From: "Björn Töpel" <bjorn@kernel.org>
To: Magnus Karlsson <magnus.karlsson@intel.com>,
Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
Alexander Lobakin <aleksander.lobakin@intel.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Shuah Khan <shuah@kernel.org>,
netdev@vger.kernel.org, bpf@vger.kernel.org
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>,
"Larysa Zaremba" <larysa.zaremba@intel.com>,
"Tushar Vyavahare" <tushar.vyavahare@intel.com>,
"Jason Xing" <kerneljasonxing@gmail.com>,
"Bastien Curutchet" <bastien.curutchet@bootlin.com>,
"Colin Ian King" <colin.i.king@gmail.com>,
intel-wired-lan@lists.osuosl.org,
linux-kselftest@vger.kernel.org
Subject: [PATCH net 0/3] xsk: Keep the shared info of zero-copy buffers in kernel memory
Date: Fri, 27 Nov 2026 15:21:26 +0100 [thread overview]
Message-ID: <20261127142131.3527737-1-bjorn@kernel.org> (raw)
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
next reply other threads:[~2026-11-27 14:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 14:21 Björn Töpel [this message]
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 14:24 ` [PATCH net 0/3] xsk: Keep the shared info of zero-copy buffers in kernel memory netdev-bot+sinfo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261127142131.3527737-1-bjorn@kernel.org \
--to=bjorn@kernel.org \
--cc=aleksander.lobakin@intel.com \
--cc=andrii@kernel.org \
--cc=anthony.l.nguyen@intel.com \
--cc=ast@kernel.org \
--cc=bastien.curutchet@bootlin.com \
--cc=bpf@vger.kernel.org \
--cc=colin.i.king@gmail.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=eddyz87@gmail.com \
--cc=edumazet@kernel.org \
--cc=emil@etsalapatis.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=ihor.solodrai@linux.dev \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kerneljasonxing@gmail.com \
--cc=kuba@kernel.org \
--cc=larysa.zaremba@intel.com \
--cc=linux-kselftest@vger.kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=tushar.vyavahare@intel.com \
--cc=willemb@google.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox