From: sashiko-bot@kernel.org
To: "Jiayuan Chen" <jiayuan.chen@linux.dev>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf v3 1/2] bpf, veth: xdp: fix page_pool page leak on skb-backed XDP
Date: Fri, 11 Sep 2026 14:36:42 +0000 [thread overview]
Message-ID: <20260911143643.402B51F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260911135711.109338-2-jiayuan.chen@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] veth_xdp_rcv_one() overwrites shared per-queue rq->xdp_rxq.mem.type state, corrupting subsequent SKB processing in the same NAPI poll and causing kernel panics.
--
commit 6d121019cfea2f329267400ac7c2525a49f34f53
Author: Jiayuan Chen <jiayuan.chen@linux.dev>
bpf, veth: xdp: fix page_pool page leak on skb-backed XDP
bpf_xdp_shrink_data() frees a released frag via __xdp_return() using
xdp->rxq->mem.type, but that type is wrong for skb-backed XDP: the skb is
cow'd into page_pool memory while the rxq still says MEM_TYPE_PAGE_SHARED.
This fixes the resulting page pool panics by recording the memory type in
the xdp_buff flags instead.
> diff --git a/drivers/net/veth.c b/drivers/net/veth.c
> index 6ed3ee81153fb..a3fdf1959b76c 100644
> --- a/drivers/net/veth.c
> +++ b/drivers/net/veth.c
> @@ -775,6 +775,12 @@ static int veth_convert_skb_to_xdp_buff(struct veth_rq *rq,
> if (skb_shinfo(skb)->nr_frags) {
> skb_shinfo(skb)->xdp_frags_size = skb->data_len;
> xdp_buff_set_frags_flag(xdp);
> + /*
> + * A nonlinear skb was cow'd into rq->page_pool above, so the
> + * frags must be freed to that pool, not via the rxq's
> + * MEM_TYPE_PAGE_SHARED.
> + */
> + xdp_buff_set_frag_pp(xdp);
> } else {
> xdp_buff_clear_frags_flag(xdp);
> }
[Severity: High]
This isn't a bug introduced by this patch, but can the shared per-queue memory
type state be clobbered during a mixed batch?
In veth_xdp_rcv_one(), the shared rq->xdp_rxq.mem.type state is overwritten
with the incoming frame's type without being restored:
veth_xdp_rcv_one() {
...
case XDP_REDIRECT:
orig_frame = *frame;
xdp->rxq->mem.type = frame->mem_type;
...
}
If a single NAPI poll (veth_xdp_rcv) processes a batch containing a native
xdp_frame (e.g. MEM_TYPE_XSK_BUFF_POOL) followed by a standard sk_buff, the
next packet will be processed with the clobbered rxq->mem.type.
When veth_xdp_rcv_skb() processes the subsequent sk_buff, the BPF program
is executed with this clobbered state:
veth_xdp_rcv_skb() {
...
act = bpf_prog_run_xdp(xdp_prog, xdp);
...
}
If this clobbered memory type is read by helpers like bpf_xdp_shrink_data(),
could it lead to a kernel panic? For instance, if clobbered to XSK_BUFF_POOL,
it would erroneously call xsk_buff_free() on a standard xdp_buff, resulting
in a garbage dereference.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260911135711.109338-1-jiayuan.chen@linux.dev?part=1
next prev parent reply other threads:[~2026-09-11 14:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 13:56 [PATCH bpf v3 0/2] net: xdp: fix bpf_xdp_shrink_data() page handling on generic XDP and veth Jiayuan Chen
2026-09-11 13:56 ` [PATCH bpf v3 1/2] bpf, veth: xdp: fix page_pool page leak on skb-backed XDP Jiayuan Chen
2026-09-11 14:36 ` sashiko-bot [this message]
2026-09-12 2:28 ` Jiayuan Chen
2026-09-13 13:05 ` Lorenzo Bianconi
2026-09-14 8:46 ` Jiayuan Chen
2026-09-11 13:56 ` [PATCH bpf v3 2/2] selftests/bpf: add xdp_shrink_frags Jiayuan Chen
2026-09-11 14:46 ` sashiko-bot
2026-09-12 2:34 ` Jiayuan Chen
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=20260911143643.402B51F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=jiayuan.chen@linux.dev \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).