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/2026…@kernel.org/
v1: https://lore.kernel.org/netdev/2026…@kernel.org/
[1] https://lore.kernel.org/netdev/1795…@kernel.org/
[2] https://lore.kernel.org/bpf/2026…@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