From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796394045; b=gHrh0TEs9n24yidu2Fnw/kQGzu9eu2xr9l5nkqxrlh87yWhbaha3HNoiXZLgZPJ3LSHr TIkwfGxAw4JEEdIjaM0iTOeEwzzfOyNj5eCFSOmiup2pDYm0xx8KZocLPr2hYWd9ZI4eg RiT2u09FSIVrwdWnRzhn1f3wJzoPoJO4uu3gW/edUdd3/M8mfAPgfNxfLNWmtLRIX3pcL K2XaGCUrH5xIOTL4s/Ei6T3UzPm3Nly9ptMS2sQ0TIKBaGflMQ6hBpQFTpUvL78sW2yDv RIqlHP7Ra62umJXHe0HxjHYMAAZAkZXZIXAKJahQ+m+JpF5ZP69G+u50CE7RBwD3dMg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796394045; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=TkWbHiQGmULa41vijPyVnPZkiPR1odfzT0jFKEEkTz4=; b=VH/EGkHTkypChtEES23HATFvF0jQ9cdr8f86XQr/fqxrbz7mI+XL5iBvUheu1vnnd5cu VysV786rwv+kUu+C1gGnC1jDdHoMpzKdfyShOyhCy6gVZg4PSY4jREveoBbDU/T9U48KG AtNoV9IVKTndZm9erxAx7W/ri0T6Few2HeJZcZVPI+SzFjPzYVXxA4yNL1+kxwAHe1D3b G8aT5D668WtbtHLmYKU5hZ5HQoG1bZrmyp+lVI3S0I/RjdHuXubPh30WEKB4x6ISmxgAe HfpdOehfdrP0MFEsmS/sL8bx/bd8TG5NLNIHRycf9nhlqZ/SXhVrmJa2whvOuKnOnOQ== 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=AyWMg9uX; arc=none smtp.remote-ip=100.103.45.18 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 3253A606A322; Fri, 4 Dec 2026 14:20:44 +0000 (UTC) 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=AyWMg9uX Received: by smtp.kernel.org (Postfix) with ESMTPSA id 305241F000C2; Fri, 4 Dec 2026 14:20:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796394044; bh=TkWbHiQGmULa41vijPyVnPZkiPR1odfzT0jFKEEkTz4=; h=From:To:Cc:Subject:Date; b=AyWMg9uXAMyZFa7t27rFsrTtjALUvSOx2CXhamAJi6uIHRuDzLG5psgBCQ9qDAQKZ 7W8dN0KSlyr3EDF05RJ+HSUJw/m2e0ouOjj/NNoeN89S3ZEB9y9sq+CzvH8Bk912IF JwWQyCr1YM+CBLDynvs7unqfM0zI/y0qQhDQD6Bk9SEfzKsvox9CXhz3aj1LCOanto t534aaeS2I6x6bIeba9TYW5TaO4Rh4UJYyK6IEq48oGIi7Edi3xuHk7XG3U2T0x9QY cD+6V9Ff8tKCdY+J984FvIn7Es/J4qVCTxaKc3aoIWw55lZGRKV/mNnZkC8ecSb9F0 /JIGmkO9hMeyA== From: =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= To: Magnus Karlsson , Maciej Fijalkowski , Alexander Lobakin , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Andrew Lunn , Tony Nguyen , Przemek Kitszel , netdev@vger.kernel.org, bpf@vger.kernel.org Cc: =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Simon Horman , Stanislav Fomichev , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , intel-wired-lan@lists.osuosl.org, =?UTF-8?q?Cl=C3=A9ment=20Lecigne?= , Michal Swiatkowski , Sriram Yagnaraman , Kurt Kanzenbach , Michal Kubiak Subject: [PATCH net v4 0/5] xsk: Keep the shared info of zero-copy buffers in kernel memory Date: Fri, 4 Dec 2026 15:20:20 +0100 Message-ID: <20261204142030.626820-1-bjorn@kernel.org> X-Mailer: git-send-email 2.56.1 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 5 moves the shared info into the buffer pool and lets the device write up to the end of each chunk. Patch 2 makes libeth count XSk XDP_TX buffers one by one, as it read the shared info at a later bulk flush. Patch 1 makes libeth count completed XDP_TX buffers up, as idpf subtracts them. Without it the count of patch 2 still goes the wrong way. Patches 3 and 4 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 issues [1], Clément the one of patch 3 earlier [2]. Patch 4 was reproduced on igb in QEMU. v4 was tested on igb and veth in QEMU, v2 also on virtio-net and on mlx5 hardware. None covers multi-buffer zero copy, XDP_TX on idpf or the generic skb builder, so i40e, ice, idpf and gve are only build-tested, patch 1 included. Intel folks, could you run your multi-buffer zero-copy and XDP_TX tests on them? Changes in v4: - New patch 1: count completed XDP_TX buffers up in libeth. v2 left it for a separate fix, but patch 2 depends on it (Sashiko) - Patch 2: count up after patch 1, and describe a frame cut short by a full XDPSQ (Sashiko) - Patch 3: give the worst case, the whole shared info (Sashiko) - Patch 5: state what a forged shared info allows, and the privilege it needs (Sashiko) - Add Maciej's reviews, rebase on net Changes in v3: - Patch 2: describe the 2K chunk case and its impact (Sashiko) - Patch 4: give the shared info of the pool its own cache lines after the data path members (Maciej) - Patch 4: say that backports need patches 1 to 3 (Sashiko) - Add Olek's acks, rebase on net Changes in v2: - New patches 2 and 3 (Sashiko, Clément) - Patches 1 and 4: kernel-doc, buffer flag and ordering fixes (Sashiko) - Drop the selftest patch, it goes to net-next (Maciej) v3: https://lore.kernel.org/netdev/20261203095647.3448925-1-bjorn@kernel.org/ v2: https://lore.kernel.org/netdev/20261130123737.125432-1-bjorn@kernel.org/ 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 (5): libeth: xdp: Count completed XDP_TX buffers up 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 | 10 +++-- include/net/libeth/xdp.h | 11 +++++- include/net/libeth/xsk.h | 6 ++- include/net/xdp.h | 32 +++++++++++++--- include/net/xdp_sock_drv.h | 26 +++---------- include/net/xsk_buff_pool.h | 2 + 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, 99 insertions(+), 65 deletions(-) base-commit: 19727ac1afdaa3dac66e0f75daca7c3d156e1ca9 -- 2.53.1