Article View: linux.kernel.netdev
Article #8832Re: [PATCH bpf v2] xsk: Do not free ZC Rx buffer when the Rx ring is full
From: bot+bpf-ci
Date: Fri, 30 Oct 2026 08:47
Date: Fri, 30 Oct 2026 08:47
90 lines
12006 bytes
12006 bytes
--===============2292663351581088568==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
> xsk: Do not free ZC Rx buffer when the Rx ring is full
TL;DR: Commit message only: the code change looks correct, but the "freed
twice" claim seems inaccurate for drivers that free immediately (i40e, ice,
etc.); only deferred-release drivers like mlx5e are affected.
> xsk: Do not free ZC Rx buffer when the Rx ring is full
>
> When an XDP program redirects a zero-copy buffer to an XSK and the
> socket's Rx ring is full, xsk_rcv_zc() frees the buffer and returns
> -ENOBUFS to xdp_do_redirect().
>
> A failed xdp_do_redirect() leaves the buffer owned by the caller, and
> most drivers rely on that: mlx5e treats the failure as XDP_DROP and
> releases the buffer when the Rx WQE is refilled, while i40e, ice,
> ixgbe, igb, igc, stmmac, idpf and others free it themselves. The
> buffer is therefore freed twice. It gets reused for another Rx
> descriptor, the second free puts an in-use buffer back on the pool
> free list, and the same UMEM frame is later handed to user space
> twice. ixgbe and igb keep the buffer in the ring on their need_wakeup
> -ENOBUFS (XDP_EXIT) path and run it through XDP again on the next poll,
> after the core has freed it.
>
> Leave the buffer with the caller on both the single-buffer and the
> multi-buffer -ENOBUFS paths, as xsk_rcv() and xsk_rcv_check() already
> do. A few drivers relied on the core freeing the buffer, so make them
> free it:
>
> - i40e and ice consume the descriptor on XDP_EXIT without freeing it.
> - gve DQO counts the redirect error without freeing the buffer.
> - octeontx2 returns false on a failed redirect, so the caller goes on
> to build an skb from the already freed buffer. Free the buffer and
> report it as consumed instead.
>
> Seen on Mellanox ConnectX-6 DX MT2892 (FW 22.47.1026) with AF_XDP
> zero-copy on 7.3.0-rc6 when the user-space consumer could not keep up
> with the Rx ring. With this change no duplicate frames were seen with
> striding RQ on or off.
>
> Fixes: 269009893146 ("xsk: recycle buffer in case Rx queue was full")
> Signed-off-by: Marcin Knap <marcin.knap@vecima.com>
The changelog says that for i40e, ice, ixgbe, igb, igc, stmmac, idpf and the
others the buffer is "freed twice" and that "the second free puts an in-use
buffer back on the pool free list". Is this accurate for those drivers?
All of them call xsk_buff_free() on the redirect failure path straight after
xdp_do_redirect() returns, before any xp_alloc() can run. xp_free() starts
with:
void xp_free(struct xdp_buff_xsk *xskb)
{
if (!list_empty(&xskb->list_node))
return;
...
and the xsk_buff_free() from the old xsk_rcv_zc() err label has already put
list_node on pool->free_list. So wouldn't the second free simply return
early here?
For a multi-buffer frame, xskb_list is already emptied by then, and the head
hits the same early return.
The corruption described seems to happen only where the second release comes
later, after the buffer may have been reallocated:
- mlx5e releases the buffer on WQE refill.
- ixgbe and igb keep the buffer in the ring on XDP_EXIT and run XDP on it
again.
- dpaa2 calls dpaa2_eth_recycle_buf(), which hands the address back to the
hardware pool while the buffer is also on free_list.
- octeontx2 builds an skb from the freed buffer.
The code change itself looks correct. Could the changelog be reworded to
name the drivers with a deferred second release, or the reuse after free, as
the ones affected, instead of the drivers that free the buffer immediately?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/41025962641
--===============2292663351581088568==--
Technical Details
Message-ID:
<36d13f061c48206a13e7a38cb846f4c71e0a15fcf0459ab56a2b01f67a57172e@mail.kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353669-linux-kernel-netdev=dewy.ruReferences:
<20261030-xsk-zc-rx-double-free-v2-1-cf01d4a9f3f7@vecima.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353669-linux-kernel-netdev=dewy.ru From: bot+bpf-ci@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH bpf v2] xsk: Do not free ZC Rx buffer when the Rx ring is full Date: Fri, 30 Oct 2026 08:47:51 +0000 (UTC) Organization: Usenet Network Message-ID: <36d13f061c48206a13e7a38cb846f4c71e0a15fcf0459ab56a2b01f67a57172e@mail.kernel.org> References: <20261030-xsk-zc-rx-double-free-v2-1-cf01d4a9f3f7@vecima.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2292663351581088568==" Injection-Info: usenet.network; logging-data="2194873"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:OgX+ceeyK8CJewdWYaWT58jkIy0= sha256:GEDORROrSCmPndqwvy+5PJ9hlFz/T45aUVY58YksCu8= sha1:rhTremvx/HkdVWk0zJq8yeiL7Qw= sha256:moL1D3U96afqU0FLAYedkVu5h/COsLRHwdC+miOYcGE= 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 7CAE5125C8B; Fri, 30 Oct 2026 11:53:52 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, 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] 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 sQ4Zyt8qCrMZ; Fri, 30 Oct 2026 11:53:49 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-353669-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id F1B3D125C86; Fri, 30 Oct 2026 11:53:38 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id C2BC82EFAE; Fri, 30 Oct 2026 08:47:58 +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=1793350078; b=y7s/iEGzTeuvxug+/pReYDuHNQA3+RyPVi7zMpDWh2YJrdbvhsveSjSRxxGl/T4MxuMH Pb4aHsdSw1W5jdT2IDsgEgAdg+flEOGwfVR6cHOmuP8aJsaDpI4eVoRfOMaJq3oW+9QvX uox3QJ8oRQYvdho/1NvoZBOVOB6vXdGMiDGXbpiSRgnFxwa8OdPuFU3KWANwW5lUggHYR I8v46HOBDxzkJrBB4mH3m3NLa1VdsWo4uu07LahOqndfi1vWyty0Uk4S93HOkFiXYAXE0 y6Ptd8A2BVyUSV4b8rW7rOgl7LqzGLCB5XtZTB8VGS6Rn5tqMs9M1GPb98YCc3+Kknw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793350078; h=X-Original-To:Received:Received:DKIM-Signature:Content-Type: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Message-Id: In-Reply-To:References:Subject:From:To:Cc:Date; bh=KrD/LT25yUr4hzgtq3ozTYQoswHyYhMKqnTj9MrA7yQ=; b=WeTFULNLlhWa8vHH/2VeguFYLxGBOf4Pd7XAyaJZ2IE2Ut88o+ZBPeWgJs3Hv9ptmo0U pPi1gLFeYdnYIsLzsrMxKXKHhdV26zh6rUJBnNJoVHGC9EBoZnChscFFqfPq8MJG+T8kz 5WlozG/Do5a79VVsjlx+bUTAn2EMnUgNK8xpcoiwFokprpdDiK9kHb9e/FEOpWiTUp2UZ n9U+qk8JG8iLyd9UUyW2wFvrusx2bxJSA6dhuTJc066YJlxHON/3Et6x0FM5y9LHuHyLf OHCIB8Rl9MfjuZ6jnF1kXuDEUptHS5cGNg+2wd9kwWPvrqRVbOdykag92QGnnuVb8Pg== 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="QjMA/2B8"; 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 997F8606A329; Fri, 30 Oct 2026 08:47:58 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QjMA/2B8 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=1793350072; b=PYkFmNNO9n4tb9UiXLPaXwsqa4uyuyBauVZchwFDJWDKJA9AcrkMzpQZxTrcOvjc+gdR SIojEN4UJas2RlvHcGZP6bcBHkQNdnajzWai9FLXkAw1IWlci70QzWiITco+2ytlrLgK8 PtCtpjnjezaxc5ITRrnRg8Rn52Pww/+nHXpn2+xRpqvoOA+1qvyWeTybYjunz0ghFjYww iaIQFlzxZnfFjmU2VFgfapQAxrBp+4jPAPw8sF1ltaxGbsmk0mpKgqltwZKMWhv06DiNn lB7sZjHcukpuyGzPm87tY7lyaSW21nRL35q8esCHg1/5W057cBSBhrI72WTL57mcbxQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793350072; h=Received:DKIM-Signature:Content-Type:MIME-Version:Message-Id: In-Reply-To:References:Subject:From:To:Cc:Date; bh=KrD/LT25yUr4hzgtq3ozTYQoswHyYhMKqnTj9MrA7yQ=; b=vJ6YZ8Zvy8b1RMdWaKBPNHyWXfvy5VFwKves5bdQtjTb4q8xZIJL6YCDFa3vkJo8rFQ4 YjgoF/44qF0L9ikDelnW0x25vOD8Z0mSWc0eeVpdNxU2C4XTu+ogSp0rHSXX+p62PPYH/ ovjyf2n8/ytT/Q+B/3OP/44ZQn7giMSCFiQKXMUOAHW4HtTcx34RzfnEY28aUQc4pWila pZfpV3evkZVkXQKyUiJ0A6ajjgEkYUTluQH00QdiNT1Cg2BW+tJvnjpA8fD7NrH5dFB+A HpN5jQm8NPPyuNkGOnjVU2zDfde95ckM9Kr+5BoOx9YX8N/tCggimT39ImRrdhz/i6g== 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="QjMA/2B8"; 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 6E1AE606A31C; Fri, 30 Oct 2026 08:47:52 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C8B01F000C1; Fri, 30 Oct 2026 08:47:51 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793350072; bh=KrD/LT25yUr4hzgtq3ozTYQoswHyYhMKqnTj9MrA7yQ=; h=In-Reply-To:References:Subject:From:To:Cc:Date; b=QjMA/2B8CZscQfaFu/WT/U6Y2M4NWtO4+THO4uTPFwCSiZ1smfQcK0uUxM4zrg9Vb LqswBte6CIMZ2ITHE67rlkTTB33tqXHR1JIa9KsVGLgxQd5EFYsQMyX+iFqGQLT/qe /giQal94WXwHFMPz28VqsVj/Bu1RG8X0FwmqEsYZe1h5Cb93gu9P5KmZ5B79A4FimV 24IF9UBSwNFykEF1OSWahsjUocfMdi/tzsrj8DxUgIkVritNttSW5oBlqb5X7q5UK2 doJVCkexnpQ/EQ4EJKCTaBSj/5CVv6fbThRkmpbjyUrY7X85S/84vYPTxrOtk4Y1F5 9L1CdTdw7Oh6g== 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 X-In-Reply-To: <20261030-xsk-zc-rx-double-free-v2-1-cf01d4a9f3f7@vecima.com> X-Cc: intel-wired-lan@lists.osuosl.org,netdev@vger.kernel.org,linux-kernel@vger.kernel.org,bpf@vger.kernel.org,marcin.knap@vecima.com,joshwash@google.com,hramamurthy@google.com,sgoutham@marvell.com,gakula@marvell.com,rkannoth@marvell.com,sbhatta@marvell.com,bbhushan2@marvell.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev