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=1796291823; b=WMlEsC6xxpQu5Hd6xrF9Ssq+F/Cia/Ia0xV8dsVkYax+nDmoHMNwziPYWn4A6hQItLGL Svqnnj5YX8Q8mKI3823JrsHiqG8gnGkVdY51DXBWbGhMgjzymqhQbbu2KdZRXZBIVVTmI IufPUsOkwxjkplUosnzpKB/oTB9itrkqas0kb6a0WjEm47/0gXVRBrOK2jW2HKgqDDgcd X+iXqd7DB8NNM/66Pd7cUbbbm3og+nOAwUSklvOiDKQThjtA/WHdcfdjR0TBlZy2AouTc 9I+k9Pt46wJX6/CtBrPQN9NfpwQhuPsro8JwdyVpODYKkY80L+8l5oSH++Z39Xx37/A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796291823; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=l9NxrBgmHS6rm7EbVEbRdzjxIk56TUV1181jEpA+93g=; b=NBNRlpOWS+CQyQ6JUEcywOIc5FpYtS53dO6hjPnAepdbkWS7cfn39V40FluM3xmhEKdc evuOPFXF7cref5pOeGZ/Y01rJ2a6xBakLE/1A5/j6yctv/9cyXFvWEADkTMUAjMl0/+iF Ul4tr5F/Olj+l4Rlg1W6FizDFBv88Qa1zyiK0bsMG4I8uT+CbzCmw6Q6hWo4nCCDmdF4b TpLUxfDTjJBLJyJGxzJvExBDb5vQOuXaI/Ufw45AzHK2XkHIdC7fxcR+W88rcz1ZqgkTT bUKM52UmAXc1tEc70xIxf8nUoXfcBjTOAc/l5sM+C3AR+s2uV3bPO3TNmMowRcVGbhg== 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=nlVcfZGa; 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 5DCD4606A322; Thu, 3 Dec 2026 09:57:03 +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=nlVcfZGa Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B4001F00893; Thu, 3 Dec 2026 09:56:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796291823; bh=l9NxrBgmHS6rm7EbVEbRdzjxIk56TUV1181jEpA+93g=; h=From:To:Cc:Subject:Date; b=nlVcfZGa8bOQheDo3yqIgEr4URkEQzeotU+B7GJc44DU0cbJjNrT60Vhki/SbKjtx 2LZGRA3zORge36FD4EfTH17MJjYpqxkEBWIuKDUxe0FP1uVtzsGqpSxd/cKxkoEfCL pCpjmo1XxAntnTer+yu5vJFXiHBqPFPnEtSgqMbRANLY9jiFAdjPZVKkG9J5WuiTFG Ef1k7wSMa3MGqrZ7IuCDJNSPLzd4o06hRwHUmPnoAtHdnaR+nc7VjhZySywI99K76A Y6a2u7qGT04RzlmYrGE6Oc/UG5s2yZfp7LlfnAh3IBejSEaiuHhlJ4TW+Tn5Re6RXp Sb3NHIVvukZdQ== 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 Subject: [PATCH net v3 0/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Date: Thu, 3 Dec 2026 10:56:41 +0100 Message-ID: <20261203095647.3448925-1-bjorn@kernel.org> X-Mailer: git-send-email 2.56.1 X-Mailing-List: bpf@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 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 issues [1], Clément the one of patch 2 earlier [2]. Patch 3 was reproduced on igb in QEMU. v3 was tested on igb and veth in QEMU, v2 also on virtio-net and on mlx5 hardware. None covers multi-buffer zero copy or 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? Maciej will send the ice fix that v2 mentioned. Thanks, Maciej! 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) 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 (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 | 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, 97 insertions(+), 63 deletions(-) base-commit: 7c13d5d5afb4ba2e8634fe5aa0a9f2bca235cb4b -- 2.53.1-Meta