BPF List
 help / color / mirror / Atom feed
* [PATCH net 0/3] xsk: Keep the shared info of zero-copy buffers in kernel memory
@ 2026-11-27 14:21 Björn Töpel
  2026-11-27 14:21 ` [PATCH net 1/3] libeth: xsk: Count each XDP_TX buffer on its own Björn Töpel
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Björn Töpel @ 2026-11-27 14:21 UTC (permalink / raw)
  To: Magnus Karlsson, Maciej Fijalkowski, Alexander Lobakin,
	Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
	John Fastabend, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Willem de Bruijn, Andrii Nakryiko, Eduard Zingerman,
	Kumar Kartikeya Dwivedi, Shuah Khan, netdev, bpf
  Cc: Björn Töpel, Simon Horman, Stanislav Fomichev,
	Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
	Emil Tsalapatis, Ihor Solodrai, Tony Nguyen, Przemek Kitszel,
	Larysa Zaremba, Tushar Vyavahare, Jason Xing, Bastien Curutchet,
	Colin Ian King, intel-wired-lan, linux-kselftest

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 2 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. Patch 3 updates the xsk selftests.

Sashiko found this in its review of the AF_XDP device buffer layout
series [1].

I tested this on mlx5 hardware, and on igb and veth in QEMU. None of
them receives multi-buffer packets in zero copy, so i40e, ice and
idpf, which do, 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.

[1] https://lore.kernel.org/netdev/179561567996.3135.9952128421877275714@kernel.org/

Björn Töpel (3):
  libeth: xsk: Count each XDP_TX buffer on its own
  xsk: Keep the shared info of zero-copy buffers in kernel memory
  selftests/bpf: Drop the zero-copy tailroom from the xsk tests

 include/net/libeth/tx.h                       |  3 +-
 include/net/libeth/xdp.h                      |  9 +++++-
 include/net/libeth/xsk.h                      |  6 ++--
 include/net/xdp.h                             | 32 +++++++++++++++----
 include/net/xdp_sock_drv.h                    | 29 ++++++-----------
 include/net/xsk_buff_pool.h                   |  2 ++
 net/xdp/xdp_umem.c                            |  3 +-
 net/xdp/xsk_buff_pool.c                       | 17 +++++-----
 .../selftests/bpf/prog_tests/test_xsk.c       | 10 +++---
 .../selftests/bpf/prog_tests/test_xsk.h       |  2 --
 tools/testing/selftests/bpf/prog_tests/xsk.c  | 13 +-------
 tools/testing/selftests/bpf/xskxceiver.c      | 15 +--------
 12 files changed, 67 insertions(+), 74 deletions(-)


base-commit: 28a371228d4eb4857cc31eeb1a0d7d01e9c3ea2f
-- 
2.56.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-11-27 16:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 14:21 [PATCH net 0/3] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-11-27 14:21 ` [PATCH net 1/3] libeth: xsk: Count each XDP_TX buffer on its own Björn Töpel
2026-11-27 14:21 ` [PATCH net 2/3] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-11-27 14:21 ` [PATCH net 3/3] selftests/bpf: Drop the zero-copy tailroom from the xsk tests Björn Töpel
2026-11-27 15:49   ` Maciej Fijalkowski
2026-11-27 16:56     ` Björn Töpel
2026-11-27 14:24 ` [PATCH net 0/3] xsk: Keep the shared info of zero-copy buffers in kernel memory netdev-bot+sinfo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox