From: Jakub Kicinski <kuba@kernel.org>
To: edumazet@google.com
Cc: Jakub Kicinski <kuba@kernel.org>,
davem@davemloft.net, pabeni@redhat.com, horms@kernel.org,
kuniyu@google.com, netdev@vger.kernel.org,
eric.dumazet@gmail.com, melotti@google.com, fw@strlen.de,
hawk@kernel.org, posk@google.com
Subject: Re: [PATCH net] inet: frags: fix a possible frag_mem_limit drift
Date: Mon, 25 May 2026 11:42:32 -0700 [thread overview]
Message-ID: <20260525184232.2384368-1-kuba@kernel.org> (raw)
In-Reply-To: <20260522140045.1836961-1-edumazet@google.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
inet: frags: fix a possible frag_mem_limit drift
This patch attempts to compensate for a frag_mem_limit accounting drift
in inet_frag_reasm_prepare() when an incoming fragment that completes
reassembly is not the first fragment, by adding the difference between
skb->truesize and head->truesize to fqdir->mem before consuming head.
> diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
> index 393770920abd..3222cc2ac235 100644
> --- a/net/ipv4/inet_fragment.c
> +++ b/net/ipv4/inet_fragment.c
> @@ -539,6 +539,9 @@ void *inet_frag_reasm_prepare(struct inet_frag_queue *q, struct sk_buff *skb,
> FRAG_CB(skb)->next_frag = FRAG_CB(head)->next_frag;
> rb_replace_node(&head->rbnode, &skb->rbnode,
> &q->rb_fragments);
> + delta = skb->truesize - head->truesize;
> + if (delta)
> + add_frag_mem_limit(q->fqdir, delta);
[High]
Can the new delta computation ever evaluate to a non-zero value at this
point?
Looking a few lines above in the same function, skb_morph(skb, head) is
invoked before this hunk:
skb_morph(skb, head);
FRAG_CB(skb)->next_frag = FRAG_CB(head)->next_frag;
rb_replace_node(&head->rbnode, &skb->rbnode,
&q->rb_fragments);
delta = skb->truesize - head->truesize;
In net/core/skbuff.c, skb_morph() is implemented as:
struct sk_buff *skb_morph(struct sk_buff *dst, struct sk_buff *src)
{
skb_release_all(dst, SKB_CONSUMED);
return __skb_clone(dst, src);
}
and __skb_clone() copies truesize from src to dst via the C(x) macro:
#define C(x) n->x = skb->x
...
C(truesize);
So by the time the new code runs, skb->truesize has already been
overwritten with head->truesize, and the subtraction is identically
zero. The if (delta) branch never fires and add_frag_mem_limit() is
never called.
If the drift described in the changelog is real (the original
skb->truesize accounted via ip_frag_queue() differs from the clone fp's
truesize that ends up being subtracted later), would the compensation
need to be computed before skb_morph() overwrites skb->truesize, or
expressed against fp->truesize rather than the post-morph skb->truesize?
> consume_skb(head);
> head = skb;
> }
--
pw-bot: cr
prev parent reply other threads:[~2026-05-25 18:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-22 14:00 [PATCH net] inet: frags: fix a possible frag_mem_limit drift Eric Dumazet
2026-05-25 18:42 ` Jakub Kicinski [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=20260525184232.2384368-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=fw@strlen.de \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=kuniyu@google.com \
--cc=melotti@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=posk@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