From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0959D606A31C for ; Mon, 30 Nov 2026 14:42:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=iv05aDHg Received: by kanga.kvack.org (Postfix) id D862F6B05B2; Mon, 30 Nov 2026 09:42:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D36CD6B05B3; Mon, 30 Nov 2026 09:42:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C73A66B05B4; Mon, 30 Nov 2026 09:42:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 570326B05B2 for ; Mon, 30 Nov 2026 09:42:20 -0500 (EST) Received: from smtpin05.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay01.hostedemail.com (Postfix) with ESMTP id F3AF11C4385 for ; Mon, 30 Nov 2026 14:42:19 +0000 (UTC) X-FDA: 85492050798.05.3C27C36 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by imf06.hostedemail.com (Postfix) with ESMTP id 40746180016 for ; Mon, 30 Nov 2026 14:42:18 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20260707 header.b=iv05aDHg; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of 3R4sNawcKCPIqcffYgVaiiafY.Wigfchor-ggepUWe.ila@flex--willemb.bounces.google.com designates 209.85.219.70 as permitted sender) smtp.mailfrom=3R4sNawcKCPIqcffYgVaiiafY.Wigfchor-ggepUWe.ila@flex--willemb.bounces.google.com ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796049738; b=kUyaRLwFIsjhXLkwgnrpSRXafj2dtc3zqacccNRxnB15rYTkT3lHM0/u5nOBpQKCgkx1DD kC+uhrsHCrOOxUEzzGNeLjqDhV4T9xPqPVnbTbQ1nR/22BYsjPYSeCsbfpyfi+CP6LDISO sleE5WMv15LP2UisikNXTqnnlNRM0x8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796049738; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=sM9uwE1EY5xsC6+GzgDv0VLEyjY1QzeLhojVMKZYwpc=; b=UbD0ot8IpGtItCB1Ok4Ab7Sz+SdJnmB3uRGxluzaWKDSEKAGqUkk+Vr4q+F3ISg0FqfzIE VR5XjfkxTUGMUtjCSeM3+yZ/wB6ih3oJF/BgiIPIvIu1XnNX4v5ImXWYJR3JzaFahp3mWS jvmr4yZw4gYZghbr2FUWh4YGp3N7+34= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20260707 header.b=iv05aDHg; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of 3R4sNawcKCPIqcffYgVaiiafY.Wigfchor-ggepUWe.ila@flex--willemb.bounces.google.com designates 209.85.219.70 as permitted sender) smtp.mailfrom=3R4sNawcKCPIqcffYgVaiiafY.Wigfchor-ggepUWe.ila@flex--willemb.bounces.google.com Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-9210bbc04abso199341156d6.2 for ; Mon, 30 Nov 2026 06:42:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796049737; x=1796654537; darn=kvack.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=sM9uwE1EY5xsC6+GzgDv0VLEyjY1QzeLhojVMKZYwpc=; b=iv05aDHgA1eGmyKNk67XobQtahEeunKYcuKIcyuhy4BkL1K0IRg0Y8ApiRaZRzHuza +pDCruHapEDGJLYH+5zFejuwr14qV89bmuLvIvjCKJBXwny1cjpi/5A2QAMqgzGOS1UC QDTnVC9kQoDjT9VWpkOLX2hdApdED99OOrWrGSDXwE77V2V4vRUI0jxdWK7SgMzaIELo E7/fzDyE8w3buxqHN1wMNVoP9zmrG/581GXBp6Ei5pBvjqlXaatRna4Q3X8Xb+u2Wt5s 7zIt/56JXwJQIHKoHIaQP5pWJXsqXWoZysgCMVvTsLAIMdEiTozAHHTrR4oyuI47JtKR EXkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796049737; x=1796654537; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=sM9uwE1EY5xsC6+GzgDv0VLEyjY1QzeLhojVMKZYwpc=; b=NMo1NsQYRSMrB5m56P0s9XqP5CXZ0hv1P5i9kUY/98ZqIjJsm++aDrvhQV8/PhcIOO U7qIBY3cTyeKNKyT8vZnucr0/lLJC/Y3i/1s8XkfVHHu3TuEFrqpc0KB/9zCYW0XOnZ3 I+m2vQtiN0GX/8ugpPDa7URGbij9I1c06fLKaEDhEoVyJ+1KU4bGaKeIetXwC7w6bE6H Q3rgNDTxPY/YVkpYLhPa4g5qmmQMES3x6QFNsFEdYshwbRm/GayhvxoThK1/C4fKh0Xl pSpzcp/6NRC5GcrZr4b6FM/Xhh/W7eSmtWwQwMvSfiLUD1tCGPWlbc/Bu9ytyZzVNeEF EPcQ== X-Forwarded-Encrypted: i=1; AL+hErE7RDIhCouizwzqL7iRaq1uIGNPlaW7N+Xu6FQZlaiU/VOjxSKpTmKddQ0M4SLozkjNlrn/foH1fQ==@kvack.org X-Gm-Message-State: APuU4Z+3rQPlamUVblFbfPOexMCW7JSTpy6CV0enFF9qTATnUIjXk1SQ /S6E1Qoojy5EWdv+6+UJY2TOpfaWK8ESVXXtqH4mmeJT2Y9+NnVYIVCXE1Hpe7ZsxMbQEsybTWy Q4r7Ufjix+g== X-Received: from qkcbk10-n1.prod.google.com ([2002:a05:620a:72ca:10b0:945:fedd:e5df]) (user=willemb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:620a:4443:b0:949:7c8c:54c7 with SMTP id af79cd13be357-949bab7e84dmr6299979085a.72.1796049735977; Mon, 30 Nov 2026 06:42:15 -0800 (PST) Date: Mon, 30 Nov 2026 09:42:15 -0500 In-Reply-To: <20261126-skb_refcount_overflow-v2-0-a6f600a5634a@kernel.org> X-Archived-By: Mime-Version: 1.0 References: <20261126-skb_refcount_overflow-v2-0-a6f600a5634a@kernel.org> Message-ID: Subject: Re: [PATCH net v2 0/4] net: skbuff: limit pagecache folio refcount From: willemb@google.com To: "David Hildenbrand (Arm)" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Stanislav Fomichev , Willem de Bruijn , 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, "David Hildenbrand (Arm)" , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes X-Stat-Signature: enkfr6j5raoiqo854dk1ofnh5umfyow4 X-Rspamd-Queue-Id: 40746180016 X-Rspam-User: X-Rspamd-Server: rspam03 X-Spam-Status: No, score=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, S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/7brMLqtBFj73xVdPsuSJjTY2bbP4hbpDNttfLc3LHQtpofcdt+qy1rqEhs3+wrCr8UkrLxYOs5fg2AB3yfn6uE+IfNq3na4re9LDHtpW3+D/WtLW6wnq1WkX3016EU5LQAmePTUgYUu2RgJ/b5l4fLp8cbDT3a821b/KkzFoBexzpRbXBitRH6eN3TWEGZPqqya/BOz/Xb0C7vVVvNYkrba2vNKsAx6y0yjQG+bcP83lI1fCb63pvQOL3RAWzmMd0LYMn4IwjNrI+xZryZDFAWUvzq9anqXOhCDxFRi985L2nXPzTr+lE80BxBUodB6n1Hg4lY0DeKK6iepmho5Fkt6G3j6LSKC9vRvXp3xs5LL442shqtoiacw2KF2S2f4Yu+Txx0oNjziPkburz45Ye+g0LolR3gFacqXHlAEGiIbNzKSZ7NsIq9l74blldj3I585LV9SMYZoFkTy7a9+z7d80pKOFOpmxQjiGPmuEXIkEUhD16RcaHB7akn1o3bRcsNaAyp9f8sFjMMGWR8L7T5h84+q1orLsxyWUDgPEFCqMZB+wzKBrGoEGMGeGmLm3GX9qFW6fTnARuEM1Q93A+84YqPxFEGhu6z3mHjkD0SHaWv1qKew5PBZDeYUfMkRnnkZfiJpgtiDrCQkq/8sQ86S98T9ofrdMto018n2WNB5QEtPrVtME/4KSbEd2CJpKDZibMuoV4yQjZUDPq9c+IClXlj1NyCWoeFk5cSkJEzs9t+4Sw6KQkfvvLjAICucvNOxpiCi+jQfS/P2viuNWr0arpgTsxnBp64QXlyjfmp6nMcp8b3P2WuaSKQ7/yIXW0Fmnc2pODlt3XOYmepJuMJhXNhB0u2v9EBIzYJqbRMtX+TgCnLUMOJcQdY73rcHNxnQftb7xar2446CMy3rg0N1jmGsxi1XcMA/NqiHWL25+ZVH+lKLrzrtXlAKuqsHKtZWoQ34FJWPwaEmVZcRwsd v0aoTlsF qK7L5uMkGiI= Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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.