Netdev List
 help / color / mirror / Atom feed
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>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Kumar Kartikeya Dwivedi <memxor@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>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Tony Nguyen <anthony.l.nguyen@intel.com>,
	Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	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>,
	intel-wired-lan@lists.osuosl.org,
	"Clément Lecigne" <clecigne@google.com>,
	"Michal Swiatkowski" <michal.swiatkowski@linux.intel.com>,
	"Sriram Yagnaraman" <sriram.yagnaraman@ericsson.com>,
	"Kurt Kanzenbach" <kurt@linutronix.de>,
	"Michal Kubiak" <michal.kubiak@intel.com>
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	[thread overview]
Message-ID: <20261204142030.626820-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 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


             reply	other threads:[~2026-12-04 14:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 14:20 Björn Töpel [this message]
2026-12-04 14:20 ` [PATCH net v4 1/5] libeth: xdp: Count completed XDP_TX buffers up Björn Töpel
2026-12-04 14:20 ` [PATCH net v4 2/5] libeth: xsk: Count each XDP_TX buffer on its own Björn Töpel
2026-12-04 14:20 ` [PATCH net v4 3/5] xdp: Size zero-copy skbs from the data, not the frame size Björn Töpel
2026-12-04 14:20 ` [PATCH net v4 4/5] intel: Copy the exact length of XSk packets to skbs Björn Töpel
2026-12-04 14:20 ` [PATCH net v4 5/5] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel

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=20261204142030.626820-1-bjorn@kernel.org \
    --to=bjorn@kernel.org \
    --cc=aleksander.lobakin@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrii@kernel.org \
    --cc=anthony.l.nguyen@intel.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=clecigne@google.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=kuba@kernel.org \
    --cc=kurt@linutronix.de \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=michal.kubiak@intel.com \
    --cc=michal.swiatkowski@linux.intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=sriram.yagnaraman@ericsson.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