Article View: linux.kernel.netdev
Article #24608[PATCH net v2 0/4] xsk: Keep the shared info of zero-copy buffers in kernel memory
From: Björn Töpel
Date: Mon, 30 Nov 2026 12:37
Date: Mon, 30 Nov 2026 12:37
83 lines
11942 bytes
11942 bytes
A packet that AF_XDP receives in zero-copy mode over several buffers
keeps its shared info, the fragment list and its count, in the UMEM,
which userspace can write while the kernel uses it. A rewritten list
or count makes the kernel read and write out of bounds.
Patch 4 moves the shared info into the buffer pool and lets the device
write up to the end of each chunk. Patch 1 makes libeth count XSk
XDP_TX buffers one by one, as it read the shared info at a later bulk
flush. Patches 2 and 3 fix skb builders that relied on the old
tailroom: the generic one sized the skb head from the frame size, and
i40e, igb, igc and ixgbe read past the data.
Sashiko found the shared info issue in its review of the AF_XDP device
buffer layout series [1], and the issues fixed by patches 2 and 3 in
its review of v1. Clément reported the issue of patch 2 earlier [2].
Patch 3 was reproduced on igb in QEMU; the others were not triggered
at runtime.
I tested this on mlx5 hardware, and on igb, virtio-net and veth in
QEMU. None of them receives multi-buffer packets in zero copy or uses
the generic skb builder, so i40e, ice, idpf and gve are only
build-tested. Intel folks, could you run your multi-buffer zero-copy
tests on them?
Also for Intel, found while auditing the drivers and not touched here:
ice no longer sizes its zero-copy RX buffers from the XSK pool. Commit
3a4f419f7509 ("ice: drop page splitting and recycling") programmed a
fixed 3072 bytes, and 93f53db9f9dc ("ice: switch to Page Pool")
changed ice_setup_rx_ctx() to use ring->rx_buf_len, which only the
page pool path sets. An XSK ring gets the length of its last page pool
setup, 3456 bytes on 4K pages, or 0 if it never had one. With 2K
chunks the device can write past the chunk into the next one. I found
this by reading the code and did not test it.
Changes in v2:
- Patch 1: fix the kernel-doc of struct libeth_sqe (Sashiko)
- New patch 2: size zero-copy skbs from the data, and copy the exact
length (Sashiko, Clément)
- New patch 3: copy the exact length in i40e, igb, igc and ixgbe
(Sashiko)
- Patch 4: set the flag on every buffer when the pool is created, and
again in xp_alloc() and xsk_buff_set_size(), as virtio_net clears
the flags of some buffers (Sashiko)
- Patch 4: publish the shared info before the buffers point to the
queue (Sashiko)
- Patch 4: update the comment in bpf_xdp_adjust_tail() (Sashiko)
- Drop the selftest patch, it goes to net-next once net is merged
(Maciej)
- The libeth XDP_TX completion count that Sashiko found going the
wrong way is older and unrelated to the shared info; Separate fix
v1: https://lore.kernel.org/netdev/20261127142131.3527737-1-bjorn@kernel.org/
[1] https://lore.kernel.org/netdev/179561567996.3135.9952128421877275714@kernel.org/
[2] https://lore.kernel.org/bpf/20260629072300.1664622-1-clecigne@google.com/
Björn Töpel (4):
libeth: xsk: Count each XDP_TX buffer on its own
xdp: Size zero-copy skbs from the data, not the frame size
intel: Copy the exact length of XSk packets to skbs
xsk: Keep the shared info of zero-copy buffers in kernel memory
drivers/net/ethernet/intel/i40e/i40e_xsk.c | 3 +-
drivers/net/ethernet/intel/igb/igb_xsk.c | 3 +-
drivers/net/ethernet/intel/igc/igc_main.c | 3 +-
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 3 +-
include/net/libeth/tx.h | 8 ++--
include/net/libeth/xdp.h | 9 ++++-
include/net/libeth/xsk.h | 6 ++-
include/net/xdp.h | 32 +++++++++++++---
include/net/xdp_sock_drv.h | 26 +++----------
include/net/xsk_buff_pool.h | 1 +
net/core/filter.c | 2 +-
net/core/xdp.c | 40 ++++++++++++++------
net/xdp/xdp_umem.c | 3 +-
net/xdp/xsk_buff_pool.c | 20 ++++++----
14 files changed, 96 insertions(+), 63 deletions(-)
base-commit: e2fb9368a41662bc54624f9be87ea8989b109306
--
2.56.1
Technical Details
Message-ID:
<20261130123737.125432-1-bjorn@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374170-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374170-linux-kernel-netdev=dewy.ru From: bjorn@kernel.org (Björn Töpel) Newsgroups: linux.kernel.netdev Subject: [PATCH net v2 0/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Date: Mon, 30 Nov 2026 13:37:31 +0100 Organization: Usenet Network Message-ID: <20261130123737.125432-1-bjorn@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1424764"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:3hXQDqokXez/8BKipyFaqFNwDto= sha256:GdInueUmGxfzbdzLvlUa09oO+ctfB0z89iBSKoKveWk= sha1:eosrKqn+GiYQs+nb4gCudvYRvkQ= sha256:Vq8bwuQ+R1+Nf2NtJ5Dw4DxCq7r1ctZLVMib7ok75ds= 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 D0233125FE3; Mon, 30 Nov 2026 15:38:01 +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 WYG5oj1-y55o; Mon, 30 Nov 2026 15:37:58 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374170-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 A84AF125FE1; Mon, 30 Nov 2026 15:37:49 +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 137C92CDFD; Mon, 30 Nov 2026 12:37: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=1796042267; b=s+7WbKIrgdvFaU1jRVmDjrAM2rwfldcvD9q6i2fxFu4LdCdiN8v9WxFZQz74jP1ydXts 4OuWXFshl7TmZrfnz+Gu2s6w9fY2tG8LC2aUpmI9WhUngrTRqj3k2wCpskYzwUQ2U9pW6 BEWKTMRqH9g6oO6TgUNnvKMlI3CcS3H2sNOfJTViK2Z5pyc1zc4/0I7APNyMQ69IMwKBy WHaMKHYUt0B3J8QKMRVEyrLGpZqMBkUKRdEjLOQdslw0rSivcdqbBBVROvWBfaDJY3rfm /BMrU1ULRNHE2FmWgiLDj49yPfQQIbevacQyIrFVdXWjsZNuRRSac5S4cbHSAkq7HOw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796042267; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Type:Content-Transfer-Encoding; bh=CsyZkGScgsCyjR1qttJlr6HlghTp3a3IoGwpVY/6tM8=; b=LF94eNwnx3yR2d2Ep0hB02krbXfOPmGUKV6wwGbOwFfj0R/Ia7VTHXyYUCwZkIUaVwY4 59FDWGk1g91SStVdJUKqdXaSryrpn3WY07FsVO5M8i0nyebTtVw4RgFFgW2S26f1pYVqU 5HJkvHMWe0xyG43fswVZf3KhULq6E5L5lGeR8xgQwnvgEcdpFkL793j7O+jiCpBleThOI jhQyScKoYZDjY5WnQMkXCpq/IKpRj1KE87i79HzeAqKWFwyzPHNZl5NSd9wsDnJmSmoMN rmnhkCHHYnNafj4pdmsDGtoVGJJFkD8CGyFjiyGuYLfAfulBRO7+/VEufa30fc96Ojw== 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=Ju0fELF8; 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 548D2606A32E; Mon, 30 Nov 2026 12:37:47 +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=Ju0fELF8 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=1796042266; b=Nd8vqOp2NpwvgWPBN0dBHDw54eXN8bCEMWRX0ntoeD1ObQ9suUObmZtvSZr42Puz64uL 7gqIpQcE5leLls8Jp15m3p6TJP6idwB2DiM4v3Leg7U1n0QYFnUCcDDa+d8L1Ret7Kgjv 61x6KDobkEziLYo9RFJc1rtO2QXygMl/gB9hleDfsT5KIxXs18fqMtrwQ8lyribkOS+aR fvu8OUDHMsBnCMMEyla67zNmScKjpVUu2lJsQ2tlvBxinVS18Pg27+PK7kna4h8vDrHAO slBr4sefy9fN+rTJ5R9f9yib8spBw1gtAeuquPkvg3Tg62/Iu2SnU/zQENYv2aJBSxA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796042266; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=CsyZkGScgsCyjR1qttJlr6HlghTp3a3IoGwpVY/6tM8=; b=ZL1SCDDBtTK+U9kFrqu07BDHzmPAPRh7xa5pMXAmGlZNEs0CvzWYfmYoRrxHM4hH2r9U 8og5PbzsCg4Y5wCrX1vd2mTYV3zQWEL+iEqvO/o74QY8k2Nydgb2lHjvVK1/dzgTTmZ+W tYKxp7YHyVKzndrW973GCYDPqBU+njWklzad/Nr+13/jkW74UMjc7UMUWHrdmhRR/9Axh C8BySGXbUCB5lWctAZ1HpkWLZwulZ3gGUTGUmeBXVtCOadK89ucZM9InjeBjm0v3ZCT65 Xt/41OAb9/THkLuyT+Ru/O8XPXS5YroaHRAprX+y/+FR3ecOiXMcCNn0q6gs0eZGbvw== 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=Ju0fELF8; 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 6EE11606A31C; Mon, 30 Nov 2026 12:37:46 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53FE11F00897; Mon, 30 Nov 2026 12:37:40 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796042266; bh=CsyZkGScgsCyjR1qttJlr6HlghTp3a3IoGwpVY/6tM8=; h=From:To:Cc:Subject:Date; b=Ju0fELF8qI+9s6zHpN9lZDTOWcb8nKg7Ht3iP/UdmnOnTOQdi5wVlx19oqwC1761u HabDg13fGg1AA79Wr0iIR/Hr3KTmALR5Qd3GaHsCWpWMdIrXYNt8XuXLSNcLTrb6XB rjmdLBOOxGb40GyggOdxtOmb+Ga8FoXSUknuvnbYI0S181uq/vs40lxtx0OK7edJle iTMzNn5AU9BswbjB/znz1jmsUvdar6BddsUkd+fhHNNZa0r4Bdh2nLUSR7ES41l15Z dj05LqAIkEjQ4h/1rZ6pMv8TLP91RHCOjcN7SOV80ixzf54zaafSBh2QJNqDbKrZsu 9k0vbVytErr3g== X-Cc: Björn Töpel <bjorn@kernel.org>, Simon Horman <horms@kernel.org>, Stanislav Fomichev <sdf@fomichev.me>, Martin KaFai Lau <martin.lau@linux.dev>, Song Liu <song@kernel.org>, Yonghong Song <yonghong.song@linux.dev>, Jiri Olsa <jolsa@kernel.org>, Emil Tsalapatis <emil@etsalapatis.com>, Ihor Solodrai <ihor.solodrai@linux.dev>, Tony Nguyen <anthony.l.nguyen@intel.com>, Przemek Kitszel <przemyslaw.kitszel@intel.com>, intel-wired-lan@lists.osuosl.org, Clément Lecigne <clecigne@google.com> X-Mailer: git-send-email 2.56.1 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