From: sashiko-bot@kernel.org
To: "Jason Xing" <kerneljasonxing@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net v4 3/5] xsk: drain continuation descs after overflow in xsk_build_skb()
Date: Sat, 30 May 2026 00:44:16 +0000 [thread overview]
Message-ID: <20260530004416.EFDC11F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260520004244.55663-4-kerneljasonxing@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Invalid TX descriptors cause `drain_cont` state desynchronization, leading to dropped or corrupted packets.
--
commit 964153358c7221b02aafc63e0caa53629df56557
Author: Jason Xing <kerneljasonxing@gmail.com>
xsk: drain continuation descs after overflow in xsk_build_skb()
This commit fixes a bug where leftover continuation descriptors remain
in the TX ring after an -EOVERFLOW drop in xsk_build_skb(). It introduces
a drain_cont flag to process and drop the remaining fragments of an
oversized multi-buffer packet, preventing corruption of the packet stream.
Closes: https://lore.kernel.org/all/20260425041726.85FB3C2BCB2@smtp.kernel.org/
Fixes: cf24f5a5feea ("xsk: add support for AF_XDP multi-buffer on Tx path")
[ ... ]
> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index 0a6203c425766..f4add7be8c935 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c
> @@ -1062,11 +1062,30 @@ static int __xsk_generic_xmit(struct sock *sk)
> goto out;
> }
>
> + if (unlikely(xs->drain_cont)) {
> + unsigned long flags;
> + u32 idx;
> +
> + spin_lock_irqsave(&xs->pool->cq_prod_lock, flags);
> + idx = xskq_get_prod(xs->pool->cq);
> + xskq_prod_write_addr(xs->pool->cq, idx, desc.addr);
> + xskq_prod_submit_n(xs->pool->cq, 1);
> + spin_unlock_irqrestore(&xs->pool->cq_prod_lock, flags);
> +
> + xs->tx->invalid_descs++;
> + xskq_cons_release(xs->tx);
> + if (!xp_mb_desc(&desc))
> + xs->drain_cont = false;
> + continue;
> + }
> +
> skb = xsk_build_skb(xs, &desc);
> if (IS_ERR(skb)) {
> err = PTR_ERR(skb);
> if (err != -EOVERFLOW)
> goto out;
> + if (xp_mb_desc(&desc))
> + xs->drain_cont = true;
> err = 0;
> continue;
> }
[Severity: High]
Could this leave xs->drain_cont set to true if an invalid descriptor is
encountered?
When xskq_cons_peek_desc() encounters an invalid TX descriptor (like an
out-of-bounds address), it returns false and terminates the while loop
early.
The invalid descriptor is then consumed by xskq_cons_release() outside the
loop:
net/xdp/xsk.c:__xsk_generic_xmit() {
...
while (xskq_cons_peek_desc(xs->tx, &desc, xs->pool)) {
...
}
if (xskq_has_descs(xs->tx)) {
if (xs->skb)
xsk_drop_skb(xs->skb);
xskq_cons_release(xs->tx);
}
...
}
If xs->drain_cont was true, and this invalid descriptor happens to be the
last fragment of the overflowed packet, the loop exits before evaluating
the XDP_PKT_CONTD flag or clearing xs->drain_cont.
Will this cause a regression where the next valid packet transmitted by the
application is erroneously treated as a drained fragment and dropped because
xs->drain_cont remained true?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260520004244.55663-1-kerneljasonxing@gmail.com?part=3
next prev parent reply other threads:[~2026-05-30 0:44 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-20 0:42 [PATCH net v4 0/5] xsk: fix meta and publish of cq issues Jason Xing
2026-05-20 0:42 ` [PATCH net v4 1/5] xsk: cache csum_start/csum_offset to fix TOCTOU in xsk_skb_metadata() Jason Xing
2026-05-21 12:04 ` Maciej Fijalkowski
2026-05-30 0:44 ` sashiko-bot
2026-05-20 0:42 ` [PATCH net v4 2/5] xsk: fix buffer leak in xsk_drop_skb() for AF_XDP multi-buffer Tx Jason Xing
2026-05-21 12:05 ` Maciej Fijalkowski
2026-05-20 0:42 ` [PATCH net v4 3/5] xsk: drain continuation descs after overflow in xsk_build_skb() Jason Xing
2026-05-20 16:10 ` Maciej Fijalkowski
2026-05-20 23:53 ` Jason Xing
2026-05-21 12:02 ` Maciej Fijalkowski
2026-05-21 13:10 ` Jason Xing
2026-05-22 9:06 ` Magnus Karlsson
2026-05-22 9:22 ` Jason Xing
2026-05-30 0:44 ` sashiko-bot [this message]
2026-05-20 0:42 ` [PATCH net v4 4/5] xsk: drain continuation descs on invalid descriptor in __xsk_generic_xmit() Jason Xing
2026-05-30 0:44 ` sashiko-bot
2026-05-20 0:42 ` [PATCH net v4 5/5] selftests/xsk: drain CQ to wait for TX completion Jason Xing
2026-05-30 0:44 ` sashiko-bot
2026-05-21 12:23 ` [PATCH net v4 0/5] xsk: fix meta and publish of cq issues Maciej Fijalkowski
2026-05-21 12:41 ` Jason Xing
2026-05-21 12:59 ` Maciej Fijalkowski
2026-05-21 13:07 ` Jason Xing
2026-05-21 14:24 ` Maciej Fijalkowski
2026-05-22 8:55 ` Jason Xing
2026-05-22 13:48 ` Jason Xing
2026-05-22 18:33 ` Maciej Fijalkowski
2026-05-22 23:49 ` Jason Xing
2026-05-26 19:43 ` Maciej Fijalkowski
2026-05-26 23:26 ` Jason Xing
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=20260530004416.EFDC11F00898@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=kerneljasonxing@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.