From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.69 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796049739; b=WY8EAzQFjSIxxjYi5ysEk7zKdAHfIrAoJ2wMOWmkEKNEZPlA1XMniNZtnqTadxEvI+l4 aQgECbzUhlKZXyBIT3aB3I3EpJNHZTEs9vFT1GrTg2Yd60jIkbtzdRD2Szf+qBBwUZ7W9 QDChpRkecmJVVW/M/TVJGjFNUea3boGkjBW9MMLK8BrLNrEHXC6VeItK3bHYRzL8YeOcm wNhvVH2ytmgY0xR2n+MbNYn4D4nCoguC14hCpWIZ60Enb6J7bqXh4rhydjGJir3f4SAIx YQaf0B/d6NSg1qX9z48RiFPY6zlfd6IW3qpWTM96oDyWPVAkqb5sHQ90T4AybzVLA5Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796049739; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:Message-ID:Subject:From:To:Cc:Content-Type; bh=sM9uwE1EY5xsC6+GzgDv0VLEyjY1QzeLhojVMKZYwpc=; b=oI9XMc6BSFnyh1vChrH3wAPzwiFqDlIjpMWXQcruKEOcsjlF+x41JBGT62mb3w/O92ei a972Q44DTzgkpkXyh7gSMFVqvrGj8zZM63Deiw5qvTamq9IOAvNM/kDFEz5Rxk32G86cl v2nVMw90CgGSptVqBDwggV1Ch3hYJZalhiMXw5axCKWTzGnjV96GZR0EzR+sn++jIIPSe 2nD5RPm60Nr1QK2enIKLmKT96iuaUK7cSDsrotspG7esE/dcGoncbnyf18gS53r14sRvO 3QUwnjvH15b1Gh3BI7dWebnQ3JQfZ3TQZO2kDHi/43K6u6wVXphUQ12dKR+y6EDz/TQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--willemb.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b="K/dESkz8"; arc=none smtp.remote-ip=209.85.219.69 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56ABD606A325 for ; Mon, 30 Nov 2026 14:42:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 56ABD606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--willemb.bounces.google.com 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=K/dESkz8 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-92106c98714so198773036d6.3 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=vger.kernel.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=K/dESkz8m/4rUysFKeVY6Moohh1JKdkdKVAcwgUBnqUi5zvPwdKLHgGB+5OeoKQCA/ bzJqLqEtdITEkPF9dVPd+BOTmx178Pq1Y6zFKgu00ycj7exjUcmqqR717x/FFMf/m9Cy q8R+oYRh/tpqSQOFHtb9n6fN2pCcNVAO63YynLOuFm3MX6fbzXb5OfyewnTF07MUwLXK kTZslWh7KkqNaJw1Y4GLj+/YrzH+8roTlI9or6O2oHZ6Z7LxfA+IhzcsQz3RuhqGCNAS 9WlkL8FXUy2OxXe3YRKtzV6fDuo8+afzQ1NFxzpgZVx9SnYZ5ZxkcE9BifVdYwBXqf1E CCNg== 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=hxVGUxcjYQJgkuRywWK+mxkKyU2J4Xx51f/I5ea69ZxHubQTDH88T8+nByNSy7OROA eaZP/NwFodneaL4/WGlJngbb24jjHKYd0AiefpLtPpKF7+a1/YY/1DR/uADrBU0fU2mD D3YNW9WpT4mQveB4jP4u1+2n9yrMxn+rVvuygjVzzlxbRYgSsqq0d+lXo1QR3BVRXok7 EXZNnuochklTP0Dvusbw53lrzabBXTZk+PUXjWDYsnhqCt/fi82QdF308IFzKfMq5oSJ a3AlA5dYws8j99rlTMUzfhjyY/OxrcL5QBmJfdPj2gdzlaD8AqQWUOAoOTM4kmVMDNEE ysQg== X-Forwarded-Encrypted: i=1; AL+hErE3KUwjcHYBOoriULKFtX1DtPzqOkjgtSBNiIIzpu6wJx6tCsSI0DqkYCJq3BYXi4jzTqEpQKY=@vger.kernel.org X-Gm-Message-State: APuU4Z9Jz1/eHRoQPgkMOm0dLu8ZpxMwxRHpBCQc1YzP/n+6Lv8BEPWk eeQThQ0E52aimrxJwsJEXt0kBElKstuWhC9jloHLhYsN/9tOyrpQ/GFCBHFv8HCO6VlhRgDZkud wTJlo0UsU/Q== 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-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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.