Article View: linux.kernel.netdev
Article #27160Re: [PATCH net 02/10] net: gro: reset unreadable and pp_recycle in napi_reuse_skb
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 22:07
Date: Fri, 04 Dec 2026 22:07
167 lines
14241 bytes
14241 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] This patch can free a page_pool page through the page
allocator.
- [Low] The commit message describes a live bug that no in-tree driver
path has been shown to reach, and it carries two Fixes: tags that will…
--
net: gro: reset unreadable and pp_recycle in napi_reuse_skb
This patch clears skb->unreadable and skb->pp_recycle in napi_reuse_skb().
The goal is to stop that state carrying over from a cached napi->skb onto
later packets. It carries Fixes: tags for the page_pool recycling hint and
unreadable frags commits.
> When an unreadable or page_pool-backed skb is
> cached and later reused for a normal readable packet (for instance across
> queue reconfiguration or shared NAPI instances), leaving skb->unreadable
> and skb->pp_recycle set on napi->skb leaks stale state onto subsequent
> packets, corrupting readability checks and causing skb_gro_receive() to
> refuse GRO merges due to mismatched pp_recycle state.
[Severity: Low]
Is there an in-tree driver path that reaches this state?
For unreadable, gve is the only driver that uses napi_get_frags() together
with unreadable netmem. gve_rx_dqo() reaches napi_get_frags() only when the
first frag is the data buffer, which is a net_iov on a devmem queue.
For such an skb, skb_gro_reset_offset() leaves frag0_len at 0. The Ethernet
pull in napi_frags_skb() then fails, because __pskb_pull_tail() returns NULL
when !skb_frags_readable(). With the earlier patch in this series ("net: gro:
free skb on napi_frags_skb() header pull failure"), the skb is freed. It
never reaches napi_reuse_skb() with unreadable set.
For queue reconfiguration, napi->skb is freed on this path, so nothing
cached survives:
gve_rx_stop_ring_dqo()
gve_remove_napi()
netif_napi_del()
napi_free_frags()
For pp_recycle, gve_rx_dqo() marks every napi_get_frags() skb again:
if (rx->dqo.page_pool)
skb_mark_for_recycle(rx->ctx.skb_head);
The other producer that leaves pp_recycle set on napi->skb is tun's XDP COW
path. There the flag is correct (see the comment on the diff below).
The KUnit test added later in the series ("net: kunit: test unreadable
net_iov napi_gro_frags") builds this state by hand. It doesn't show a driver
path that produces it.
Should this be described as hardening, with the Fixes: tags reconsidered
since they would send it to stable? Or could the message name a concrete
in-tree driver sequence that triggers it?
> diff --git a/net/core/gro.c b/net/core/gro.c
> index fb730017fd3ba..c1d07bca1b4eb 100644
> --- a/net/core/gro.c
> +++ b/net/core/gro.c
> @@ -697,6 +697,8 @@ static void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb)
>
> skb->encapsulation = 0;
> skb->ip_summed = CHECKSUM_NONE;
> + skb->unreadable = 0;
> + skb->pp_recycle = 0;
^^^^
[Severity: Medium]
Can clearing pp_recycle here free a page_pool head through the page
allocator?
napi_reuse_skb() keeps skb->head. This reset assumes the head of every skb
cached on napi->skb is not page_pool memory. That holds for
napi_get_frags(), but tun can store a different skb in napi.skb. This
happens in tun_get_user() with IFF_NAPI_FRAGS and a generic XDP program
attached:
drivers/net/tun.c:tun_get_user() {
...
ret = do_xdp_generic(xdp_prog, &skb);
...
if (frags && skb != tfile->napi.skb)
tfile->napi.skb = skb;
...
}
The frags skb is always nonlinear, so do_xdp_generic() can replace it:
do_xdp_generic()
netif_receive_generic_xdp()
netif_skb_check_for_xdp()
skb_cow_data_for_xdp()
skb_pp_cow_data()
skb_pp_cow_data() builds the new head with page_pool_dev_alloc_va() and
napi_build_skb(), so head_frag is 1. It then calls skb_mark_for_recycle().
Suppose skb_gro_receive() merges that skb with headlen <= offset. It sets
NAPI_GRO_CB(skb)->free = NAPI_GRO_FREE, and napi_frags_finish() passes the
skb to napi_reuse_skb(). pp_recycle is then cleared while skb->head is still
a page_pool page.
The cached skb can be freed next in several ways:
- consume_skb() in skb_pp_cow_data() on the next XDP COW
- napi_free_frags() from netif_napi_del()
- a tun drop path
In each case skb_free_head() would take the non-recycle branch:
net/core/skbuff.c:skb_free_head() {
...
if (skb->head_frag) {
if (skb_pp_recycle(skb, head))
return;
skb_free_frag(head);
...
}
Wouldn't that return the page_pool page to the buddy allocator? It would
then trip the page_pool_page_is_pp() bad page check and throw off
page_pool's in-flight accounting.
Before this patch, pp_recycle stayed set across reuse and the head was
recycled correctly. Mixing it with tun's non-page_pool frags was fine,
because napi_pp_put_page() falls back for non-pp netmem.
Reaching this needs all of the following:
- CAP_NET_ADMIN
- an XDP program with frags support on the tun device
- deferred NAPI completion (napi_defer_hard_irqs or gro_flush_timeout)
- a merge where the linear length exactly matches the GRO header offset
Could pp_recycle be cleared only when the head is not page_pool memory? For
example:
!skb->head_frag ||
!page_pool_page_is_pp(virt_to_head_page(skb->head))
Checking !head_frag alone wouldn't be enough, because napi_alloc_skb() can
also return head_frag skbs.
Other options would be to drop the pp_recycle reset, or to make sure
napi->skb only ever comes from napi_get_frags().
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1796329894.git.tavip%40google.com
Technical Details
Message-ID:
<179642206721.3146.14507054591597786210@kernel.org>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mi.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377686-linux-kernel-netdev=dewy.ruReferences:
<808e0a7c2cbb252654d1d55368858b774cf48853.1796329894.git.tavip@google.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mi.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377686-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net 02/10] net: gro: reset unreadable and pp_recycle in napi_reuse_skb Date: Fri, 04 Dec 2026 22:07:47 +0000 Organization: Usenet Network Message-ID: <179642206721.3146.14507054591597786210@kernel.org> References: <808e0a7c2cbb252654d1d55368858b774cf48853.1796329894.git.tavip@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2883806"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:cqIH64DZe12AMkGic5vgu8/tbME= sha256:Z724tlPmmcnahQETeRb0/O2sEq0MXyzxc451V46ysuY= sha1:ITYvLfaYR0UI4VwPfzS2TYiiZl4= sha256:0QQ/frmVEwr289wOtbEnfNJWqVhY0cDEMoCmRrI1u9o= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id BDC38117C79; Sat, 5 Dec 2026 01:08:06 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.641 X-Spam-Status: No, score=-3.641 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Io6MbmXPOBXx; Sat, 5 Dec 2026 01:07:59 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-377686-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 9C9B8117D0A; Sat, 5 Dec 2026 01:07:51 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 33DD0608D01; Fri, 4 Dec 2026 22:07:51 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796422070; b=o0MCoYfNVMLcstAvFL3Cy7ebjVfFwX4oXihCoSyMjq2E9UgJK0K9ocMnv3gCvwA6cNbw iTkr9u8YqN1t+qyQnTNoRX1i3Nv+laVCIbMK8wsSmxSAehhH7XJJdzH+rs93L25cJ/N4E YaghLk7jZJgLtyfKzofpBGoVNgW9MpKAh+eBEHQ3ztYskTuLhUQWD2oajVZihgoDUEeM2 At+hdCAz+6hI/rNFXFBY1Dhg8C1T5Lg8P12ZEOFIKC9K5oxjDkZ1tO45Mlc6pAaSAWl5h AI3buyPNqPK2/gg+v2GtIq8Egr7N2PMzQThHabHgeyvsaJ2ce7ZMVCMKDmlyJrPH98g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796422070; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=EzdSE9/ZMDIgxCwkI3toA2LVm1dTGHeIMdOQujBBMGc=; b=2rb71kOZi5jFSziFlrYKtrmL1aZ5zmQBlcv8hNV6c1zDkg8HM1akyTfTWHZdFhWjoNMD Krfqa6CJf0JBS62GpzP1KG0k8qUEZS3a01yaNjPVXzojlJDc7ZZoi/LtRj1/fBNlF9U1t bexIpg+bGF37L3AmZJvYbTrFuRFtQ03NU8/rQtDspIy3dhAIyly2mMr7eP8jJw/A+r3x8 idbdnyZHDJxfkQ+osslnmAMGNlXabtiNfVKLrvZ1J/005WPOVtKzLOCS92OMGtIglBXXr QumaogOkdD8mUVA2fAWhrSQG6yblpIqe3pfe3dzLOayj/Da3AlYqLq1mz/cK6Bn7WiQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mROuma7o; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67744606A33A; Fri, 4 Dec 2026 22:07:50 +0000 (UTC) X-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=mROuma7o X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796422069; b=En3rMVqOGkvKh6CAPGeHEOeDENvbbj8AXt3vNRWclRl9JEfIqvqs2voNDwE2oAicuj1L qq3bS2cZj0CZnN8KY16rah6FiAAiE/CpK6ucMCosGoGbs8zkx3H6jQ+HkpzUJOkbDfUE5 28QRisduz0SfcEtr7rmytqox4pBY79UePko01Wqp+hFWweLf2B4ob2qmaqnsPRZt80gXV vm6jzH7kOFXXUWTWrkmlNlM62WAf3g5s1QfWx69aI43BEqM9D4/cik4DlGVATtYOIhH0s QqHwWb2Otq3sgwQdx/2ih1jh3BFgXkidEJcx280vYn2bFwh/Y0SLBTtScecEwSYU/QQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796422069; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=EzdSE9/ZMDIgxCwkI3toA2LVm1dTGHeIMdOQujBBMGc=; b=eUb3ExaH5YCPyJ49LWh6EMShOhGq0xTuTlxoSz/+LaHkXYEmqy4pSvt87OyH3WswsfWU TIsOQPIcIaIU5aVWHwuhtSxQ9Wex+cLVug+7p0QtYJcPSMIVPE+zrWKXAmTNaieHQiZUZ ulcfHssdedvcQcvwj1/hjbwGzQAUJjrc5L+TGi8NM+tpM5bV3LeYCU+4aohwHTfBmc256 vS/hpOEXHhJsGo+o5V/DOtSHp+y5x+oNcCjsYlPD1479OBb0uvCvslyj9hGH9fQQ7FsjT jNxSwR/YlEhZk2d8JjObugsJeptMJ46i5uWfkIDiXRMCIeapZUL+dAOcodrw7Girojg== X-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=mROuma7o; arc=none smtp.remote-ip=100.103.45.18 X-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 892FD606A339; Fri, 4 Dec 2026 22:07:49 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB9861F0093B; Fri, 4 Dec 2026 22:07:47 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796422069; bh=EzdSE9/ZMDIgxCwkI3toA2LVm1dTGHeIMdOQujBBMGc=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=mROuma7oO8y2PmQcfZs4m4dBJvb+YgwF/u8PaeeMVeVUvPR9euXXpKgHAfGLfbeJC cLHydH7RyA/78KoH3Cx3FV17uE4S1t4pwlg1MvMyET6CcM1OZ8xHpoxhZdOnGBk3kz LgTL8njQzUNNJlCACFv4XWAcnNHh0XDhzOtdgzYO4hQRZYLEfGqu16NwW1Bvz1DWRJ Y2mH4s7lUV1LUN006N/0GSYl6JQrai34apvDN/+0hRQHSkSgt3EDgJSd0jOiK8C/7K 3wqnSGnVVJUmPjjCi9fDwUIVnQ8zVDlmmfPBwFdMnDDTc6WY6SJhdXEujQuWcchbSr txTWTehgbp2OQ== X-Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org, andrew+netdev@lunn.ch, ncardwell@google.com, kuniyu@google.com, dsahern@kernel.org, idosch@nvidia.com, john.fastabend@gmail.com, jakub@cloudflare.com, jiayuan.chen@linux.dev, sd@queasysnail.net, shuah@kernel.org, almasrymina@google.com, sdf@fomichev.me, kaiyuanz@google.com, ilias.apalodimas@linaro.org, hawk@kernel.org, mcroce@microsoft.com, herbert@gondor.apana.org.au, ecree.xilinx@gmail.com, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org X-In-Reply-To: <808e0a7c2cbb252654d1d55368858b774cf48853.1796329894.git.tavip@google.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list