Article View: linux.kernel.netdev
Article #27490Re: [PATCH net v6 2/2] xdp: Do not free ZC buffer when a frame redirect fails
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 19:42
Date: Sat, 05 Dec 2026 19:42
131 lines
13064 bytes
13064 bytes
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/20261204193929.1168874-1-maciej.fijalkowski%40intel.com
Technical Details
Message-ID:
<179649976493.3148.10047606663691842433@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378115-linux-kernel-netdev=dewy.ruReferences:
<20261204193929.1168874-3-maciej.fijalkowski@intel.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378115-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v6 2/2] xdp: Do not free ZC buffer when a frame redirect fails Date: Sat, 05 Dec 2026 19:42:44 +0000 Organization: Usenet Network Message-ID: <179649976493.3148.10047606663691842433@kernel.org> References: <20261204193929.1168874-3-maciej.fijalkowski@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3107366"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:NSiNo1AjKDYb2bkE9habm92W/wM= sha256:YvFEJcK8sQDSC4aS6V7MJy3dK5j0QzIYiMvSz7JDNbE= sha1:kgn+7t9kZKKCDBSH0ndlKcXVNz4= sha256:GZ1qZssvHucj4Xc1F1Wd9PGVtP0BsERLf/XtOFsQb/0= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id E865C117E82; Sat, 5 Dec 2026 22:43:02 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.639 X-Spam-Status: No, score=-3.639 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.14, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1wOvghkiaC9k; Sat, 5 Dec 2026 22:43:00 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-378115-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id C3458117E9C; Sat, 5 Dec 2026 22:42:50 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id D50F528A41; Sat, 5 Dec 2026 19:42:48 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796499768; b=erVdpQReer0nT0ndSYETuvOKtRzffoxSzbScgEjTUPgC08xE5rnKgVACGWjk2tRcpU6Z W264O0t+TJ/iJmDLwoFZwrURSd5In1mVg/o2Mg9RIO78SLs173QAm8anpq7bMWfsSpGGk I2UlAP8m2wI4SBaEYXCuNo95zRiWs3lwCUV3ge/ys4js+guNgtWCUAlod5ll9GpQlZI0A Kjk1KGP4V7y2Zb4Ldn6b7H9LBktlWcYAlBhliyghc+sj7rq1bN45Vh2lXW4e1izfxPwNO ZBs+/IuyN/q5zW94h9ZuZBqDt8AUnDjYtC3zAyqA+NoETiy48g3X0TRza+kg/y10Jew== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796499768; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=LgZ+H34lopVEhT/vo4SXudVCuCaJSMjgFSUmPAgLb/8=; b=DlIqddoMjZ6Eo+OpdcLBo8qOaGrzpL8BP17KIKebu0AjwGpoeX+UPerV3r7P+RBQ/kWl vltzMcM2LyfNuRoR+4mqOt5BAtyUcmpdvO9bzhjGouB1a8JwStVsHGZ/6BxJVz5QWmqT3 WmeGJJ0KKqhYL3696s8M+htNPAT6bTsn5QXj9r6Ztp2v0PWk+B7LsW6HP9MexISqNK1Rp hsjK++Lf4h0ZOxVBrKRXh6+Q8nJYqoHqS4Qle9CFzJVYvI/rBFimV6Zk+MLwv4yQvSi1I ZrTu2ZEO6SMR9H2P0kf1IWetL2zL0wK3ZqggwURSClni5YijwNznbjGRZaxpcXr0Oew== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=W8aEJjpg; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 424D0606A33A; Sat, 5 Dec 2026 19:42:48 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=W8aEJjpg X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796499767; b=d/77OsUl+4YuFC8sObOeCYx5/62QHciphj3PmrioI72iRrn7P8zbUb0wQLRHBsfrg/Y9 Imnt0ov6i6EbxyXcTbUS2fA5dLeznMY5ErmPHwrEqJ0NNIgxfbZYtKqq8OHjWrfHtlHJe UGcyUxAeqbawg4tiCNm4LhbySV5GhvwzKcDDy1RI1gVXLgDdKJ+HyRpj9q/f7TaHbzSwS jJrAUDu+ancsKnGt+jO12aEbv/PvB1dYecPpghoTSb0M5KOZPml1+Vq+sWhV9IAPeUgb/ 719LJLsSjO4slga7teTPpWyBTfAlNdigEiR39DcsWrn1J3FPYzWAKLKE861yPSaGxNg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796499767; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=LgZ+H34lopVEhT/vo4SXudVCuCaJSMjgFSUmPAgLb/8=; b=geytFKiSG+P6rOylvhrDiJ+kBhiCguOcCYG4aOjk60EleQOJOZUmb/6/UVoojgYz65iZ G7PQnvz9pXxr3pQvPKDBZc/fKV+Uen5iXOOpfpLamdr1oZfyVl2kGoMTVITSPOXteunLZ 3gmpI6gWcwRPpn2pH4gd1ONJSMtTWjI0SfNBtqj+F+lNJdEtf6iaTsSpLutGI7RrRiuLP 9/kSN0b28QJNUpHy35B03HMygExqQfDpzlHyZjnjr7DPpQ4+cLONZqsat1DWanc1JPov0 /7rOzGo+EKupGJnfIC+sU4fyYQ1Y/aokvszZhhOlvirM4uYBcrU/S7YRNop8vS9Obyg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=W8aEJjpg; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D2A2606A330; Sat, 5 Dec 2026 19:42:47 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F3D51F0092B; Sat, 5 Dec 2026 19:42:45 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796499767; bh=LgZ+H34lopVEhT/vo4SXudVCuCaJSMjgFSUmPAgLb/8=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=W8aEJjpgLpqyPI7qhe36b4RXHJpI8IBhtD54ZEdR32dQYArFYMnGpmUVmb/47Ktmy YBXq/1OeFADtJe1/0/0qCzcaA676pkqAOrwG3a7wKxmwz1+Dqz/FUD6m8N70mi42EK L2De7YL/AgYU/ryXyHHbW47SpztnPJedHe0Tam+AQnUzY86SOP1D2lZm8Ll53Hd6nT PHwgcD2xIQnX1uKd7drO42fWU5FcH5t9SGs0anxa2xE1+i/flisCyZUbAsrYYE2t1B FyZN56lWk5Rm1BZChadrYSTJIYq06c57Y3BZNwjVPSqwVln9XlEOJ1sFZmhclR3ZYU lt047jo0SMCdw== X-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 X-In-Reply-To: <20261204193929.1168874-3-maciej.fijalkowski@intel.com> X-sashiko-severity: High X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list