From: netdev-bot+sashiko@kernel.org
To: maciej.fijalkowski@intel.com
Cc: netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com,
magnus.karlsson@intel.com, sdf@fomichev.me, ast@kernel.org,
daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com,
jtollet@cisco.com, willemb@google.com, andrii@kernel.org,
eddyz87@gmail.com, memxor@gmail.com, bpf@vger.kernel.org,
bjorn@kernel.org, kerneljasonxing@gmail.com,
marcin.knap@vecima.com, joshwash@google.com,
hramamurthy@google.com, sgoutham@marvell.com,
martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev,
jolsa@kernel.org, emil@etsalapatis.com, ihor.solodrai@linux.dev,
toke@redhat.com, hangbin.liu@linux.dev
Subject: Re: [PATCH net v6 1/2] xsk: Do not free ZC Rx buffer when the Rx ring is full
Date: Sat, 05 Dec 2026 19:42:42 +0000 [thread overview]
Message-ID: <179649976273.3148.10281043057398500708@kernel.org> (raw)
In-Reply-To: <20261204193929.1168874-2-maciej.fijalkowski@intel.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 (1) · High: 1 (1) · Medium: 0 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The patch relies on ixgbe's XDP_EXIT retry path to handle the
retained buffer correctly, but that retry reuses stale xdp_buff state.
- [Low] The commit message lists the drivers that break because
xsk_rcv_zc() freed the buffer on -ENOBUFS, and names ixgbe as the one…
Pre-existing issues:
- [Critical] In otx2_xdp_rcv_pkt_handler(), the non-XSK (page pool)
XDP_REDIRECT failure path releases the receive page and then returns…
- [High] In otx2_xdp_rcv_pkt_handler(), when pool->xsk_pool is set, the
code runs the program on xsk_buff and does `goto handle_xdp_verdict`…
--
xsk: Do not free ZC Rx buffer when the Rx ring is full
This patch stops xsk_rcv_zc() from freeing the zero-copy buffer when
the XSK Rx ring is full. The buffer now stays with the driver that
called xdp_do_redirect(). It also updates i40e, ice, gve DQO and
octeontx2, which relied on the core freeing the buffer, so that they
free it themselves.
> A failed xdp_do_redirect() leaves the buffer owned by the caller, so
> the driver releases it as well. That is harmless when the driver frees
> it right away, as i40e, ice, igc, stmmac, idpf and most others do:
> xp_free() ignores a buffer that is already on the pool free list. It
> breaks when the driver releases or uses the buffer later, after it may
> have been reallocated:
[ ... ]
> - ixgbe keeps the buffer in the ring on its need_wakeup -ENOBUFS
> (XDP_EXIT) path and runs XDP on it again on the next poll.
[Severity: Low]
Should igb be listed next to ixgbe here? igb_run_xdp_zc() returns
IGB_XDP_EXIT on -ENOBUFS when need_wakeup is enabled.
igb_clean_rx_irq_zc() then handles it the same way ixgbe does:
drivers/net/ethernet/intel/igb/igb_xsk.c:igb_clean_rx_irq_zc() {
...
} else if (xdp_res == IGB_XDP_EXIT) {
failure = true;
break;
...
}
ntc is not advanced and rx_buffer_info_zc[ntc] is not cleared, so the
same xdp_buff goes through XDP again on the next poll. Before this
patch, that buffer was already on the pool free list.
The core change in xsk_rcv_zc() fixes igb without any driver change.
The changelog doesn't say so, though, and it suggests igb is one of
"most others" that free the buffer right away. Could igb be added to
the list of affected drivers?
[ ... ]
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
> index 90af9b9044aa0..6d10c132f61cb 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
> @@ -1555,7 +1555,8 @@ static bool otx2_xdp_rcv_pkt_handler(struct otx2_nic *pfvf,
> *need_xdp_flush = true;
> return true;
> }
> - return false;
> + xsk_buff_free(xsk_buff);
> + return true;
> }
[Severity: High]
This is a pre-existing issue, but this patch is fixing the XSK verdict
handling in otx2_xdp_rcv_pkt_handler(). What happens with XDP_TX and
XDP_PASS on the XSK path?
The XSK branch jumps to the verdict without initializing the local
struct xdp_buff xdp:
if (pool->xsk_pool) {
xsk_buff = pool->xdp[--cq->rbpool->xdp_top];
...
xsk_buff->data_end = xsk_buff->data + cqe->sg.seg_size;
act = bpf_prog_run_xdp(prog, xsk_buff);
goto handle_xdp_verdict;
}
The verdict cases still use xdp, though:
case XDP_PASS:
*metasize = xdp.data - xdp.data_meta;
break;
case XDP_TX:
...
xdpf = xdp_convert_buff_to_frame(&xdp);
xdp_convert_buff_to_frame() dereferences xdp->rxq->mem.type
immediately. xdp.rxq is uninitialized stack memory, or NULL with
INIT_STACK_ALL_ZERO.
Can an XDP_TX verdict on an AF_XDP zero-copy queue oops in NAPI
context here? xsk_buff is also never converted or released on that
path.
For XDP_PASS, metasize comes from uninitialized stack memory, and the
caller passes it to skb_metadata_set().
>
> err = xdp_do_redirect(pfvf->netdev, &xdp, prog);
[Severity: Critical]
This isn't a bug introduced by this patch, but the non-XSK branch just
below seems to have the same problem the commit message describes for
octeontx2 ("returns false on a failed redirect, so the caller goes on
to build an skb from the freed buffer"):
err = xdp_do_redirect(pfvf->netdev, &xdp, prog);
if (!err) {
*need_xdp_flush = true;
return true;
}
otx2_dma_unmap_page(pfvf, iova, pfvf->rbsize,
DMA_FROM_DEVICE);
xdpf = xdp_convert_buff_to_frame(&xdp);
xdp_return_frame(xdpf);
break;
...
return false;
The page is unmapped and returned through xdp_return_frame(), and then
the function returns false. otx2_rcv_pkt_handler() treats false as
XDP_PASS:
if (pfvf->xdp_prog)
if (otx2_xdp_rcv_pkt_handler(pfvf, pfvf->xdp_prog, cqe, cq,
&metasize, need_xdp_flush))
return;
skb = napi_get_frags(napi);
...
if (otx2_skb_add_frag(pfvf, skb, *seg_addr,
seg_size[seg], parse, cq->cq_idx))
cq->pool_ptrs++;
Does this attach the already freed page to an skb and pass it to GRO?
cq->pool_ptrs also gets incremented a second time.
This looks reachable whenever __xdp_do_redirect_frame() fails, for
example when a devmap or ifindex target is down or has no
ndo_xdp_xmit.
Should this branch also return true after releasing the page? The
later patch in this series doesn't touch this driver either.
> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index 48a835e535188..933a13a19a781 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c
> @@ -224,21 +224,15 @@ static int xsk_rcv_zc(struct xdp_sock *xs, struct xdp_buff *xdp, u32 len)
> struct list_head *xskb_list;
> u32 contd = 0;
> u32 num_desc;
> - int err;
>
> - if (likely(!frags)) {
> - err = __xsk_rcv_zc(xs, xskb, len, contd);
> - if (err)
> - goto err;
> - return 0;
> - }
> + if (likely(!frags))
> + return __xsk_rcv_zc(xs, xskb, len, contd);
[Severity: High]
Now that the buffer stays with the driver, ixgbe's XDP_EXIT retry
becomes the normal path whenever the XSK Rx ring is full. Does that
retry start from a clean xdp_buff?
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c:ixgbe_clean_rx_irq_zc() {
...
bi->xdp->data_end = bi->xdp->data + size;
xsk_buff_dma_sync_for_cpu(bi->xdp);
xdp_res = ixgbe_run_xdp_zc(adapter, rx_ring, bi->xdp);
if (likely(xdp_res & (IXGBE_XDP_TX | IXGBE_XDP_REDIR))) {
xdp_xmit |= xdp_res;
} else if (xdp_res == IXGBE_XDP_EXIT) {
failure = true;
break;
...
}
On the next poll only data_end is recomputed. data and data_meta keep
whatever the previous program run left in them. igb resets them with
xsk_buff_set_size().
Suppose the program calls bpf_xdp_adjust_head() with a positive offset
N before redirecting. data then moves forward by N on every retry, and
data_end moves with it, so this check in bpf_xdp_adjust_head() keeps
passing:
if (unlikely(data < data_start ||
data > xdp->data_end - ETH_HLEN))
return -EINVAL;
After a single retry, user space would get the packet shifted by N
bytes, with N trailing bytes the hardware never wrote.
If the Rx ring stays full for enough polls, can [data, data_end) move
past the end of the UMEM chunk? The program could then read and write
the neighbouring chunk.
When the redirect finally succeeds, in aligned mode xp_get_handle()
takes the descriptor address from xskb->xdp.data - pool->addrs. That
address could then point into another chunk, so the same frame would
be handed to user space twice.
Would ixgbe need an xsk_buff_set_size() style reset before it runs XDP
again, as igb does? The later patch in this series ("xdp: Do not free
ZC buffer when a frame redirect fails") doesn't seem to touch ixgbe.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204193929.1168874-1-maciej.fijalkowski%40intel.com
next prev parent reply other threads:[~2026-12-05 19:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 19:39 [PATCH net v6 0/2] xsk, xdp: fix ZC buffer double free on failed redirect Maciej Fijalkowski
2026-12-04 19:39 ` [PATCH net v6 1/2] xsk: Do not free ZC Rx buffer when the Rx ring is full Maciej Fijalkowski
2026-12-05 19:42 ` netdev-bot+sashiko [this message]
2026-12-04 19:39 ` [PATCH net v6 2/2] xdp: Do not free ZC buffer when a frame redirect fails Maciej Fijalkowski
2026-12-05 19:42 ` netdev-bot+sashiko
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=179649976273.3148.10281043057398500708@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=hangbin.liu@linux.dev \
--cc=hawk@kernel.org \
--cc=hramamurthy@google.com \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=joshwash@google.com \
--cc=jtollet@cisco.com \
--cc=kerneljasonxing@gmail.com \
--cc=kuba@kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=marcin.knap@vecima.com \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=sgoutham@marvell.com \
--cc=song@kernel.org \
--cc=toke@redhat.com \
--cc=willemb@google.com \
--cc=yonghong.song@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