netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Aleksandrov <razor@blackwall.org>
To: willemb@google.com, netdev-bot+sashiko@kernel.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: Thu, 26 Nov 2026 10:49:22 +0200	[thread overview]
Message-ID: <cea8eaf8-ea5f-4165-84ff-a8b2a944ebb5@blackwall.org> (raw)
In-Reply-To: <willemb.1b39ecea58ba6@google.com>

On 26/11/2026 02:36, willemb@google.com wrote:
> Nikolay Aleksandrov wrote:
>> On 24/11/2026 05:03, netdev-bot+sashiko@kernel.org wrote:
>> > 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:
>> >
> 
>> Oh well the bot seems right even though it's a weird case, I'd suggest to change
>> the check and orphan on any skb->sk set, i.e.: || unlikely(skb->sk)
>> instead of unlikely(skb_sk_is_prefetched(skb)), that is cache hot too as
>> skb->dev is read before and will catch
> 
>> Also tried asking an LLM if I'm missing something and the only case it could come up
>> that will not be aggregated is:
>> "the only correct aggregation that's lost is software ESP over veth or netdevsim in tunnel mode"
>> IMO that is ok.
> 
>> What do you think?
> 
> This also affects ESP over tuntap with IFF_NAPI. But that is not a common
> production configuration.
> 
> So LGTM.
> 
> Just a small note that redirect to netif_rx != orphan. No need to orphan.

Oh yes, of course. I was thinking and working on bpf_sk_assign egress support
which needs to orphan in a few places and blurped orphan when replying :)

Thanks!

      reply	other threads:[~2026-11-26  8:49 UTC|newest]

Thread overview: 7+ 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
2026-11-24  8:39   ` Nikolay Aleksandrov
2026-11-26  0:36     ` willemb
2026-11-26  8:49       ` Nikolay Aleksandrov [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=cea8eaf8-ea5f-4165-84ff-a8b2a944ebb5@blackwall.org \
    --to=razor@blackwall.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-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    /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;
as well as URLs for NNTP newsgroup(s).