From: sashiko-bot@kernel.org
To: "Jason Xing" <kerneljasonxing@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net v2 4/5] xsk: drain continuation descs on invalid descriptor in __xsk_generic_xmit()
Date: Sat, 16 May 2026 12:31:27 +0000 [thread overview]
Message-ID: <20260516123127.C4D41C19425@smtp.kernel.org> (raw)
In-Reply-To: <20260515123018.80147-5-kerneljasonxing@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] State machine logic flaw causing valid packet drop due to un-cleared drain_cont flag.
--
commit 8841b899f0208ddaf58f3df5eb5feff9db62147f
Author: Jason Xing <kerneljasonxing@gmail.com>
xsk: drain continuation descs on invalid descriptor in __xsk_generic_xmit()
This commit addresses an issue in the TX loop where an invalid descriptor
mid-packet leaves remaining continuation fragments in the ring, which
corrupts the packet stream. It introduces a drain_cont flag to drain the
remaining fragments on the next iteration.
> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index 9c51eed6ee99c..ac4884a87a0fb 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c
[ ... ]
> @@ -1125,6 +1125,8 @@ static int __xsk_generic_xmit(struct sock *sk)
> if (xs->skb)
> xsk_drop_skb(xs->skb);
> xskq_cons_release(xs->tx);
> + if (xp_mb_desc(&desc))
> + xs->drain_cont = true;
Does this logic inadvertently leave the socket stuck in the drain state?
If xs->drain_cont is already true and the current invalid descriptor is the
final fragment of the packet (meaning XDP_PKT_CONTD is not set), the flag
is not explicitly cleared since there is no else branch.
If xs->drain_cont remains true, could the next invocation of
__xsk_generic_xmit() intercept the first fragment of a completely valid,
unrelated packet in the if (unlikely(xs->drain_cont)) drain loop?
It appears the valid packet would then be drained to the completion queue
and silently dropped with -EOVERFLOW.
Would it be safer to unconditionally update the state based on the
descriptor boundary, such as:
xs->drain_cont = xp_mb_desc(&desc);
> }
>
> out:
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260515123018.80147-1-kerneljasonxing@gmail.com?part=4
next prev parent reply other threads:[~2026-05-16 12:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 12:30 [PATCH net v2 0/5] xsk: fix meta and publish of cq issues Jason Xing
2026-05-15 12:30 ` [PATCH net v2 1/5] xsk: cache csum_start/csum_offset to fix TOCTOU in xsk_skb_metadata() Jason Xing
2026-05-15 12:30 ` [PATCH net v2 2/5] xsk: fix buffer leak in xsk_drop_skb() for AF_XDP multi-buffer Tx Jason Xing
2026-05-15 12:30 ` [PATCH net v2 3/5] xsk: drain continuation descs after overflow in xsk_build_skb() Jason Xing
2026-05-16 12:31 ` sashiko-bot
2026-05-17 1:49 ` Jason Xing
2026-05-15 12:30 ` [PATCH net v2 4/5] xsk: drain continuation descs on invalid descriptor in __xsk_generic_xmit() Jason Xing
2026-05-16 12:31 ` sashiko-bot [this message]
2026-05-17 1:58 ` Jason Xing
2026-05-15 12:30 ` [PATCH net v2 5/5] selftests/xsk: fix multi-buffer invalid desc tests for drain_cont Jason Xing
2026-05-16 12:31 ` sashiko-bot
2026-05-17 2:47 ` Jason Xing
2026-05-17 6:15 ` Jason Xing
2026-05-15 16:59 ` [PATCH net v2 0/5] xsk: fix meta and publish of cq issues Maciej Fijalkowski
2026-05-17 2:09 ` 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=20260516123127.C4D41C19425@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.