Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 0 · Low: 0 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] On the zero-copy XDP_TX paths of i40e, ixgbe and icssg, the bug this patch fixes for xdp_do_redirect() is still there: a copied frame… -- xdp: Do not free ZC buffer when a frame redirect fails This patch adds __xdp_convert_zc_to_xdp_frame(), which takes a release flag. xdp_do_redirect() now uses it so that the zero-copy buffer is freed only after the copied frame has been redirected. If the redirect fails, the copy is returned with xdp_return_frame() and the XSk buffer is left to the driver. xdp_convert_zc_to_xdp_frame() still frees on success, for the zero-copy XDP_TX users.
> diff --git a/net/core/xdp.c b/net/core/xdp.c > index 1d679e8fd6493..0466b1d62231e 100644 > --- a/net/core/xdp.c > +++ b/net/core/xdp.c
[ ... ]
> @@ -607,9 +608,23 @@ struct xdp_frame *xdp_convert_zc_to_xdp_frame(struct xdp_buff *xdp) > xdpf->frame_sz = PAGE_SIZE; > xdpf->mem_type = MEM_TYPE_PAGE_ORDER0; > > - xsk_buff_free(xdp); > + if (release) > + xsk_buff_free(xdp); > + > return xdpf; > } > + > +/** > + * xdp_convert_zc_to_xdp_frame - copy an XSk buffer into a new &xdp_frame > + * @xdp: XSk buffer to copy, freed if the copy succeeds > + * > + * Return: new %MEM_TYPE_PAGE_ORDER0 frame, or %NULL if the data does not > + * fit into a page or the allocation fails. > + */ > +struct xdp_frame *xdp_convert_zc_to_xdp_frame(struct xdp_buff *xdp) > +{ > + return __xdp_convert_zc_to_xdp_frame(xdp, true); > +}
[Severity: High] The commit message says free-on-success is kept "for the zero-copy XDP_TX paths that rely on it, such as those of i40e, mlx5e and stmmac". The zero-copy XDP_TX paths in i40e, ixgbe and icssg seem to have the same leak of the copied page, and the same second xsk_buff_free(), that this patch fixes for xdp_do_redirect(). Is that right? In i40e the conversion frees the XSk buffer right away: drivers/net/ethernet/intel/i40e/i40e_txrx.c:i40e_xmit_xdp_tx_ring() { struct xdp_frame *xdpf = xdp_convert_buff_to_frame(xdp); if (unlikely(!xdpf)) return I40E_XDP_CONSUMED; return i40e_xmit_xdp_ring(xdpf, xdp_ring); } i40e_xmit_xdp_ring() can then fail without freeing or storing xdpf. One case is a full ring, and the DMA mapping error path is another: if (unlikely(I40E_DESC_UNUSED(xdp_ring) < 1 + nr_frags)) { xdp_ring->tx_stats.tx_busy++; return I40E_XDP_CONSUMED; } i40e_run_xdp_zc() passes the CONSUMED result to out_failure. Then i40e_handle_xdp_result_zc() frees the XSk buffer a second time: if (xdp_res == I40E_XDP_CONSUMED) { xsk_buff_free(xdp_buff); return; } Would this leak the dev_alloc_page() page from __xdp_convert_zc_to_xdp_frame() for every XDP_TX packet that is dropped this way? A full XDP Tx ring is a normal runtime condition, and remote senders can cause it. ixgbe looks the same. In ixgbe_run_xdp_zc()->ixgbe_xmit_xdp_ring(), a full ring or a DMA map error returns IXGBE_XDP_CONSUMED without freeing xdpf. ixgbe_clean_rx_irq_zc() then calls xsk_buff_free(bi->xdp) again. icssg looks the same too. In emac_run_xdp()->emac_xmit_xdp_frame(), a failure to allocate a descriptor, map the buffer or push it returns ICSSG_XDP_CONSUMED. prueth_xmit_free() does not free xdpf, and emac_rx_packet_zc() then calls xsk_buff_free(xdp) again. The second free is harmless only because xp_free() ignores a buffer that is already on the free list. The commit message makes the same argument for the redirect case. mlx5e_xmit_xdp_buff() and stmmac_xdp_xmit_back() call xdp_return_frame(xdpf) on failure and skip the second XSk free. So this looks specific to these three drivers. There seem to be two ways to fix these XDP_TX paths: - convert with __xdp_convert_zc_to_xdp_frame(xdp, false) and free the XSk buffer only after a successful transmit, as xdp_do_redirect() now does - call xdp_return_frame(xdpf) when the transmit fails and skip the caller's xsk_buff_free() Should one of these be applied? Also, should the commit message and the new kernel-doc stop presenting i40e as a correct user of the free-on-success contract?
> EXPORT_SYMBOL_GPL(xdp_convert_zc_to_xdp_frame); > > /* Used by XDP_WARN macro, to avoid inlining WARN() in fast-path */
-- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40intel.com