From: sashiko-bot@kernel.org
To: "Sun Jian" <sun.jian.kdev@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net 2/2] veth: fix skb length accounting after XDP frag adjustment
Date: Tue, 28 Jul 2026 03:26:11 +0000 [thread overview]
Message-ID: <20260728032611.EA2001F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <20260727032535.13469-3-sun.jian.kdev@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Incorrect ordering of SKB length synchronization and manipulation helpers causes BUG_ON() panics in __skb_put and __skb_pull.
--
--- Patch [2]: [PATCH net 2/2] veth: fix skb length accounting after XDP frag adjustment ---
commit 7bca8b2841500975db8d1e89e6bd51e147aa4ad3
Author: Sun Jian <sun.jian.kdev@gmail.com>
veth: fix skb length accounting after XDP frag adjustment
This commit fixes an issue where veth_xdp_rcv_skb() left skb->len containing
stale fragment sizes after an XDP program adjusted the fragment area. It
subtracts the old data_len before replacing it and adds the new data_len
afterwards to keep skb->len and skb->data_len synchronized.
Link: https://lore.kernel.org/r/20260720141859.19FF41F000E9@smtp.kernel.org
Link: https://lore.kernel.org/bpf/al9T9Eto%2FhRIzP5W@boxer/
> diff --git a/drivers/net/veth.c b/drivers/net/veth.c
> index 00e34afd858e7..a956498a073be 100644
> --- a/drivers/net/veth.c
> +++ b/drivers/net/veth.c
> @@ -871,12 +871,14 @@ static struct sk_buff *veth_xdp_rcv_skb(struct veth_rq *rq,
> __skb_put(skb, off); /* positive on grow, negative on shrink */
[Severity: High]
This is a pre-existing issue, but can this sequence of SKB length
synchronizations trigger a kernel panic due to the order of operations?
If an XDP program modifies a fragmented packet, veth_xdp_rcv_skb() adjusts
the head and tail before syncing skb->data_len:
if (off < 0)
__skb_pull(skb, -off);
...
if (off != 0)
__skb_put(skb, off); /* positive on grow, negative on shrink */
If the XDP program shrinks the tail past the fragments, __skb_put() is called
with a negative offset while skb->data_len is still non-zero. Doesn't this
trigger SKB_LINEAR_ASSERT if CONFIG_DEBUG_SG is enabled?
Likewise, if the program shrinks the head (triggering __skb_pull() before
updating skb->data_len), could skb->len drop below the stale skb->data_len
value? This would hit the unconditional BUG_ON(skb->len < skb->data_len)
inside __skb_pull() and cause a denial of service.
Would it make sense to synchronize skb->data_len and skb->len before calling
__skb_pull() and __skb_put()?
>
> /* XDP frag metadata (e.g. nr_frags) are updated in eBPF helpers
> - * (e.g. bpf_xdp_adjust_tail), we need to update data_len here.
> + * (e.g. bpf_xdp_adjust_tail), update skb length fields here.
> */
> + skb->len -= skb->data_len;
> if (xdp_buff_has_frags(xdp))
> skb->data_len = skb_shinfo(skb)->xdp_frags_size;
> else
> skb->data_len = 0;
> + skb->len += skb->data_len;
>
> skb->protocol = eth_type_trans(skb, rq->dev);
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260727032535.13469-1-sun.jian.kdev@gmail.com?part=2
prev parent reply other threads:[~2026-07-28 3:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 3:25 [PATCH net 0/2] xdp: fix skb length accounting after frag adjustment Sun Jian
2026-07-27 3:25 ` [PATCH net 1/2] net: fix skb length accounting after generic XDP " Sun Jian
2026-07-27 19:06 ` Maciej Fijalkowski
2026-07-28 3:26 ` sashiko-bot
2026-07-27 3:25 ` [PATCH net 2/2] veth: fix skb length accounting after " Sun Jian
2026-07-27 6:54 ` Lorenzo Bianconi
2026-07-27 7:28 ` Lorenzo Bianconi
2026-07-28 3:26 ` sashiko-bot [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=20260728032611.EA2001F00A3E@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sun.jian.kdev@gmail.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