From: netdev-bot+sashiko@kernel.org
To: razor@blackwall.org
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
ast@kernel.org, kafai@fb.com, joe@wand.net.nz,
daniel@iogearbox.net, bpf@vger.kernel.org
Subject: Re: [PATCH net] net: keep skbs with a prefetched socket out of gro_cells gro
Date: Tue, 24 Nov 2026 03:03:39 +0000 [thread overview]
Message-ID: <179548941922.3135.9577858774980848901@kernel.org> (raw)
In-Reply-To: <20261121160204.4024204-1-razor@blackwall.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 0
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).
- [High] The fix is incomplete.
--
net: keep skbs with a prefetched socket out of gro_cells gro
This patch makes gro_cells_receive() send skbs that carry a prefetched
socket from bpf_sk_assign() to netif_rx() instead of the GRO cell. The
goal is to stop GRO from clearing skb->sk and skb->destructor on merged
skbs, which leaks one socket reference per merged skb.
> diff --git a/net/core/gro_cells.c b/net/core/gro_cells.c
> index 31352cac355ce..4e8b9c3cd7da0 100644
> --- a/net/core/gro_cells.c
> +++ b/net/core/gro_cells.c
[ ... ]
> @@ -26,7 +27,8 @@ int gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb)
>
> skb_unset_transport_header(skb);
>
> - if (!gcells->cells || skb_cloned(skb) || netif_elide_gro(dev)) {
> + if (!gcells->cells || skb_cloned(skb) || netif_elide_gro(dev) ||
> + unlikely(skb_sk_is_prefetched(skb))) {
[Severity: High]
Is matching only skb->destructor == sock_pfree enough here? An skb that
got its socket from bpf_sk_assign() can still reach gro_cells_receive()
with a different destructor that owns one sk_refcnt reference per skb.
One path: bpf_sk_assign() at tc ingress attaches a non-refcounted socket,
such as a TCP listener or a UDP socket. It sets sock_pfree and takes no
reference. ip_rcv_core() keeps it. Then an NFQUEUE rule matches the outer
ipip/gre/esp packet, and __nf_queue() converts it:
net/netfilter/nf_queue.c:__nf_queue() {
...
if (skb_sk_is_prefetched(skb)) {
struct sock *sk = skb->sk;
if (!sk_is_refcounted(sk)) {
if (!refcount_inc_not_zero(&sk->sk_refcnt))
return -ENOTCONN;
/* drop refcount on skb_orphan */
skb->destructor = sock_edemux;
}
}
...
}
After an NF_ACCEPT reinject, the packet is decapsulated. With !xnet,
skb_scrub_packet() does not orphan it, so the skb arrives here with
skb->sk set and destructor == sock_edemux. skb_sk_is_prefetched() now
returns false, and the skb is queued for GRO.
skb_gro_receive() then clears both fields on each merged skb without
calling sock_edemux():
net/core/gro.c:skb_gro_receive() {
...
/* sk ownership - if any - completely transferred to the aggregated packet */
skb->destructor = NULL;
skb->sk = NULL;
...
}
The frag_list merge path in the same function does the same thing.
gro_list_prepare() still allows the merge because p->sk == skb->sk.
Wouldn't each merged skb then leak the reference that __nf_queue() took?
That is the same socket and netns teardown leak described in the commit
message.
The tree already has a general rule for this in skb_prepare_for_gro():
include/net/sock.h:skb_prepare_for_gro() {
if (skb->destructor != sock_wfree) {
skb_orphan(skb);
return;
}
skb->slow_gro = 1;
}
veth_xdp_rcv_skb() calls it before napi_gro_receive(). Could
gro_cells_receive() divert or orphan any skb that still has skb->sk set
with a destructor other than sock_wfree, rather than checking for
sock_pfree only? Checking skb->sk directly would be one way to do it.
Separately, the "sk ownership - if any - completely transferred to the
aggregated packet" comments in skb_gro_receive() look wrong for
destructors that hold one reference per skb (sock_pfree on refcounted
sockets, sock_edemux, sock_efree).
> res = netif_rx(skb);
> goto unlock;
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261121160204.4024204-1-razor%40blackwall.org
prev parent reply other threads:[~2026-11-24 3:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 16:02 [PATCH net] net: keep skbs with a prefetched socket out of gro_cells gro Nikolay Aleksandrov
2026-11-22 14:21 ` Nikolay Aleksandrov
2026-11-23 10:49 ` Eric Dumazet
2026-11-24 3:03 ` netdev-bot+sashiko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179548941922.3135.9577858774980848901@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=joe@wand.net.nz \
--cc=kafai@fb.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=razor@blackwall.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox