From: sashiko-bot@kernel.org
To: "Jason Xing" <kerneljasonxing@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net v3 3/8] xsk: fix use-after-free of xs->skb in xsk_build_skb() free_err path
Date: Sat, 25 Apr 2026 04:17:25 +0000 [thread overview]
Message-ID: <20260425041726.85FB3C2BCB2@smtp.kernel.org> (raw)
In-Reply-To: <20260422033650.68457-4-kerneljasonxing@gmail.com>
Sashiko AI review found 2 potential issue(s):
- [High] Incorrect completion address reporting to user-space and leaked descriptor on `-EOVERFLOW` in multi-buffer packets.
- [High] Packet stream corruption when dropping oversized multi-buffer packets.
--
commit 38322c7d2a85e9ef029404cbf4ae750b54520d27
Author: Jason Xing <kerneljasonxing@gmail.com>
xsk: fix use-after-free of xs->skb in xsk_build_skb() free_err path
This patch fixes a use-after-free in the xsk_build_skb() error path
by ensuring that in-progress multi-buffer socket buffers are not
freed if they are still referenced by the xdp_sock.
Link: https://lore.kernel.org/all/20260415082654.21026-4-kerneljasonxing@gmail.com/
> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c
> @@ -969,7 +969,7 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
> return skb;
>
> free_err:
> - if (skb && !skb_shinfo(skb)->nr_frags)
> + if (skb && !xs->skb)
> kfree_skb(skb);
>
> if (err == -EOVERFLOW) {
I noticed a couple of pre-existing regressions in this error path.
Do the error handling paths for -EOVERFLOW leak the original descriptor
address and submit an invalid address to user-space?
When a continuation descriptor exceeds the fragment limit, the code
jumps to the free_err label before the current descriptor address is
stored in the xsk_addr array.
However, the error path still increments the descriptor count:
if (xs->skb) {
/* Drop the packet */
xsk_inc_num_desc(xs->skb);
xsk_drop_skb(xs->skb);
}
When xsk_destruct_skb() loops up to the new descriptor count, could it
read past the initialized entries, find a zero address from the earlier
kmem_cache_zalloc(), and submit address 0 to the completion queue instead
of the actual dropped address?
Does dropping the socket buffer here cause packet stream corruption?
When a multi-buffer packet is dropped due to an -EOVERFLOW error,
the partial packet is discarded and the socket buffer pointer is cleared.
Because there is no state tracking to discard the remaining descriptors
of the dropped packet, will the transmission loop process the next
descriptor (which is just a continuation of the dropped packet) as the
beginning of a completely new packet?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260422033650.68457-1-kerneljasonxing@gmail.com?part=3
next prev parent reply other threads:[~2026-04-25 4:17 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-22 3:36 [PATCH net v3 0/8] xsk: fix bugs around xsk skb allocation Jason Xing
2026-04-22 3:36 ` [PATCH net v3 1/8] xsk: reject sw-csum UMEM binding to IFF_TX_SKB_NO_LINEAR devices Jason Xing
2026-04-22 3:36 ` [PATCH net v3 2/8] xsk: handle NULL dereference of the skb without frags issue Jason Xing
2026-04-22 3:36 ` [PATCH net v3 3/8] xsk: fix use-after-free of xs->skb in xsk_build_skb() free_err path Jason Xing
2026-04-22 16:31 ` Stanislav Fomichev
2026-04-25 4:17 ` sashiko-bot [this message]
2026-04-27 2:34 ` Jason Xing
2026-04-22 3:36 ` [PATCH net v3 4/8] xsk: prevent CQ desync when freeing half-built skbs in xsk_build_skb() Jason Xing
2026-04-22 16:31 ` Stanislav Fomichev
2026-04-22 3:36 ` [PATCH net v3 5/8] xsk: avoid skb leak in XDP_TX_METADATA case Jason Xing
2026-04-22 16:31 ` Stanislav Fomichev
2026-04-22 3:36 ` [PATCH net v3 6/8] xsk: free the skb when hitting the upper bound MAX_SKB_FRAGS Jason Xing
2026-04-22 16:31 ` Stanislav Fomichev
2026-04-22 3:36 ` [PATCH net v3 7/8] xsk: fix xsk_addrs slab leak on multi-buffer error path Jason Xing
2026-04-22 3:36 ` [PATCH net v3 8/8] xsk: don't support AF_XDP on 32-bit architectures Jason Xing
2026-04-22 16:09 ` Alexander Lobakin
2026-04-22 16:37 ` Jason Xing
2026-04-22 16:58 ` Maciej Fijalkowski
2026-04-22 23:49 ` Jason Xing
2026-04-23 12:14 ` Alexander Lobakin
2026-04-23 13:03 ` Jason Xing
2026-04-22 17:00 ` Alexander Lobakin
2026-04-22 16:31 ` Stanislav Fomichev
2026-04-22 20:27 ` David Laight
2026-04-22 23:45 ` 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=20260425041726.85FB3C2BCB2@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=kerneljasonxing@gmail.com \
--cc=sashiko@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox