From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796052944; b=o1k6JyNAGxC8Oy4+E+fKMXNCvTzuR+uQoGSyrNJCbEHYcdQ1nx60x4qfTS9avFXVpC87 dhhr7JEfeYijE5YnAF4YtTzLNcP1K/xes1TqqLDRceoc7NT4FIU3PIp0CYIT0Eh+DlaiZ LAt0sXQe5X819K8M/h4GQQQGwo+UiSrRKV7UFk46oqc7JYLc4XTUa+pSz8vjSOovmLpGT pvJ9Qu1kAKHr7sefLbUVfNhr3ic1CUIqEy8UkVp7T6t3xAEh84GupQWzcnHMG7PCV4c47 m+F4ArRn4nGxPoms/cZlFaaU/w0ihnbqXD9rN4YS1ddnY0rEY69khDkSRYH5q4tAJZA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796052944; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:Content-Language:Autocrypt:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=wQ6JG85yB81gwH07UuqmTgsVrROL+7eCyuIu8kNOAcc=; b=m/5TepZnRCWHsYPcsjvH71ekdDzQiPxgLRr4NjzAKnU7V0hyoi3TX1MNsnCF4AvQ+LnQ SiT7NgoXSY4zfMjAQNI8fHxGtS4Tq9RqsTUJXbkf2G4fRIoviCpKUMPcs/0ha1WvKT/ED Qx4H8RS+tOyiFyryGGNw8Tx4j9qGso8sOvMm+jxU/pzR+QAJ1+cP9hWXUNW2b4tXiIT1H 9pbeaO0nVSgLFxzFiS8YdDz847l/Qm1yrnn9OlO4uIwONXhH2/j17MjACpuYTTYZ+gXqU 2BXP/eYZqEdpjLKrga0apMY7hvPbw16CYHcPxnLjeJiOYDjwIeJCZNFvb8afqNHPBfg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HfoDHn81; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4A6C606A31C; Mon, 30 Nov 2026 15:35:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HfoDHn81 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB6B21F0089F; Mon, 30 Nov 2026 15:35:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796052944; bh=wQ6JG85yB81gwH07UuqmTgsVrROL+7eCyuIu8kNOAcc=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=HfoDHn81CvYJcnKVOWlXo9AWhO5rBQ6nOrOzjNpNGXWzwckXmI0pts1wLCo/wkFex qpJNuiCXMi4Oewzk6iWWc6ijLf1wKfBpXfppx2chQR2ceMf37lNxYUomNIoeYthKjw jIjW4HAlfpT1fgC7snMjRVpA9o4jfYu3aB3x7+GlypmYkttXF9KA6AU+FVBnGAjxoJ Ju0MOhLl+vwStLjHwQnmjToGXFYvsjfSk9bkPe8N/h6U44sJI0OTlXjfDjr2krSw2w FxKz2RuD708m3JMcL6h2t0C6CIhyQoqlOKReHZ/Wx1I6pwtSNAz3VU1HjXgqNjiHH5 ryDftgfC2b5YA== Message-ID: <6c029802-08ca-4858-b0e1-63e40c6c75fc@kernel.org> Date: Mon, 30 Nov 2026 16:35:34 +0100 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net v2 0/4] net: skbuff: limit pagecache folio refcount To: willemb@google.com, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Stanislav Fomichev , Simon Horman , Andrew Morton , Kiryl Shutsemau , Song Liu , Johannes Weiner , Rik van Riel , "Matthew Wilcox (Oracle)" , Neal Cardwell , Kuniyuki Iwashima , Pedro Falcato , Chuck Lever , Jeff Layton Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, stable@vger.kernel.org References: <20261126-skb_refcount_overflow-v2-0-a6f600a5634a@kernel.org> From: "David Hildenbrand (Arm)" Content-Language: en-US Autocrypt: addr=david@kernel.org; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQRwU0O/ztJIQqsE5LsUomE//bLwzj9IVsaQpKDqW6TAPjcdBDPLHvriq7kGjt WhVhdl0qEYB8lkBEU7V2Yb+SYhmhpDrti9Fq1EsmhiHSkxJcGREoMK/63r9WLZYI3+4W2rAc UucZa4OT27U5ZISjNg3Ev0rxU5UH2/pT4wJCfxwocmqaRr6UYmrtZmND89X0KigoFD/XSeVv jwBRNjPAubK9/k5NoRrYqztM9W6sJqrH8+UWZ1Idd/DdmogJh0gNC0+N42Za9yBRURfIdKSb B3JfpUqcWwE7vUaYrHG1nw54pLUoPG6s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g r7xDAYKIrAwfHHmMTnBQDPJwVqxJjVNr7yBic4yfzVWGCGNE4DnOW0vcIeoyhy9vnIa3w1uZ 3iyY2Nsd7JxfKu1PRhCGwXzRw5TlfEsoRI7V9A8isUCoqE2Dzh3FvYHVeX4Us+bRL/oqareJ CIFqgYMyvHj7Q06kTKmauOe4Nf0l0qEkIuIzfoLJ3qr5UyXc2hLtWyT9Ir+lYlX9efqh7mOY qIws/H2t In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 11/30/26 15:42, willemb@google.com wrote: > David Hildenbrand (Arm) wrote: >> Hi, > >> This is v2 of the remaining folio refcount overflow fixes that should go >> through the net tree, ideally soon. They address the known cases where >> networking can still overflow the folio refcount by taking unbounded >> references. > >> The series is based on Linus' tree, which includes the MM prerequisite >> c6c9a4c1c9a16 ("mm: limit pagecache folio refcount when splicing into >> pipes") that adds the refcount limit checks to try_get_page(). > >> More details in [1], but in essence: > >> There are ways to overflow the folio refcount and cause trouble either >> by letting it go negative or letting it go all the way back to 0. > >> This is particularly easy with large pagecache folios, where page table >> mappings can "easily" create many references. The MM changes limit >> references from page tables, GUP and pipes, and leave some headroom for >> races, other bounded refcount users etc. > >> However, skbs can easily multiply folio references, so any such skb path >> that can take unbounded folio references must also obey the new limits: we >> must use try_get_page() to obtain an additional folio reference and handle >> failures accordingly. > >> Patch #1 introduces skb_frag_try_ref() and skb_frags_try_ref() and uses >> them when copying skb frag references. Patch #2 covers rearranging >> frags. Patches #3 and #4 cover splicing pages into skbs and splicing data >> from sockets into pipes. > >> We use existing failure paths where possible. Socket splicing returns >> the bytes already spliced, or -EFAULT if no data could be spliced because >> try_get_page() failed. > >> Net paths that take folio references that I don't touch because the >> references are either bounded or the paths are not relevant in practice: > >> - skb_split(): each reference needs a new socket-charged skb. >> - IP-TFS reassembly: each reference needs a new inner skb. >> - io_uring zerocopy send: each piece is charged >= 4 KiB of TCP memory. >> - kTLS software splicing: only transfers references from the pipe. >> - kTLS device offload: pushing the record fails in skb_append_pagefrags() >> (patch #3), so a socket can exceed the limit by about one record. >> - AF_XDP zerocopy TX, nfsd splice reads, sockmap / sk_msg, espintcp: >> bounded, or require privileges / special setups. >> - Other driver-specific paths: not looked into for now, as I can neither >> test them nor see if they actually trigger unbounded references. >> - page_pool and net_iov frags: not pagecache pages. > >> The original refcount overflow problem was reported by Anthropic; we >> knew that it was possible in theory, but didn't expect to have easy ways >> to trigger it. After fixing the splice issue, I used AI to identify >> other unbounded folio refcount users, and it flagged various skb-related >> paths. I made it actually reproduce unbounded references. These patches >> address the paths that were actually reproduced. > >> I ran tests before and after applying the changes, using a kernel with >> reduced folio refcount limits. These tests focused on exercising the new >> error paths and checking that the refcount limits were respected. > >> These tests covered AF_PACKET, nft dup, NFQUEUE, software GSO >> segmentation, TCP receive coalescing with dropped ACKs, and socket >> splicing. > >> I also ran the following networking selftests successfully: > >> - net:tls >> - net:udp_splice_checksum >> - net:udpgso.sh >> - net:msg_zerocopy.sh > >> If there are any further tests I can run, please let me know; help with >> testing would be appreciated as well, as I only have access to limited >> hardware and have limited net experience in general. > >> [1] >> https://lore.kernel.org/linux-mm/20261112-refcount_overflow_stable-v4-0-ad3deef0bd23@kernel.org/ > >> Signed-off-by: David Hildenbrand (Arm) >> --- >> Changes in v2: >> - "net: skbuff: limit folio refcount when copying skb frag references" >> - Fix skb_zerocopy() kernel-doc indentation >> - "net: skbuff: limit folio refcount when splicing pages into skbs" >> - Mention nfsd connection teardown in the description >> - "net: skbuff: limit folio refcount when splicing from sockets" >> - Propagate the error through an "err" pointer >> - Document the skb_splice_bits() return value >> - Update the description accordingly >> - Drop Pedro's Ack >> - Extend the cover letter >> - The GVE issue sashiko reported has already been fixed in commit >> 3946899dbeac ("gve: fix RX page refcount overflow from INT_MAX >> pagecnt_bias"). >> - Link to v1: >> https://patch.msgid.link/20261118-skb_refcount_overflow-v1-0-5551b4954c3f@kernel.org > >> --- >> David Hildenbrand (Arm) (4): >> net: skbuff: limit folio refcount when copying skb frag references >> net: skbuff: limit folio refcount when rearranging skb frags >> net: skbuff: limit folio refcount when splicing pages into skbs >> net: skbuff: limit folio refcount when splicing from sockets > >> include/linux/skbuff_ref.h | 53 ++++++++++++++++++++ >> net/core/skbuff.c | 117 >> +++++++++++++++++++++++++++++---------------- >> net/ipv4/tcp_output.c | 8 ++-- >> 3 files changed, 134 insertions(+), 44 deletions(-) >> --- >> base-commit: 63fdb511c27afcebce797e3db580b3534ddfa639 >> change-id: 20261117-skb_refcount_overflow-75a0034e469e > >> Best regards, >> -- >> David Hildenbrand (Arm) > > For the series: > > Reviewed-by: Willem de Bruijn > > Thanks, David. Btw, definitely no expectation that all sashiko low > severity comments get a response, let alone are addressed. > > The series has a merge conflict. Just figuring out how to best > handle that, but an LGTM in the meantime. Thanks William! Just let me know if any action from my side is required (rebase against a specific branch, resend, etc ..). -- Cheers, David