* [PATCH net v3 0/4] xsk: Keep the shared info of zero-copy buffers in kernel memory
@ 2026-12-03 9:56 Björn Töpel
2026-12-03 9:56 ` [PATCH net v3 1/4] libeth: xsk: Count each XDP_TX buffer on its own Björn Töpel
` (3 more replies)
0 siblings, 4 replies; 16+ messages in thread
From: Björn Töpel @ 2026-12-03 9:56 UTC (permalink / raw)
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, bpf
Cc: Björn Töpel, Simon Horman, Stanislav Fomichev,
Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
Emil Tsalapatis, Ihor Solodrai, intel-wired-lan,
Clément Lecigne, Michal Swiatkowski, Sriram Yagnaraman,
Kurt Kanzenbach
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
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH net v3 1/4] libeth: xsk: Count each XDP_TX buffer on its own
2026-12-03 9:56 [PATCH net v3 0/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
@ 2026-12-03 9:56 ` Björn Töpel
2026-12-04 10:39 ` netdev-bot+sashiko
2026-12-03 9:56 ` [PATCH net v3 2/4] xdp: Size zero-copy skbs from the data, not the frame size Björn Töpel
` (2 subsequent siblings)
3 siblings, 1 reply; 16+ messages in thread
From: Björn Töpel @ 2026-12-03 9:56 UTC (permalink / raw)
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, bpf
Cc: Björn Töpel, Simon Horman, Stanislav Fomichev,
Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
Emil Tsalapatis, Ihor Solodrai, intel-wired-lan,
Clément Lecigne, Michal Swiatkowski, Sriram Yagnaraman,
Kurt Kanzenbach
libeth takes the number of buffers of an XSk XDP_TX frame from its
shared info, and reports that many completed buffers to the driver. It
reads the shared info when it flushes the bulk, not when it queues the
frame. The shared info of a zero-copy buffer lives in the UMEM, which
userspace may write at any time, so a rewritten count makes libeth
report a wrong number. Once the last patch of this series moves the
shared info into the buffer pool, the next multi-buffer frame of the
same poll can overwrite it before the flush.
A wrong number breaks the in-flight count of XDP_TX buffers that idpf
keeps on its XSk queues, and idpf may then complete XDP_TX buffers as
XSk xmit frames.
Make libeth count each buffer on its own SQE. Head and fragments each
count one completed buffer, and the head counts the packet. Stats stay
the same for frames sent in full.
Found by an AI agent while reviewing this code. Not triggered at
runtime.
Fixes: b3ad8450b4dc ("libeth: xsk: add XSk XDP_TX sending helpers")
Acked-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Signed-off-by: Björn Töpel <bjorn@kernel.org>
---
include/net/libeth/tx.h | 8 +++++---
include/net/libeth/xdp.h | 9 ++++++++-
include/net/libeth/xsk.h | 6 ++++--
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/include/net/libeth/tx.h b/include/net/libeth/tx.h
index c3db5c6f1641..a8cf03c8be71 100644
--- a/include/net/libeth/tx.h
+++ b/include/net/libeth/tx.h
@@ -22,7 +22,8 @@
* @LIBETH_SQE_XDP_XMIT: &xdp_frame, unmap and xdp_return_frame_bulk(), stats
* @LIBETH_SQE_XDP_XMIT_FRAG: &xdp_frame frag, only unmap DMA
* @LIBETH_SQE_XSK_TX: &libeth_xdp_buff on XSk queue, xsk_buff_free(), stats
- * @LIBETH_SQE_XSK_TX_FRAG: &libeth_xdp_buff frag on XSk queue, xsk_buff_free()
+ * @LIBETH_SQE_XSK_TX_FRAG: &libeth_xdp_buff frag on XSk queue, xsk_buff_free(),
+ * stats
*/
enum libeth_sqe_type {
LIBETH_SQE_EMPTY = 0U,
@@ -50,9 +51,10 @@ enum libeth_sqe_type {
* @xsk: XSk Rx frame from XDP_TX action
* @dma: DMA address to unmap
* @len: length of the mapped region to unmap
- * @nr_frags: number of frags in the frame this buffer belongs to
+ * @nr_frags: number of frags in the frame this buffer belongs to, not for XSk
* @packets: number of physical packets sent for this frame
- * @bytes: number of physical bytes sent for this frame
+ * @bytes: number of physical bytes sent for this frame, or for this buffer
+ * on XSk
* @priv: driver-private scratchpad
*/
struct libeth_sqe {
diff --git a/include/net/libeth/xdp.h b/include/net/libeth/xdp.h
index 898723ab62e8..66a3c4ec9967 100644
--- a/include/net/libeth/xdp.h
+++ b/include/net/libeth/xdp.h
@@ -1794,12 +1794,19 @@ __libeth_xdp_complete_tx(struct libeth_sqe *sqe, struct libeth_cq_pp *cp,
switch (type) {
case LIBETH_SQE_XDP_TX:
case LIBETH_SQE_XDP_XMIT:
- case LIBETH_SQE_XSK_TX:
cp->xdp_tx -= sqe->nr_frags;
cp->xss->packets++;
cp->xss->bytes += sqe->bytes;
break;
+ case LIBETH_SQE_XSK_TX:
+ cp->xss->packets++;
+ fallthrough;
+ case LIBETH_SQE_XSK_TX_FRAG:
+ /* One buffer per SQE, see libeth_xsk_tx_fill_buf() */
+ cp->xdp_tx--;
+ cp->xss->bytes += sqe->bytes;
+ break;
default:
break;
}
diff --git a/include/net/libeth/xsk.h b/include/net/libeth/xsk.h
index 249b1c740788..2cd4252a3445 100644
--- a/include/net/libeth/xsk.h
+++ b/include/net/libeth/xsk.h
@@ -129,6 +129,10 @@ libeth_xsk_tx_fill_buf(struct libeth_xdp_tx_frame frm, u32 i,
sqe = &sq->sqes[i];
sqe->xsk = xdp;
+ /* Count each buffer on its own SQE. The shared info of the frame
+ * may change before the bulk is flushed.
+ */
+ sqe->bytes = desc.len;
if (!(desc.flags & LIBETH_XDP_TX_FIRST)) {
sqe->type = LIBETH_SQE_XSK_TX_FRAG;
@@ -136,8 +140,6 @@ libeth_xsk_tx_fill_buf(struct libeth_xdp_tx_frame frm, u32 i,
}
sqe->type = LIBETH_SQE_XSK_TX;
- libeth_xdp_tx_fill_stats(sqe, &desc,
- xdp_get_shared_info_from_buff(&xdp->base));
return desc;
}
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH net v3 2/4] xdp: Size zero-copy skbs from the data, not the frame size
2026-12-03 9:56 [PATCH net v3 0/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-12-03 9:56 ` [PATCH net v3 1/4] libeth: xsk: Count each XDP_TX buffer on its own Björn Töpel
@ 2026-12-03 9:56 ` Björn Töpel
2026-12-03 14:04 ` Maciej Fijalkowski
2026-12-04 10:39 ` netdev-bot+sashiko
2026-12-03 9:56 ` [PATCH net v3 3/4] intel: Copy the exact length of XSk packets to skbs Björn Töpel
2026-12-03 9:56 ` [PATCH net v3 4/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
3 siblings, 2 replies; 16+ messages in thread
From: Björn Töpel @ 2026-12-03 9:56 UTC (permalink / raw)
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, bpf
Cc: Björn Töpel, Simon Horman, Stanislav Fomichev,
Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
Emil Tsalapatis, Ihor Solodrai, intel-wired-lan,
Clément Lecigne, Michal Swiatkowski, Sriram Yagnaraman,
Kurt Kanzenbach
xdp_build_skb_from_zc() gives the skb head the frame size of the XSk
buffer, and the skb shared info takes the end of it. A device may fill
a single-buffer XSk frame to its end, so a long packet overwrites the
shared info of the new skb with packet data. With 2K chunks, no UMEM
headroom and the default MTU, a 1514 byte frame that XDP passes on
ice, idpf or gve needs 256 + 1514 + 320 = 2090 bytes and gets 2048.
The sender controls up to 48 bytes of the shared info, its frag list
among them. The last patch of this series lets multi-buffer pools and
bpf_xdp_adjust_tail() reach the end of the frame as well.
The copies of the head and of the fragments also round the length up
to 16 bytes, and read and write past the end of the data.
Size the head from the data, and copy the exact length. Heads larger
than a page come from kmalloc, not the page pool.
Found again by an AI code review agent, and the 2K case by reading the
code. Reproduced out of tree, with a test module and the AF_XDP
page-pool RFC on fbnic in QEMU.
Reported-by: Clément Lecigne <clecigne@google.com>
Link: https://lore.kernel.org/bpf/20260629072300.1664622-1-clecigne@google.com/
Fixes: 560d958c6c68 ("xsk: add generic XSk &xdp_buff -> skb conversion")
Acked-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Signed-off-by: Björn Töpel <bjorn@kernel.org>
---
net/core/xdp.c | 40 ++++++++++++++++++++++++++++------------
1 file changed, 28 insertions(+), 12 deletions(-)
diff --git a/net/core/xdp.c b/net/core/xdp.c
index 1d679e8fd649..33a6740b411f 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -709,7 +709,7 @@ static noinline bool xdp_copy_frags_from_zc(struct sk_buff *skb,
}
memcpy(page_address(page) + offset, skb_frag_address(frag),
- LARGEST_ALIGN(len));
+ len);
__skb_fill_page_desc_noacc(sinfo, i, page, offset, len);
tsize += truesize;
@@ -723,6 +723,27 @@ static noinline bool xdp_copy_frags_from_zc(struct sk_buff *skb,
return true;
}
+static struct sk_buff *xdp_zc_alloc_head(struct page_pool *pp,
+ struct net_device *dev, u32 size)
+{
+ u32 truesize = SKB_HEAD_ALIGN(size);
+ struct sk_buff *skb;
+ void *data;
+
+ if (truesize > PAGE_SIZE)
+ return __netdev_alloc_skb(dev, size, GFP_ATOMIC | __GFP_NOWARN);
+
+ data = page_pool_dev_alloc_va(pp, &truesize);
+ if (unlikely(!data))
+ return NULL;
+
+ skb = napi_build_skb(data, truesize);
+ if (unlikely(!skb))
+ page_pool_free_va(pp, data, true);
+
+ return skb;
+}
+
/**
* xdp_build_skb_from_zc - create an skb from XSk &xdp_buff
* @xdp: source XSk buff
@@ -730,7 +751,8 @@ static noinline bool xdp_copy_frags_from_zc(struct sk_buff *skb,
* Similar to xdp_build_skb_from_buff(), but for XSk frames. Allocate an skb
* head, new buffer for the head, copy the data and initialize the skb fields.
* If there are frags, allocate new buffers for them and copy.
- * Buffers are allocated from the system percpu pools to try recycling them.
+ * Buffers are allocated from the system percpu pools to try recycling them,
+ * except a head that does not fit into a page.
* If new skb was built successfully, @xdp is returned to XSk pool's freelist.
* On error, it remains untouched and the caller must take care of this.
*
@@ -738,33 +760,27 @@ static noinline bool xdp_copy_frags_from_zc(struct sk_buff *skb,
*/
struct sk_buff *xdp_build_skb_from_zc(struct xdp_buff *xdp)
{
+ u32 size = xdp->data_end - xdp->data_hard_start;
const struct xdp_rxq_info *rxq = xdp->rxq;
u32 len = xdp->data_end - xdp->data_meta;
- u32 truesize = xdp->frame_sz;
struct sk_buff *skb = NULL;
struct page_pool *pp;
int metalen;
- void *data;
if (!IS_ENABLED(CONFIG_PAGE_POOL))
return NULL;
local_lock_nested_bh(&system_page_pool.bh_lock);
pp = this_cpu_read(system_page_pool.pool);
- data = page_pool_dev_alloc_va(pp, &truesize);
- if (unlikely(!data))
- goto out;
- skb = napi_build_skb(data, truesize);
- if (unlikely(!skb)) {
- page_pool_free_va(pp, data, true);
+ skb = xdp_zc_alloc_head(pp, rxq->dev, size);
+ if (unlikely(!skb))
goto out;
- }
skb_mark_for_recycle(skb);
skb_reserve(skb, xdp->data_meta - xdp->data_hard_start);
- memcpy(__skb_put(skb, len), xdp->data_meta, LARGEST_ALIGN(len));
+ memcpy(__skb_put(skb, len), xdp->data_meta, len);
metalen = xdp->data - xdp->data_meta;
if (metalen > 0) {
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH net v3 3/4] intel: Copy the exact length of XSk packets to skbs
2026-12-03 9:56 [PATCH net v3 0/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-12-03 9:56 ` [PATCH net v3 1/4] libeth: xsk: Count each XDP_TX buffer on its own Björn Töpel
2026-12-03 9:56 ` [PATCH net v3 2/4] xdp: Size zero-copy skbs from the data, not the frame size Björn Töpel
@ 2026-12-03 9:56 ` Björn Töpel
2026-12-03 14:07 ` Maciej Fijalkowski
2026-12-04 14:51 ` Loktionov, Aleksandr
2026-12-03 9:56 ` [PATCH net v3 4/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
3 siblings, 2 replies; 16+ messages in thread
From: Björn Töpel @ 2026-12-03 9:56 UTC (permalink / raw)
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, bpf
Cc: Björn Töpel, Simon Horman, Stanislav Fomichev,
Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
Emil Tsalapatis, Ihor Solodrai, intel-wired-lan,
Clément Lecigne, Michal Swiatkowski, Sriram Yagnaraman,
Kurt Kanzenbach
i40e, igb, igc and ixgbe copy an XSk zero-copy packet that the XDP
program passes into a new skb, and round the length of the copy up to
a multiple of 8 bytes. The copy then reads up to 7 bytes past the end
of the data. When the data ends at the end of the last chunk of the
UMEM, the read hits the guard page after the UMEM mapping and faults.
On i40e the device can already fill a single-buffer chunk to its end.
The last patch of this series lets multi-buffer pools and
bpf_xdp_adjust_tail() reach the end of a chunk on all four.
Copy the exact length.
Found by an AI code review agent in review of this series. Reproduced
on igb in QEMU. An AF_XDP socket in zero copy with 4K chunks and only
the last chunk of the UMEM in the FILL ring, and an XDP program that
adds 4 bytes of metadata, grows the tail to the end of the chunk and
passes the packet:
BUG: unable to handle page fault for address: ffa0000001048000
RIP: 0010:memcpy+0xc/0x30
igb_clean_rx_irq_zc+0x8a7/0x1520
igb_poll+0x1039/0x4f50
With this patch the same test passes.
Fixes: 6dba29537c0f ("i40e: respect metadata on XSK Rx to skb")
Fixes: f322a620be69 ("ixgbe: respect metadata on XSK Rx to skb")
Fixes: f9e61d365baf ("igc: don't reserve excessive XDP_PACKET_HEADROOM on XSK Rx to skb")
Fixes: 2c6196013f84 ("igb: Add AF_XDP zero-copy Rx support")
Acked-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Signed-off-by: Björn Töpel <bjorn@kernel.org>
---
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 +--
4 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
index 5f5f33b2a097..03dd949a16b5 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
@@ -308,8 +308,7 @@ static struct sk_buff *i40e_construct_skb_zc(struct i40e_ring *rx_ring,
if (unlikely(!skb))
goto out;
- memcpy(__skb_put(skb, totalsize), xdp->data_meta,
- ALIGN(totalsize, sizeof(long)));
+ memcpy(__skb_put(skb, totalsize), xdp->data_meta, totalsize);
if (metasize) {
skb_metadata_set(skb, metasize);
diff --git a/drivers/net/ethernet/intel/igb/igb_xsk.c b/drivers/net/ethernet/intel/igb/igb_xsk.c
index ce4a7b58cad2..aa00c36fe63f 100644
--- a/drivers/net/ethernet/intel/igb/igb_xsk.c
+++ b/drivers/net/ethernet/intel/igb/igb_xsk.c
@@ -280,8 +280,7 @@ static struct sk_buff *igb_construct_skb_zc(struct igb_ring *rx_ring,
if (timestamp)
skb_hwtstamps(skb)->hwtstamp = timestamp;
- memcpy(__skb_put(skb, totalsize), xdp->data_meta,
- ALIGN(totalsize, sizeof(long)));
+ memcpy(__skb_put(skb, totalsize), xdp->data_meta, totalsize);
if (metasize) {
skb_metadata_set(skb, metasize);
diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index 1fb5f3cbe93c..a3b153bbb081 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -2749,8 +2749,7 @@ static struct sk_buff *igc_construct_skb_zc(struct igc_ring *ring,
if (unlikely(!skb))
return NULL;
- memcpy(__skb_put(skb, totalsize), xdp->data_meta,
- ALIGN(totalsize, sizeof(long)));
+ memcpy(__skb_put(skb, totalsize), xdp->data_meta, totalsize);
if (metasize) {
skb_metadata_set(skb, metasize);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
index 89f96c463f02..0d56466956c1 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
@@ -224,8 +224,7 @@ static struct sk_buff *ixgbe_construct_skb_zc(struct ixgbe_ring *rx_ring,
if (unlikely(!skb))
return NULL;
- memcpy(__skb_put(skb, totalsize), xdp->data_meta,
- ALIGN(totalsize, sizeof(long)));
+ memcpy(__skb_put(skb, totalsize), xdp->data_meta, totalsize);
if (metasize) {
skb_metadata_set(skb, metasize);
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH net v3 4/4] xsk: Keep the shared info of zero-copy buffers in kernel memory
2026-12-03 9:56 [PATCH net v3 0/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
` (2 preceding siblings ...)
2026-12-03 9:56 ` [PATCH net v3 3/4] intel: Copy the exact length of XSk packets to skbs Björn Töpel
@ 2026-12-03 9:56 ` Björn Töpel
2026-12-03 15:16 ` Maciej Fijalkowski
` (2 more replies)
3 siblings, 3 replies; 16+ messages in thread
From: Björn Töpel @ 2026-12-03 9:56 UTC (permalink / raw)
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, bpf
Cc: Björn Töpel, Simon Horman, Stanislav Fomichev,
Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
Emil Tsalapatis, Ihor Solodrai, intel-wired-lan,
Clément Lecigne, Michal Swiatkowski, Sriram Yagnaraman,
Kurt Kanzenbach
A packet that a driver receives in zero-copy mode over several buffers
keeps its shared info, the fragment list and its count, in the
tailroom of the UMEM chunk of its head. Userspace may write the UMEM
at any time, also while the kernel walks the fragments, and a
rewritten list or count makes the kernel read and write out of bounds.
Keep the shared info in the buffer pool, which outlives its buffers
and the queues that point to it, and let the device write up to the
end of the chunk. One shared info per pool is enough, as a pool builds
one multi-buffer packet at a time.
Buffers carry a flag for this, set again on every reuse, as drivers
may clear the flags of the buffers they receive into.
Multi-buffer pools now give the device the whole chunk, as
single-buffer pools already do. Every UMEM accepts a larger headroom,
also in copy mode, and bpf_xdp_adjust_tail() can grow a zero-copy
packet up to the end of its chunk.
A backport needs patches 1 to 3 of this series, which stop libeth and
the skb builders from relying on the old layout.
Found by an AI code review agent, in its review of another series. Not
triggered at runtime.
Suggested-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Fixes: 24ea50127ecf ("xsk: support mbuf on ZC RX")
Signed-off-by: Björn Töpel <bjorn@kernel.org>
---
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/xdp/xdp_umem.c | 3 +--
net/xdp/xsk_buff_pool.c | 20 ++++++++++++--------
6 files changed, 48 insertions(+), 37 deletions(-)
diff --git a/include/net/xdp.h b/include/net/xdp.h
index 07231adfb5f8..052402766988 100644
--- a/include/net/xdp.h
+++ b/include/net/xdp.h
@@ -65,6 +65,10 @@ struct xdp_rxq_info {
u32 reg_state;
struct xdp_mem_info mem;
u32 frag_size;
+ /* Shared info of buffers with %XDP_FLAGS_SINFO_EXT, in the XSk buffer
+ * pool, set by xsk_pool_set_rxq_info().
+ */
+ struct skb_shared_info *ext_sinfo;
} ____cacheline_aligned; /* perf critical, avoid false-sharing */
struct xdp_txq_info {
@@ -81,6 +85,13 @@ enum xdp_buff_flags {
* XDP program is not attached.
*/
XDP_FLAGS_FRAGS_UNREADABLE = BIT(2),
+ /* The shared info lives in &xdp_rxq_info.ext_sinfo, not at the end of
+ * the frame, as userspace may write the frame. The frame reserves no
+ * tailroom, so the data may reach its end. The pool builds one such
+ * buffer at a time, so a consumer that uses the shared info later
+ * must copy what it needs.
+ */
+ XDP_FLAGS_SINFO_EXT = BIT(3),
};
struct xdp_buff {
@@ -178,17 +189,26 @@ xdp_prepare_buff(struct xdp_buff *xdp, unsigned char *hard_start,
/* Reserve memory area at end-of data area.
*
- * This macro reserves tailroom in the XDP buffer by limiting the
- * XDP/BPF data access to data_hard_end. Notice same area (and size)
- * is used for XDP_PASS, when constructing the SKB via build_skb().
+ * This reserves tailroom in the XDP buffer by limiting the XDP/BPF data
+ * access to data_hard_end. Notice same area (and size) is used for
+ * XDP_PASS, when constructing the SKB via build_skb(). Buffers with
+ * %XDP_FLAGS_SINFO_EXT keep the shared info elsewhere and reserve none.
*/
-#define xdp_data_hard_end(xdp) \
- ((xdp)->data_hard_start + (xdp)->frame_sz - \
- SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
+static __always_inline void *xdp_data_hard_end(const struct xdp_buff *xdp)
+{
+ u32 tailroom = SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
+
+ if (xdp->flags & XDP_FLAGS_SINFO_EXT)
+ tailroom = 0;
+ return xdp->data_hard_start + xdp->frame_sz - tailroom;
+}
static inline struct skb_shared_info *
xdp_get_shared_info_from_buff(const struct xdp_buff *xdp)
{
+ if (xdp->flags & XDP_FLAGS_SINFO_EXT)
+ return READ_ONCE(xdp->rxq)->ext_sinfo;
+
return (struct skb_shared_info *)xdp_data_hard_end(xdp);
}
diff --git a/include/net/xdp_sock_drv.h b/include/net/xdp_sock_drv.h
index a40ad3f90f13..ec74bf3ffa51 100644
--- a/include/net/xdp_sock_drv.h
+++ b/include/net/xdp_sock_drv.h
@@ -41,11 +41,6 @@ static inline u32 xsk_pool_get_headroom(struct xsk_buff_pool *pool)
return XDP_PACKET_HEADROOM + pool->headroom;
}
-static inline u32 xsk_pool_get_tailroom(bool mbuf)
-{
- return mbuf ? SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) : 0;
-}
-
static inline u32 xsk_pool_get_chunk_size(struct xsk_buff_pool *pool)
{
return pool->chunk_size;
@@ -58,18 +53,7 @@ static inline u32 __xsk_pool_get_rx_frame_size(struct xsk_buff_pool *pool)
static inline u32 xsk_pool_get_rx_frame_size(struct xsk_buff_pool *pool)
{
- u32 frame_size = __xsk_pool_get_rx_frame_size(pool);
- struct xdp_umem *umem = pool->umem;
- bool mbuf;
-
- /* Reserve tailroom only for zero-copy pools that opted into
- * multi-buffer. The reserved area is used for skb_shared_info,
- * matching the XDP core's xdp_data_hard_end() layout.
- */
- mbuf = pool->dev && (umem->flags & XDP_UMEM_SG_FLAG);
- frame_size -= xsk_pool_get_tailroom(mbuf);
-
- return ALIGN_DOWN(frame_size, 128);
+ return ALIGN_DOWN(__xsk_pool_get_rx_frame_size(pool), 128);
}
static inline u32 xsk_pool_get_rx_frag_step(struct xsk_buff_pool *pool)
@@ -152,7 +136,6 @@ static inline void xsk_buff_free(struct xdp_buff *xdp)
xp_free(pos);
}
- xdp_get_shared_info_from_buff(xdp)->nr_frags = 0;
xdp_buff_clear_frags_flag(xdp);
out:
xp_free(xskb);
@@ -226,8 +209,11 @@ static inline void xsk_buff_set_size(struct xdp_buff *xdp, u32 size)
xdp->data = xdp->data_hard_start + XDP_PACKET_HEADROOM;
xdp->data_meta = xdp->data;
xdp->data_end = xdp->data + size;
- /* Frags flag is cleared when the frags of a head are released */
- xdp->flags &= XDP_FLAGS_HAS_FRAGS;
+ /* Frags flag is cleared when the frags of a head are released. The
+ * shared info stays in the pool, see xp_set_rxq_info(), also for a
+ * buffer whose flags a driver cleared.
+ */
+ xdp->flags = (xdp->flags & XDP_FLAGS_HAS_FRAGS) | XDP_FLAGS_SINFO_EXT;
}
static inline dma_addr_t xsk_buff_raw_get_dma(struct xsk_buff_pool *pool,
diff --git a/include/net/xsk_buff_pool.h b/include/net/xsk_buff_pool.h
index 02e89350faf9..ef4bbf7f66b9 100644
--- a/include/net/xsk_buff_pool.h
+++ b/include/net/xsk_buff_pool.h
@@ -95,6 +95,8 @@ struct xsk_buff_pool {
* destructor callback.
*/
spinlock_t cq_prod_lock;
+ /* Own cache lines, as zero-copy multi-buffer Rx writes it per packet */
+ struct skb_shared_info sinfo ____cacheline_aligned_in_smp;
struct xdp_buff_xsk *free_heads[];
};
diff --git a/net/core/filter.c b/net/core/filter.c
index 53c042b267ab..3820c4edc14d 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4510,7 +4510,7 @@ BPF_CALL_2(bpf_xdp_adjust_tail, struct xdp_buff *, xdp, int, offset)
return bpf_xdp_frags_increase_tail(xdp, offset);
}
- /* Notice that xdp_data_hard_end have reserved some tailroom */
+ /* Notice that xdp_data_hard_end may have reserved some tailroom */
if (unlikely(data_end > data_hard_end))
return -EINVAL;
diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c
index ad72bd96905c..de8a2747ac9f 100644
--- a/net/xdp/xdp_umem.c
+++ b/net/xdp/xdp_umem.c
@@ -195,8 +195,7 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr)
if (!unaligned_chunks && chunks_rem)
return -EINVAL;
- if (headroom > chunk_size - XDP_PACKET_HEADROOM -
- SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) - 128)
+ if (headroom > chunk_size - XDP_PACKET_HEADROOM - 128)
return -EINVAL;
if (mr->flags & XDP_UMEM_TX_METADATA_LEN) {
diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
index 5ec092f7cb6f..28bdc63551bf 100644
--- a/net/xdp/xsk_buff_pool.c
+++ b/net/xdp/xsk_buff_pool.c
@@ -107,6 +107,7 @@ struct xsk_buff_pool *xp_create_and_assign_umem(struct xdp_sock *xs,
xskb = &pool->heads[i];
xskb->pool = pool;
xskb->xdp.frame_sz = umem->chunk_size - umem->headroom;
+ xskb->xdp.flags = XDP_FLAGS_SINFO_EXT;
INIT_LIST_HEAD(&xskb->list_node);
if (pool->unaligned)
pool->free_heads[i] = xskb;
@@ -125,8 +126,15 @@ void xp_set_rxq_info(struct xsk_buff_pool *pool, struct xdp_rxq_info *rxq)
{
u32 i;
+ /* Userspace may write the UMEM. Keep the shared info in the pool,
+ * and let the device write up to the end of each chunk. A NAPI may
+ * still run on the buffers, so publish the shared info first.
+ */
+ rxq->ext_sinfo = &pool->sinfo;
+ /* Pairs with READ_ONCE(xdp->rxq) in xdp_get_shared_info_from_buff() */
+ smp_wmb();
for (i = 0; i < pool->heads_cnt; i++)
- pool->heads[i].xdp.rxq = rxq;
+ WRITE_ONCE(pool->heads[i].xdp.rxq, rxq);
}
EXPORT_SYMBOL(xp_set_rxq_info);
@@ -229,12 +237,7 @@ int xp_assign_dev(struct xsk_buff_pool *pool,
segs = 1;
}
- /* open-code xsk_pool_get_rx_frame_size() as pool->dev is not
- * set yet at this point; we are before getting down to driver
- */
- frame_size = __xsk_pool_get_rx_frame_size(pool) -
- xsk_pool_get_tailroom(mbuf);
- frame_size = ALIGN_DOWN(frame_size, 128);
+ frame_size = xsk_pool_get_rx_frame_size(pool);
if (needed > frame_size * segs) {
err = -EINVAL;
@@ -629,7 +632,8 @@ struct xdp_buff *xp_alloc(struct xsk_buff_pool *pool)
xskb->xdp.data = xskb->xdp.data_hard_start + XDP_PACKET_HEADROOM;
xskb->xdp.data_meta = xskb->xdp.data;
- xskb->xdp.flags &= XDP_FLAGS_HAS_FRAGS;
+ xskb->xdp.flags = (xskb->xdp.flags & XDP_FLAGS_HAS_FRAGS) |
+ XDP_FLAGS_SINFO_EXT;
if (pool->dev)
xp_dma_sync_for_device(pool, xskb->dma, pool->frame_len);
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH net v3 2/4] xdp: Size zero-copy skbs from the data, not the frame size
2026-12-03 9:56 ` [PATCH net v3 2/4] xdp: Size zero-copy skbs from the data, not the frame size Björn Töpel
@ 2026-12-03 14:04 ` Maciej Fijalkowski
2026-12-04 10:39 ` netdev-bot+sashiko
1 sibling, 0 replies; 16+ messages in thread
From: Maciej Fijalkowski @ 2026-12-03 14:04 UTC (permalink / raw)
To: Björn Töpel
Cc: Magnus Karlsson, 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, bpf, Simon Horman, Stanislav Fomichev, Martin KaFai Lau,
Song Liu, Yonghong Song, Jiri Olsa, Emil Tsalapatis,
Ihor Solodrai, intel-wired-lan, Clément Lecigne,
Michal Swiatkowski, Sriram Yagnaraman, Kurt Kanzenbach
On Thu, Dec 03, 2026 at 10:56:43AM +0100, Björn Töpel wrote:
> xdp_build_skb_from_zc() gives the skb head the frame size of the XSk
> buffer, and the skb shared info takes the end of it. A device may fill
> a single-buffer XSk frame to its end, so a long packet overwrites the
> shared info of the new skb with packet data. With 2K chunks, no UMEM
> headroom and the default MTU, a 1514 byte frame that XDP passes on
> ice, idpf or gve needs 256 + 1514 + 320 = 2090 bytes and gets 2048.
> The sender controls up to 48 bytes of the shared info, its frag list
> among them. The last patch of this series lets multi-buffer pools and
> bpf_xdp_adjust_tail() reach the end of the frame as well.
>
> The copies of the head and of the fragments also round the length up
> to 16 bytes, and read and write past the end of the data.
>
> Size the head from the data, and copy the exact length. Heads larger
> than a page come from kmalloc, not the page pool.
>
> Found again by an AI code review agent, and the 2K case by reading the
> code. Reproduced out of tree, with a test module and the AF_XDP
> page-pool RFC on fbnic in QEMU.
>
> Reported-by: Clément Lecigne <clecigne@google.com>
> Link: https://lore.kernel.org/bpf/20260629072300.1664622-1-clecigne@google.com/
> Fixes: 560d958c6c68 ("xsk: add generic XSk &xdp_buff -> skb conversion")
> Acked-by: Alexander Lobakin <aleksander.lobakin@intel.com>
> Signed-off-by: Björn Töpel <bjorn@kernel.org>
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> ---
> net/core/xdp.c | 40 ++++++++++++++++++++++++++++------------
> 1 file changed, 28 insertions(+), 12 deletions(-)
>
> diff --git a/net/core/xdp.c b/net/core/xdp.c
> index 1d679e8fd649..33a6740b411f 100644
> --- a/net/core/xdp.c
> +++ b/net/core/xdp.c
> @@ -709,7 +709,7 @@ static noinline bool xdp_copy_frags_from_zc(struct sk_buff *skb,
> }
>
> memcpy(page_address(page) + offset, skb_frag_address(frag),
> - LARGEST_ALIGN(len));
> + len);
> __skb_fill_page_desc_noacc(sinfo, i, page, offset, len);
>
> tsize += truesize;
> @@ -723,6 +723,27 @@ static noinline bool xdp_copy_frags_from_zc(struct sk_buff *skb,
> return true;
> }
>
> +static struct sk_buff *xdp_zc_alloc_head(struct page_pool *pp,
> + struct net_device *dev, u32 size)
> +{
> + u32 truesize = SKB_HEAD_ALIGN(size);
> + struct sk_buff *skb;
> + void *data;
> +
> + if (truesize > PAGE_SIZE)
> + return __netdev_alloc_skb(dev, size, GFP_ATOMIC | __GFP_NOWARN);
> +
> + data = page_pool_dev_alloc_va(pp, &truesize);
> + if (unlikely(!data))
> + return NULL;
> +
> + skb = napi_build_skb(data, truesize);
> + if (unlikely(!skb))
> + page_pool_free_va(pp, data, true);
> +
> + return skb;
> +}
> +
> /**
> * xdp_build_skb_from_zc - create an skb from XSk &xdp_buff
> * @xdp: source XSk buff
> @@ -730,7 +751,8 @@ static noinline bool xdp_copy_frags_from_zc(struct sk_buff *skb,
> * Similar to xdp_build_skb_from_buff(), but for XSk frames. Allocate an skb
> * head, new buffer for the head, copy the data and initialize the skb fields.
> * If there are frags, allocate new buffers for them and copy.
> - * Buffers are allocated from the system percpu pools to try recycling them.
> + * Buffers are allocated from the system percpu pools to try recycling them,
> + * except a head that does not fit into a page.
> * If new skb was built successfully, @xdp is returned to XSk pool's freelist.
> * On error, it remains untouched and the caller must take care of this.
> *
> @@ -738,33 +760,27 @@ static noinline bool xdp_copy_frags_from_zc(struct sk_buff *skb,
> */
> struct sk_buff *xdp_build_skb_from_zc(struct xdp_buff *xdp)
> {
> + u32 size = xdp->data_end - xdp->data_hard_start;
> const struct xdp_rxq_info *rxq = xdp->rxq;
> u32 len = xdp->data_end - xdp->data_meta;
> - u32 truesize = xdp->frame_sz;
> struct sk_buff *skb = NULL;
> struct page_pool *pp;
> int metalen;
> - void *data;
>
> if (!IS_ENABLED(CONFIG_PAGE_POOL))
> return NULL;
>
> local_lock_nested_bh(&system_page_pool.bh_lock);
> pp = this_cpu_read(system_page_pool.pool);
> - data = page_pool_dev_alloc_va(pp, &truesize);
> - if (unlikely(!data))
> - goto out;
>
> - skb = napi_build_skb(data, truesize);
> - if (unlikely(!skb)) {
> - page_pool_free_va(pp, data, true);
> + skb = xdp_zc_alloc_head(pp, rxq->dev, size);
> + if (unlikely(!skb))
> goto out;
> - }
>
> skb_mark_for_recycle(skb);
> skb_reserve(skb, xdp->data_meta - xdp->data_hard_start);
>
> - memcpy(__skb_put(skb, len), xdp->data_meta, LARGEST_ALIGN(len));
> + memcpy(__skb_put(skb, len), xdp->data_meta, len);
>
> metalen = xdp->data - xdp->data_meta;
> if (metalen > 0) {
> --
> 2.53.1-Meta
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH net v3 3/4] intel: Copy the exact length of XSk packets to skbs
2026-12-03 9:56 ` [PATCH net v3 3/4] intel: Copy the exact length of XSk packets to skbs Björn Töpel
@ 2026-12-03 14:07 ` Maciej Fijalkowski
2026-12-04 14:51 ` Loktionov, Aleksandr
1 sibling, 0 replies; 16+ messages in thread
From: Maciej Fijalkowski @ 2026-12-03 14:07 UTC (permalink / raw)
To: Björn Töpel
Cc: Magnus Karlsson, 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, bpf, Simon Horman, Stanislav Fomichev, Martin KaFai Lau,
Song Liu, Yonghong Song, Jiri Olsa, Emil Tsalapatis,
Ihor Solodrai, intel-wired-lan, Clément Lecigne,
Michal Swiatkowski, Sriram Yagnaraman, Kurt Kanzenbach
On Thu, Dec 03, 2026 at 10:56:44AM +0100, Björn Töpel wrote:
> i40e, igb, igc and ixgbe copy an XSk zero-copy packet that the XDP
> program passes into a new skb, and round the length of the copy up to
> a multiple of 8 bytes. The copy then reads up to 7 bytes past the end
> of the data. When the data ends at the end of the last chunk of the
> UMEM, the read hits the guard page after the UMEM mapping and faults.
>
> On i40e the device can already fill a single-buffer chunk to its end.
> The last patch of this series lets multi-buffer pools and
> bpf_xdp_adjust_tail() reach the end of a chunk on all four.
>
> Copy the exact length.
>
> Found by an AI code review agent in review of this series. Reproduced
> on igb in QEMU. An AF_XDP socket in zero copy with 4K chunks and only
> the last chunk of the UMEM in the FILL ring, and an XDP program that
> adds 4 bytes of metadata, grows the tail to the end of the chunk and
> passes the packet:
>
> BUG: unable to handle page fault for address: ffa0000001048000
> RIP: 0010:memcpy+0xc/0x30
> igb_clean_rx_irq_zc+0x8a7/0x1520
> igb_poll+0x1039/0x4f50
>
> With this patch the same test passes.
>
> Fixes: 6dba29537c0f ("i40e: respect metadata on XSK Rx to skb")
> Fixes: f322a620be69 ("ixgbe: respect metadata on XSK Rx to skb")
> Fixes: f9e61d365baf ("igc: don't reserve excessive XDP_PACKET_HEADROOM on XSK Rx to skb")
> Fixes: 2c6196013f84 ("igb: Add AF_XDP zero-copy Rx support")
> Acked-by: Alexander Lobakin <aleksander.lobakin@intel.com>
> Signed-off-by: Björn Töpel <bjorn@kernel.org>
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> ---
> 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 +--
> 4 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
> index 5f5f33b2a097..03dd949a16b5 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
> @@ -308,8 +308,7 @@ static struct sk_buff *i40e_construct_skb_zc(struct i40e_ring *rx_ring,
> if (unlikely(!skb))
> goto out;
>
> - memcpy(__skb_put(skb, totalsize), xdp->data_meta,
> - ALIGN(totalsize, sizeof(long)));
> + memcpy(__skb_put(skb, totalsize), xdp->data_meta, totalsize);
>
> if (metasize) {
> skb_metadata_set(skb, metasize);
> diff --git a/drivers/net/ethernet/intel/igb/igb_xsk.c b/drivers/net/ethernet/intel/igb/igb_xsk.c
> index ce4a7b58cad2..aa00c36fe63f 100644
> --- a/drivers/net/ethernet/intel/igb/igb_xsk.c
> +++ b/drivers/net/ethernet/intel/igb/igb_xsk.c
> @@ -280,8 +280,7 @@ static struct sk_buff *igb_construct_skb_zc(struct igb_ring *rx_ring,
> if (timestamp)
> skb_hwtstamps(skb)->hwtstamp = timestamp;
>
> - memcpy(__skb_put(skb, totalsize), xdp->data_meta,
> - ALIGN(totalsize, sizeof(long)));
> + memcpy(__skb_put(skb, totalsize), xdp->data_meta, totalsize);
>
> if (metasize) {
> skb_metadata_set(skb, metasize);
> diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
> index 1fb5f3cbe93c..a3b153bbb081 100644
> --- a/drivers/net/ethernet/intel/igc/igc_main.c
> +++ b/drivers/net/ethernet/intel/igc/igc_main.c
> @@ -2749,8 +2749,7 @@ static struct sk_buff *igc_construct_skb_zc(struct igc_ring *ring,
> if (unlikely(!skb))
> return NULL;
>
> - memcpy(__skb_put(skb, totalsize), xdp->data_meta,
> - ALIGN(totalsize, sizeof(long)));
> + memcpy(__skb_put(skb, totalsize), xdp->data_meta, totalsize);
>
> if (metasize) {
> skb_metadata_set(skb, metasize);
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
> index 89f96c463f02..0d56466956c1 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
> @@ -224,8 +224,7 @@ static struct sk_buff *ixgbe_construct_skb_zc(struct ixgbe_ring *rx_ring,
> if (unlikely(!skb))
> return NULL;
>
> - memcpy(__skb_put(skb, totalsize), xdp->data_meta,
> - ALIGN(totalsize, sizeof(long)));
> + memcpy(__skb_put(skb, totalsize), xdp->data_meta, totalsize);
>
> if (metasize) {
> skb_metadata_set(skb, metasize);
> --
> 2.53.1-Meta
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH net v3 4/4] xsk: Keep the shared info of zero-copy buffers in kernel memory
2026-12-03 9:56 ` [PATCH net v3 4/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
@ 2026-12-03 15:16 ` Maciej Fijalkowski
2026-12-04 9:57 ` sashiko-bot
2026-12-04 10:39 ` netdev-bot+sashiko
2 siblings, 0 replies; 16+ messages in thread
From: Maciej Fijalkowski @ 2026-12-03 15:16 UTC (permalink / raw)
To: Björn Töpel
Cc: Magnus Karlsson, 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, bpf, Simon Horman, Stanislav Fomichev, Martin KaFai Lau,
Song Liu, Yonghong Song, Jiri Olsa, Emil Tsalapatis,
Ihor Solodrai, intel-wired-lan, Clément Lecigne,
Michal Swiatkowski, Sriram Yagnaraman, Kurt Kanzenbach
On Thu, Dec 03, 2026 at 10:56:45AM +0100, Björn Töpel wrote:
> A packet that a driver receives in zero-copy mode over several buffers
> keeps its shared info, the fragment list and its count, in the
> tailroom of the UMEM chunk of its head. Userspace may write the UMEM
> at any time, also while the kernel walks the fragments, and a
> rewritten list or count makes the kernel read and write out of bounds.
>
> Keep the shared info in the buffer pool, which outlives its buffers
> and the queues that point to it, and let the device write up to the
> end of the chunk. One shared info per pool is enough, as a pool builds
> one multi-buffer packet at a time.
>
> Buffers carry a flag for this, set again on every reuse, as drivers
> may clear the flags of the buffers they receive into.
>
> Multi-buffer pools now give the device the whole chunk, as
> single-buffer pools already do. Every UMEM accepts a larger headroom,
> also in copy mode, and bpf_xdp_adjust_tail() can grow a zero-copy
> packet up to the end of its chunk.
>
> A backport needs patches 1 to 3 of this series, which stop libeth and
> the skb builders from relying on the old layout.
>
> Found by an AI code review agent, in its review of another series. Not
> triggered at runtime.
>
> Suggested-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> Fixes: 24ea50127ecf ("xsk: support mbuf on ZC RX")
> Signed-off-by: Björn Töpel <bjorn@kernel.org>
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> ---
> 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/xdp/xdp_umem.c | 3 +--
> net/xdp/xsk_buff_pool.c | 20 ++++++++++++--------
> 6 files changed, 48 insertions(+), 37 deletions(-)
>
> diff --git a/include/net/xdp.h b/include/net/xdp.h
> index 07231adfb5f8..052402766988 100644
> --- a/include/net/xdp.h
> +++ b/include/net/xdp.h
> @@ -65,6 +65,10 @@ struct xdp_rxq_info {
> u32 reg_state;
> struct xdp_mem_info mem;
> u32 frag_size;
> + /* Shared info of buffers with %XDP_FLAGS_SINFO_EXT, in the XSk buffer
> + * pool, set by xsk_pool_set_rxq_info().
> + */
> + struct skb_shared_info *ext_sinfo;
> } ____cacheline_aligned; /* perf critical, avoid false-sharing */
>
> struct xdp_txq_info {
> @@ -81,6 +85,13 @@ enum xdp_buff_flags {
> * XDP program is not attached.
> */
> XDP_FLAGS_FRAGS_UNREADABLE = BIT(2),
> + /* The shared info lives in &xdp_rxq_info.ext_sinfo, not at the end of
> + * the frame, as userspace may write the frame. The frame reserves no
> + * tailroom, so the data may reach its end. The pool builds one such
> + * buffer at a time, so a consumer that uses the shared info later
> + * must copy what it needs.
> + */
> + XDP_FLAGS_SINFO_EXT = BIT(3),
> };
>
> struct xdp_buff {
> @@ -178,17 +189,26 @@ xdp_prepare_buff(struct xdp_buff *xdp, unsigned char *hard_start,
>
> /* Reserve memory area at end-of data area.
> *
> - * This macro reserves tailroom in the XDP buffer by limiting the
> - * XDP/BPF data access to data_hard_end. Notice same area (and size)
> - * is used for XDP_PASS, when constructing the SKB via build_skb().
> + * This reserves tailroom in the XDP buffer by limiting the XDP/BPF data
> + * access to data_hard_end. Notice same area (and size) is used for
> + * XDP_PASS, when constructing the SKB via build_skb(). Buffers with
> + * %XDP_FLAGS_SINFO_EXT keep the shared info elsewhere and reserve none.
> */
> -#define xdp_data_hard_end(xdp) \
> - ((xdp)->data_hard_start + (xdp)->frame_sz - \
> - SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
> +static __always_inline void *xdp_data_hard_end(const struct xdp_buff *xdp)
> +{
> + u32 tailroom = SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
> +
> + if (xdp->flags & XDP_FLAGS_SINFO_EXT)
> + tailroom = 0;
> + return xdp->data_hard_start + xdp->frame_sz - tailroom;
> +}
>
> static inline struct skb_shared_info *
> xdp_get_shared_info_from_buff(const struct xdp_buff *xdp)
> {
> + if (xdp->flags & XDP_FLAGS_SINFO_EXT)
> + return READ_ONCE(xdp->rxq)->ext_sinfo;
> +
> return (struct skb_shared_info *)xdp_data_hard_end(xdp);
> }
>
> diff --git a/include/net/xdp_sock_drv.h b/include/net/xdp_sock_drv.h
> index a40ad3f90f13..ec74bf3ffa51 100644
> --- a/include/net/xdp_sock_drv.h
> +++ b/include/net/xdp_sock_drv.h
> @@ -41,11 +41,6 @@ static inline u32 xsk_pool_get_headroom(struct xsk_buff_pool *pool)
> return XDP_PACKET_HEADROOM + pool->headroom;
> }
>
> -static inline u32 xsk_pool_get_tailroom(bool mbuf)
> -{
> - return mbuf ? SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) : 0;
> -}
> -
> static inline u32 xsk_pool_get_chunk_size(struct xsk_buff_pool *pool)
> {
> return pool->chunk_size;
> @@ -58,18 +53,7 @@ static inline u32 __xsk_pool_get_rx_frame_size(struct xsk_buff_pool *pool)
>
> static inline u32 xsk_pool_get_rx_frame_size(struct xsk_buff_pool *pool)
> {
> - u32 frame_size = __xsk_pool_get_rx_frame_size(pool);
> - struct xdp_umem *umem = pool->umem;
> - bool mbuf;
> -
> - /* Reserve tailroom only for zero-copy pools that opted into
> - * multi-buffer. The reserved area is used for skb_shared_info,
> - * matching the XDP core's xdp_data_hard_end() layout.
> - */
> - mbuf = pool->dev && (umem->flags & XDP_UMEM_SG_FLAG);
> - frame_size -= xsk_pool_get_tailroom(mbuf);
> -
> - return ALIGN_DOWN(frame_size, 128);
> + return ALIGN_DOWN(__xsk_pool_get_rx_frame_size(pool), 128);
> }
>
> static inline u32 xsk_pool_get_rx_frag_step(struct xsk_buff_pool *pool)
> @@ -152,7 +136,6 @@ static inline void xsk_buff_free(struct xdp_buff *xdp)
> xp_free(pos);
> }
>
> - xdp_get_shared_info_from_buff(xdp)->nr_frags = 0;
> xdp_buff_clear_frags_flag(xdp);
> out:
> xp_free(xskb);
> @@ -226,8 +209,11 @@ static inline void xsk_buff_set_size(struct xdp_buff *xdp, u32 size)
> xdp->data = xdp->data_hard_start + XDP_PACKET_HEADROOM;
> xdp->data_meta = xdp->data;
> xdp->data_end = xdp->data + size;
> - /* Frags flag is cleared when the frags of a head are released */
> - xdp->flags &= XDP_FLAGS_HAS_FRAGS;
> + /* Frags flag is cleared when the frags of a head are released. The
> + * shared info stays in the pool, see xp_set_rxq_info(), also for a
> + * buffer whose flags a driver cleared.
> + */
> + xdp->flags = (xdp->flags & XDP_FLAGS_HAS_FRAGS) | XDP_FLAGS_SINFO_EXT;
> }
>
> static inline dma_addr_t xsk_buff_raw_get_dma(struct xsk_buff_pool *pool,
> diff --git a/include/net/xsk_buff_pool.h b/include/net/xsk_buff_pool.h
> index 02e89350faf9..ef4bbf7f66b9 100644
> --- a/include/net/xsk_buff_pool.h
> +++ b/include/net/xsk_buff_pool.h
> @@ -95,6 +95,8 @@ struct xsk_buff_pool {
> * destructor callback.
> */
> spinlock_t cq_prod_lock;
> + /* Own cache lines, as zero-copy multi-buffer Rx writes it per packet */
> + struct skb_shared_info sinfo ____cacheline_aligned_in_smp;
> struct xdp_buff_xsk *free_heads[];
> };
>
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 53c042b267ab..3820c4edc14d 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -4510,7 +4510,7 @@ BPF_CALL_2(bpf_xdp_adjust_tail, struct xdp_buff *, xdp, int, offset)
> return bpf_xdp_frags_increase_tail(xdp, offset);
> }
>
> - /* Notice that xdp_data_hard_end have reserved some tailroom */
> + /* Notice that xdp_data_hard_end may have reserved some tailroom */
> if (unlikely(data_end > data_hard_end))
> return -EINVAL;
>
> diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c
> index ad72bd96905c..de8a2747ac9f 100644
> --- a/net/xdp/xdp_umem.c
> +++ b/net/xdp/xdp_umem.c
> @@ -195,8 +195,7 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr)
> if (!unaligned_chunks && chunks_rem)
> return -EINVAL;
>
> - if (headroom > chunk_size - XDP_PACKET_HEADROOM -
> - SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) - 128)
> + if (headroom > chunk_size - XDP_PACKET_HEADROOM - 128)
> return -EINVAL;
>
> if (mr->flags & XDP_UMEM_TX_METADATA_LEN) {
> diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
> index 5ec092f7cb6f..28bdc63551bf 100644
> --- a/net/xdp/xsk_buff_pool.c
> +++ b/net/xdp/xsk_buff_pool.c
> @@ -107,6 +107,7 @@ struct xsk_buff_pool *xp_create_and_assign_umem(struct xdp_sock *xs,
> xskb = &pool->heads[i];
> xskb->pool = pool;
> xskb->xdp.frame_sz = umem->chunk_size - umem->headroom;
> + xskb->xdp.flags = XDP_FLAGS_SINFO_EXT;
> INIT_LIST_HEAD(&xskb->list_node);
> if (pool->unaligned)
> pool->free_heads[i] = xskb;
> @@ -125,8 +126,15 @@ void xp_set_rxq_info(struct xsk_buff_pool *pool, struct xdp_rxq_info *rxq)
> {
> u32 i;
>
> + /* Userspace may write the UMEM. Keep the shared info in the pool,
> + * and let the device write up to the end of each chunk. A NAPI may
> + * still run on the buffers, so publish the shared info first.
> + */
> + rxq->ext_sinfo = &pool->sinfo;
> + /* Pairs with READ_ONCE(xdp->rxq) in xdp_get_shared_info_from_buff() */
> + smp_wmb();
> for (i = 0; i < pool->heads_cnt; i++)
> - pool->heads[i].xdp.rxq = rxq;
> + WRITE_ONCE(pool->heads[i].xdp.rxq, rxq);
> }
> EXPORT_SYMBOL(xp_set_rxq_info);
>
> @@ -229,12 +237,7 @@ int xp_assign_dev(struct xsk_buff_pool *pool,
> segs = 1;
> }
>
> - /* open-code xsk_pool_get_rx_frame_size() as pool->dev is not
> - * set yet at this point; we are before getting down to driver
> - */
> - frame_size = __xsk_pool_get_rx_frame_size(pool) -
> - xsk_pool_get_tailroom(mbuf);
> - frame_size = ALIGN_DOWN(frame_size, 128);
> + frame_size = xsk_pool_get_rx_frame_size(pool);
>
> if (needed > frame_size * segs) {
> err = -EINVAL;
> @@ -629,7 +632,8 @@ struct xdp_buff *xp_alloc(struct xsk_buff_pool *pool)
>
> xskb->xdp.data = xskb->xdp.data_hard_start + XDP_PACKET_HEADROOM;
> xskb->xdp.data_meta = xskb->xdp.data;
> - xskb->xdp.flags &= XDP_FLAGS_HAS_FRAGS;
> + xskb->xdp.flags = (xskb->xdp.flags & XDP_FLAGS_HAS_FRAGS) |
> + XDP_FLAGS_SINFO_EXT;
>
> if (pool->dev)
> xp_dma_sync_for_device(pool, xskb->dma, pool->frame_len);
> --
> 2.53.1-Meta
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH net v3 4/4] xsk: Keep the shared info of zero-copy buffers in kernel memory
2026-12-03 9:56 ` [PATCH net v3 4/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-12-03 15:16 ` Maciej Fijalkowski
@ 2026-12-04 9:57 ` sashiko-bot
2026-12-04 10:39 ` netdev-bot+sashiko
2 siblings, 0 replies; 16+ messages in thread
From: sashiko-bot @ 2026-12-04 9:57 UTC (permalink / raw)
To: Björn Töpel, bpf; +Cc: intel-wired-lan
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] xsk: order-1 kmalloc demotion on 4K multi-buffer XDP_PASS skb
heads
--
commit 398e24a8ed1c684ab049fa90f5ec27a7ab098093
Author: Björn Töpel <bjorn@kernel.org>
xsk: Keep the shared info of zero-copy buffers in kernel memory
This commit moves skb_shared_info for zero-copy XSK buffers out of UMEM
tailroom into struct xsk_buff_pool, marks those buffers with
XDP_FLAGS_SINFO_EXT, and stops reserving tailroom in
xsk_pool_get_rx_frame_size() and xdp_umem_reg().
> diff --git a/include/net/xdp_sock_drv.h b/include/net/xdp_sock_drv.h
> index a40ad3f90f13c..ec74bf3ffa510 100644
> --- a/include/net/xdp_sock_drv.h
> +++ b/include/net/xdp_sock_drv.h
[ ... ]
> @@ -58,18 +53,7 @@ static inline u32 __xsk_pool_get_rx_frame_size(struct xsk_buff_pool *pool)
>
> static inline u32 xsk_pool_get_rx_frame_size(struct xsk_buff_pool *pool)
> {
> - u32 frame_size = __xsk_pool_get_rx_frame_size(pool);
> - struct xdp_umem *umem = pool->umem;
> - bool mbuf;
> -
> - /* Reserve tailroom only for zero-copy pools that opted into
> - * multi-buffer. The reserved area is used for skb_shared_info,
> - * matching the XDP core's xdp_data_hard_end() layout.
> - */
> - mbuf = pool->dev && (umem->flags & XDP_UMEM_SG_FLAG);
> - frame_size -= xsk_pool_get_tailroom(mbuf);
> -
> - return ALIGN_DOWN(frame_size, 128);
> + return ALIGN_DOWN(__xsk_pool_get_rx_frame_size(pool), 128);
> }
[Severity: Medium]
Does removing the tailroom subtraction here demote 4K-chunk multi-buffer
XDP_PASS skb head allocations to order-1 kmalloc-8k?
With 4096-byte UMEM chunks and zero headroom, xsk_pool_get_rx_frame_size()
grows from 3456 to 3840 bytes. On idpf (via libeth_xskfq_create()), a
multi-buffer jumbo packet returning XDP_PASS passes a 4096-byte head
(XDP_PACKET_HEADROOM + 3840) to xdp_zc_alloc_head():
net/core/xdp.c:xdp_zc_alloc_head() {
u32 truesize = SKB_HEAD_ALIGN(size);
...
if (truesize > PAGE_SIZE)
return __netdev_alloc_skb(dev, size, GFP_ATOMIC | __GFP_NOWARN);
}
Because SKB_HEAD_ALIGN(4096) is 4416 bytes (versus 4032 bytes before),
every such packet now bypasses system_page_pool and falls back to
__netdev_alloc_skb(), which exceeds SKB_WITH_OVERHEAD(PAGE_SIZE) and
allocates from kmalloc-8k instead of recycled order-0 pages.
This doubles the skb head memory footprint, loses page-pool recycling, and
risks GFP_ATOMIC order-1 allocation failures under memory fragmentation.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203095647.3448925-1-bjorn@kernel.org?part=4
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH net v3 1/4] libeth: xsk: Count each XDP_TX buffer on its own
2026-12-03 9:56 ` [PATCH net v3 1/4] libeth: xsk: Count each XDP_TX buffer on its own Björn Töpel
@ 2026-12-04 10:39 ` netdev-bot+sashiko
2026-12-04 14:08 ` Björn Töpel
0 siblings, 1 reply; 16+ messages in thread
From: netdev-bot+sashiko @ 2026-12-04 10:39 UTC (permalink / raw)
To: bjorn
Cc: magnus.karlsson, maciej.fijalkowski, aleksander.lobakin, ast,
daniel, hawk, john.fastabend, andrii, eddyz87, memxor, davem,
edumazet, kuba, pabeni, willemb, andrew+netdev, anthony.l.nguyen,
przemyslaw.kitszel, netdev, bpf, horms, sdf, martin.lau, song,
yonghong.song, jolsa, emil, ihor.solodrai, intel-wired-lan,
clecigne, michal.swiatkowski, sriram.yagnaraman, kurt
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The in-flight XDP_TX count uses opposite signs on the two sides,
so this patch does not fix the count it is meant to fix.
- [Low] The commit message names two causes for the wrong XSk XDP_TX in-
flight count: userspace rewriting the shared info in the UMEM, and a…
--
libeth: xsk: Count each XDP_TX buffer on its own
This commit changes libeth so that each XSk XDP_TX SQE counts one
completed buffer and its own byte length. It no longer reads the frame's
shared info at bulk flush time, because that shared info lives in the UMEM
and can change before the flush. The goal is to keep the idpf in-flight
XDP_TX count on XSk queues correct.
> libeth takes the number of buffers of an XSk XDP_TX frame from its
> shared info, and reports that many completed buffers to the driver. It
> reads the shared info when it flushes the bulk, not when it queues the
> frame. The shared info of a zero-copy buffer lives in the UMEM, which
> userspace may write at any time, so a rewritten count makes libeth
> report a wrong number.
[ ... ]
> Make libeth count each buffer on its own SQE. Head and fragments each
> count one completed buffer, and the head counts the packet. Stats stay
> the same for frames sent in full.
>
> Found by an AI agent while reviewing this code. Not triggered at
> runtime.
[Severity: Low]
This isn't a bug, but should the message mention another trigger? It needs
no userspace action and was reachable before this patch: a multi-buffer
XSk XDP_TX frame that is only partly sent when the XDPSQ ring is full.
libeth_xdp_tx_xmit_bulk() limits the send to the free ring space and only
counts what it wrote:
n = min(n, prep(xdpsq, &sq));
...
if (sq.xdp_tx)
*sq.xdp_tx += n;
__libeth_xdp_finalize_rx() then does the final flush with drop set:
if (bq->count)
flush_bulk(bq, flags | LIBETH_XDP_TX_DROP);
libeth_xdp_tx_exception() then drops the unsent tail through
libeth_xsk_tx_return_bulk(). That tail can include trailing frags of a
frame whose head was already sent.
Before this patch, the head SQE's nr_frags covered the whole frame
(1 + sinfo->nr_frags), and frag SQEs counted nothing. So the in-flight
count was off by the number of dropped frags.
The per-SQE counting in this patch also covers that case. The message only
hints at it with "Stats stay the same for frames sent in full". Bytes
reported for a partly sent frame also change, from the full frame size to
the sum of the buffers that were sent.
Could the message describe this path, since normal load can reach it?
> diff --git a/include/net/libeth/xdp.h b/include/net/libeth/xdp.h
> index 898723ab62e81..66a3c4ec9967e 100644
> --- a/include/net/libeth/xdp.h
> +++ b/include/net/libeth/xdp.h
> @@ -1794,12 +1794,19 @@ __libeth_xdp_complete_tx(struct libeth_sqe *sqe, struct libeth_cq_pp *cp,
> switch (type) {
> case LIBETH_SQE_XDP_TX:
> case LIBETH_SQE_XDP_XMIT:
> - case LIBETH_SQE_XSK_TX:
> cp->xdp_tx -= sqe->nr_frags;
>
> cp->xss->packets++;
> cp->xss->bytes += sqe->bytes;
> break;
> + case LIBETH_SQE_XSK_TX:
> + cp->xss->packets++;
> + fallthrough;
> + case LIBETH_SQE_XSK_TX_FRAG:
> + /* One buffer per SQE, see libeth_xsk_tx_fill_buf() */
> + cp->xdp_tx--;
[Severity: High]
Does this decrement move the idpf in-flight count the wrong way?
cp.xdp_tx is a u32, and idpf starts it at 0 because its initializer does
not set the field. idpf then expects a positive count of completed
buffers:
drivers/net/ethernet/intel/idpf/xsk.c:idpf_xsksq_complete_slow() {
struct libeth_cq_pp cp = {
.dev = xdpsq->pool->dev,
.bq = &bq,
.xss = &ss,
.napi = true,
};
...
xdpsq->xdp_tx -= cp.xdp_tx;
}
idpf_xdpsq_complete() in idpf/xdp.c works the same way. The kernel-doc
for struct libeth_cq_pp also describes @xdp_tx as "number of XDP-not-XSk
frames processed".
After k XSk XDP_TX completions, cp.xdp_tx is 2^32 - k. The subtraction in
idpf therefore adds k to xdpsq->xdp_tx. The send side in
libeth_xdp_tx_xmit_bulk() also adds to it:
if (sq.xdp_tx)
*sq.xdp_tx += n;
So the count goes up by two for each XDP_TX buffer and does not get back
to 0.
Would that stop idpf_xsksq_complete() from ever taking its fast path
again?
if (likely(!xdpsq->xdp_tx)) {
...
xsk_frames = done_frames;
goto finalize;
}
After about 2^31 XDP_TX buffers the u32 can wrap to exactly 0 while
XDP_TX SQEs are still in flight. In that case, can those SQEs be reported
through xsk_tx_completed() as XSk xmit frames? libeth_xdp_complete_tx()
would never be called for them.
Their UMEM buffers would not be freed. The SQEs would keep
LIBETH_SQE_XSK_TX as their type and a stale xsk pointer. That seems to be
the same "idpf may then complete XDP_TX buffers as XSk xmit frames" result
the commit message says this patch prevents.
The existing cp->xdp_tx -= sqe->nr_frags for LIBETH_SQE_XDP_TX and
LIBETH_SQE_XDP_XMIT uses the same sign, and the new branch copies it.
Should this fix change the sign on one side, either in the libeth
completion code or in the idpf consumers? No later patch in the series
appears to touch include/net/libeth/ or drivers/net/ethernet/intel/idpf/.
> + cp->xss->bytes += sqe->bytes;
> + break;
> default:
> break;
> }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203095647.3448925-1-bjorn%40kernel.org
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH net v3 2/4] xdp: Size zero-copy skbs from the data, not the frame size
2026-12-03 9:56 ` [PATCH net v3 2/4] xdp: Size zero-copy skbs from the data, not the frame size Björn Töpel
2026-12-03 14:04 ` Maciej Fijalkowski
@ 2026-12-04 10:39 ` netdev-bot+sashiko
2026-12-04 14:09 ` Björn Töpel
1 sibling, 1 reply; 16+ messages in thread
From: netdev-bot+sashiko @ 2026-12-04 10:39 UTC (permalink / raw)
To: bjorn
Cc: magnus.karlsson, maciej.fijalkowski, aleksander.lobakin, ast,
daniel, hawk, john.fastabend, andrii, eddyz87, memxor, davem,
edumazet, kuba, pabeni, willemb, andrew+netdev, anthony.l.nguyen,
przemyslaw.kitszel, netdev, bpf, horms, sdf, martin.lau, song,
yonghong.song, jolsa, emil, ihor.solodrai, intel-wired-lan,
clecigne, michal.swiatkowski, sriram.yagnaraman, kurt
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message understates how much of the shared info the
old xdp_build_skb_from_zc() let a sender overwrite.
--
xdp: Size zero-copy skbs from the data, not the frame size
This patch changes how xdp_build_skb_from_zc() sizes the skb head. It now
uses data_end - data_hard_start instead of the XSk frame size, so packet
data can no longer overwrite the skb_shared_info. It also copies the exact
head and fragment lengths instead of rounding them up with LARGEST_ALIGN().
Heads larger than a page now come from __netdev_alloc_skb().
Link: https://lore.kernel.org/bpf/20260629072300.1664622-1-clecigne@google.com/
> With 2K chunks, no UMEM
> headroom and the default MTU, a 1514 byte frame that XDP passes on
> ice, idpf or gve needs 256 + 1514 + 320 = 2090 bytes and gets 2048.
> The sender controls up to 48 bytes of the shared info, its frag list
> among them.
[Severity: Low]
Is "up to 48 bytes" the real upper bound, or only the overflow for this
example? The 48 bytes come from 1514 rounded up to 1520 by LARGEST_ALIGN():
256 + 1520 + 320 - 2048 = 48.
For single-buffer pools, xsk_pool_get_rx_frame_size() subtracts the shared
info tailroom only for multi-buffer pools:
include/net/xdp_sock_drv.h:xsk_pool_get_rx_frame_size() {
...
mbuf = pool->dev && (umem->flags & XDP_UMEM_SG_FLAG);
frame_size -= xsk_pool_get_tailroom(mbuf);
return ALIGN_DOWN(frame_size, 128);
}
xp_create_and_assign_umem() sets frame_sz to the whole chunk:
xskb->xdp.frame_sz = umem->chunk_size - umem->headroom;
The commit message says a device may fill a single-buffer frame to its
end. In that case data_end - data_hard_start can equal frame_sz. One
example is a 2K chunk whose 1792 byte rx buffer is filled after a raised
MTU. Another is 4K chunks with 3840 byte frames.
The old code built the head with napi_build_skb(data, xdp->frame_sz). That
left only frame_sz - 320 bytes of linear room. So the copy would overwrite
all of SKB_DATA_ALIGN(sizeof(struct skb_shared_info)), which is 320 bytes
on x86_64, including frags[]. With 4K chunks, the LARGEST_ALIGN() rounding
could also write past the page handed out by the system page pool.
The sender also controls more than the frag list in the first 48 bytes.
The flags, nr_frags, frag_list, dataref and destructor_arg fields all sit
there. A chosen SKBFL_ZEROCOPY_* flag combined with a chosen
destructor_arg gives a callback pointer.
Could the commit message give the worst case as the whole shared info
rather than 48 bytes? The code change closes the whole overflow. Only the
stated impact looks understated.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203095647.3448925-1-bjorn%40kernel.org
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH net v3 4/4] xsk: Keep the shared info of zero-copy buffers in kernel memory
2026-12-03 9:56 ` [PATCH net v3 4/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-12-03 15:16 ` Maciej Fijalkowski
2026-12-04 9:57 ` sashiko-bot
@ 2026-12-04 10:39 ` netdev-bot+sashiko
2026-12-04 14:12 ` Björn Töpel
2 siblings, 1 reply; 16+ messages in thread
From: netdev-bot+sashiko @ 2026-12-04 10:39 UTC (permalink / raw)
To: bjorn
Cc: magnus.karlsson, maciej.fijalkowski, aleksander.lobakin, ast,
daniel, hawk, john.fastabend, andrii, eddyz87, memxor, davem,
edumazet, kuba, pabeni, willemb, andrew+netdev, anthony.l.nguyen,
przemyslaw.kitszel, netdev, bpf, horms, sdf, martin.lau, song,
yonghong.song, jolsa, emil, ihor.solodrai, intel-wired-lan,
clecigne, michal.swiatkowski, sriram.yagnaraman, kurt
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message understates the bug it fixes.
- [Low] The AF_XDP selftests still model the old UMEM layout, in which ZC
multi-buffer pools reserved skb_shared_info tailroom at the end of…
--
xsk: Keep the shared info of zero-copy buffers in kernel memory
This moves the skb_shared_info of zero-copy multi-buffer packets out of the
user-writable UMEM chunk tailroom and into the xsk_buff_pool. A new
XDP_FLAGS_SINFO_EXT flag tells xdp_get_shared_info_from_buff() to use
rxq->ext_sinfo, and xdp_data_hard_end() then reserves no tailroom. The
UMEM headroom limit in xdp_umem_reg() is relaxed to match.
> A packet that a driver receives in zero-copy mode over several buffers
> keeps its shared info, the fragment list and its count, in the
> tailroom of the UMEM chunk of its head. Userspace may write the UMEM
> at any time, also while the kernel walks the fragments, and a
> rewritten list or count makes the kernel read and write out of bounds.
[Severity: Low]
Does "read and write out of bounds" fully describe the impact?
Before this patch, xdp_get_shared_info_from_buff() returned a pointer into
the UMEM chunk tailroom for a zero-copy head. Each skb_frag_t stored there
holds a netmem_ref plus len and offset. That means userspace could forge
the page pointer, the length and the offset, not just nr_frags.
The consumers use those values directly. xdp_copy_frags_from_zc() does:
memcpy(page_address(page) + offset, skb_frag_address(frag),
len);
This copies from a kernel address that userspace chooses into an skb that
is passed up the stack. bpf_xdp_frags_increase_tail() does:
memset(skb_frag_address(frag) + skb_frag_size(frag), 0, offset);
This writes at an address that userspace chooses.
__xdp_buff_add_frag() also reads nr_frags back from the UMEM. It only
rejects nr_frags == MAX_SKB_FRAGS, so a forged count of up to 255 sends
the frags[] write far past the chunk.
This gives userspace a kernel read and write at addresses it picks, not an
access limited to the area next to the chunk. To reach it you need
ns_capable(CAP_NET_RAW) in xsk_create(), a netdev that supports zero-copy,
and an AF_XDP socket bound with XDP_USE_SG in zero-copy mode.
Could the commit message state the real impact and the privilege needed?
Stable reviewers and backporters use that to triage. The patch also relaxes
the headroom check in xdp_umem_reg(), so they need it to weigh that change.
> diff --git a/include/net/xdp.h b/include/net/xdp.h
> index 07231adfb5f82..0524027669882 100644
> --- a/include/net/xdp.h
> +++ b/include/net/xdp.h
[ ... ]
> @@ -178,17 +189,26 @@ xdp_prepare_buff(struct xdp_buff *xdp, unsigned char *hard_start,
[ ... ]
> -#define xdp_data_hard_end(xdp) \
> - ((xdp)->data_hard_start + (xdp)->frame_sz - \
> - SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
> +static __always_inline void *xdp_data_hard_end(const struct xdp_buff *xdp)
> +{
> + u32 tailroom = SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
> +
> + if (xdp->flags & XDP_FLAGS_SINFO_EXT)
> + tailroom = 0;
> + return xdp->data_hard_start + xdp->frame_sz - tailroom;
> +}
[Severity: Low]
Should the AF_XDP selftests be updated along with this layout change?
They still assume that zero-copy multi-buffer chunks reserve
skb_shared_info tailroom at the end. test_xsk() in prog_tests/xsk.c and
main() in xskxceiver.c both compute:
/* 48 bytes is a part of skb_shared_info w/o frags array;
* 16 bytes is sizeof(skb_frag_t)
*/
umem_tailroom = ALIGN(48 + (max_frags * 16), cache_line_size);
In prog_tests/test_xsk.c, testapp_adjust_tail_grow_mb() still has the
comment "4k is truesize, 3k payload, 256 HR, 320 TR". It also subtracts
umem_tailroom from grow_size.
testapp_stats_rx_dropped() subtracts umem_tr when it sets frame_headroom.
That lands exactly on the old xdp_umem_reg() limit
(4096 - 256 - 128 - 320 = 3392).
These sizes are conservative, so the tests still pass. However, no test
covers a zero-copy bpf_xdp_adjust_tail() grow up to the end of the chunk.
No test uses a UMEM headroom above the old limit either.
Wouldn't these tests pass just the same if the kernel still reserved the
tailroom?
>
> static inline struct skb_shared_info *
> xdp_get_shared_info_from_buff(const struct xdp_buff *xdp)
> {
> + if (xdp->flags & XDP_FLAGS_SINFO_EXT)
> + return READ_ONCE(xdp->rxq)->ext_sinfo;
> +
> return (struct skb_shared_info *)xdp_data_hard_end(xdp);
> }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203095647.3448925-1-bjorn%40kernel.org
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH net v3 1/4] libeth: xsk: Count each XDP_TX buffer on its own
2026-12-04 10:39 ` netdev-bot+sashiko
@ 2026-12-04 14:08 ` Björn Töpel
0 siblings, 0 replies; 16+ messages in thread
From: Björn Töpel @ 2026-12-04 14:08 UTC (permalink / raw)
To: netdev-bot+sashiko
Cc: magnus.karlsson, maciej.fijalkowski, aleksander.lobakin, ast,
daniel, hawk, john.fastabend, andrii, eddyz87, memxor, davem,
edumazet, kuba, pabeni, willemb, andrew+netdev, anthony.l.nguyen,
przemyslaw.kitszel, netdev, bpf, horms, sdf, martin.lau, song,
yonghong.song, jolsa, emil, ihor.solodrai, intel-wired-lan,
clecigne, michal.swiatkowski, sriram.yagnaraman, kurt
netdev-bot+sashiko@kernel.org writes:
> Thank you for your contribution! Sashiko AI review found 2 potential
> issue(s) to consider.
>
> Critical: 0 · High: 1 · Medium: 0 · Low: 1
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
>
> - [High] The in-flight XDP_TX count uses opposite signs on the two sides,
> so this patch does not fix the count it is meant to fix.
Sigh... OK, I'm convinced. :-) See below.
> [Severity: Low]
> This isn't a bug, but should the message mention another trigger? It needs
> no userspace action and was reachable before this patch: a multi-buffer
> XSk XDP_TX frame that is only partly sent when the XDPSQ ring is full.
[...]
> Could the message describe this path, since normal load can reach it?
Ok
> [Severity: High]
> Does this decrement move the idpf in-flight count the wrong way?
[...]
> Should this fix change the sign on one side, either in the libeth
> completion code or in the idpf consumers? No later patch in the series
> appears to touch include/net/libeth/ or drivers/net/ethernet/intel/idpf/.
In v1 I said the sign was an older bug and that a fix was outside this
series. But this patch only does what it says once the sign is right,
and the two changes touch the same lines, so splitting them just means
that whichever lands second has to flip the other one.
So I'll add the sign fix as patch 1. libeth then counts completed
buffers up, like its kernel-doc says, and this patch does cp->xdp_tx++.
idpf is the only user, and it only reads the count on XSk queues. I
don't have idpf hardware, so patch 1 is build-tested only.
I hope Olek can help me out here.
Björn
pw-bot: cr
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH net v3 2/4] xdp: Size zero-copy skbs from the data, not the frame size
2026-12-04 10:39 ` netdev-bot+sashiko
@ 2026-12-04 14:09 ` Björn Töpel
0 siblings, 0 replies; 16+ messages in thread
From: Björn Töpel @ 2026-12-04 14:09 UTC (permalink / raw)
To: netdev-bot+sashiko
Cc: magnus.karlsson, maciej.fijalkowski, aleksander.lobakin, ast,
daniel, hawk, john.fastabend, andrii, eddyz87, memxor, davem,
edumazet, kuba, pabeni, willemb, andrew+netdev, anthony.l.nguyen,
przemyslaw.kitszel, netdev, bpf, horms, sdf, martin.lau, song,
yonghong.song, jolsa, emil, ihor.solodrai, intel-wired-lan,
clecigne, michal.swiatkowski, sriram.yagnaraman, kurt
netdev-bot+sashiko@kernel.org writes:
> [Severity: Low]
> Is "up to 48 bytes" the real upper bound, or only the overflow for this
> example?
[...]
> Could the commit message give the worst case as the whole shared info
> rather than 48 bytes? The code change closes the whole overflow. Only the
> stated impact looks understated.
Fair enough, I'll tweak, since a v4 is coming.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH net v3 4/4] xsk: Keep the shared info of zero-copy buffers in kernel memory
2026-12-04 10:39 ` netdev-bot+sashiko
@ 2026-12-04 14:12 ` Björn Töpel
0 siblings, 0 replies; 16+ messages in thread
From: Björn Töpel @ 2026-12-04 14:12 UTC (permalink / raw)
To: netdev-bot+sashiko
Cc: magnus.karlsson, maciej.fijalkowski, aleksander.lobakin, ast,
daniel, hawk, john.fastabend, andrii, eddyz87, memxor, davem,
edumazet, kuba, pabeni, willemb, andrew+netdev, anthony.l.nguyen,
przemyslaw.kitszel, netdev, bpf, horms, sdf, martin.lau, song,
yonghong.song, jolsa, emil, ihor.solodrai, intel-wired-lan,
clecigne, michal.swiatkowski, sriram.yagnaraman, kurt
netdev-bot+sashiko@kernel.org writes:
> [Severity: Low]
> Should the AF_XDP selftests be updated along with this layout change?
[...]
> Wouldn't these tests pass just the same if the kernel still reserved the
> tailroom?
They would, yes. They're conservative, so they pass on both layouts.
We'll add selftest update goes to net-next once this is in net, like
Maciej asked back in v2. It drops the old tailroom math and adds a
zero-copy bpf_xdp_adjust_tail() grow up to the end of the chunk, plus a
UMEM headroom above the old limit.
Björn
^ permalink raw reply [flat|nested] 16+ messages in thread
* RE: [PATCH net v3 3/4] intel: Copy the exact length of XSk packets to skbs
2026-12-03 9:56 ` [PATCH net v3 3/4] intel: Copy the exact length of XSk packets to skbs Björn Töpel
2026-12-03 14:07 ` Maciej Fijalkowski
@ 2026-12-04 14:51 ` Loktionov, Aleksandr
1 sibling, 0 replies; 16+ messages in thread
From: Loktionov, Aleksandr @ 2026-12-04 14:51 UTC (permalink / raw)
To: Björn Töpel, Karlsson, Magnus, Fijalkowski, Maciej,
Lobakin, Aleksander, 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, Nguyen, Anthony L, Kitszel, Przemyslaw,
netdev@vger.kernel.org, bpf@vger.kernel.org
Cc: Simon Horman, Stanislav Fomichev, Martin KaFai Lau, Song Liu,
Yonghong Song, Jiri Olsa, Emil Tsalapatis, Ihor Solodrai,
intel-wired-lan@lists.osuosl.org, Clément Lecigne,
Michal Swiatkowski, Sriram Yagnaraman, Kurt Kanzenbach
> -----Original Message-----
> From: Björn Töpel <bjorn@kernel.org>
> Sent: Thursday, December 3, 2026 10:57 AM
> To: Karlsson, Magnus <magnus.karlsson@intel.com>; Fijalkowski, Maciej
> <maciej.fijalkowski@intel.com>; Lobakin, Aleksander
> <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>;
> Nguyen, Anthony L <anthony.l.nguyen@intel.com>; Kitszel, Przemyslaw
> <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>
> Subject: [PATCH net v3 3/4] intel: Copy the exact length of XSk packets
> to skbs
>
> i40e, igb, igc and ixgbe copy an XSk zero-copy packet that the XDP
> program passes into a new skb, and round the length of the copy up to a
> multiple of 8 bytes. The copy then reads up to 7 bytes past the end of
> the data. When the data ends at the end of the last chunk of the UMEM,
> the read hits the guard page after the UMEM mapping and faults.
>
> On i40e the device can already fill a single-buffer chunk to its end.
> The last patch of this series lets multi-buffer pools and
> bpf_xdp_adjust_tail() reach the end of a chunk on all four.
>
> Copy the exact length.
>
> Found by an AI code review agent in review of this series. Reproduced on
> igb in QEMU. An AF_XDP socket in zero copy with 4K chunks and only the
> last chunk of the UMEM in the FILL ring, and an XDP program that adds 4
> bytes of metadata, grows the tail to the end of the chunk and passes the
> packet:
>
> BUG: unable to handle page fault for address: ffa0000001048000
> RIP: 0010:memcpy+0xc/0x30
> igb_clean_rx_irq_zc+0x8a7/0x1520
> igb_poll+0x1039/0x4f50
>
> With this patch the same test passes.
>
> Fixes: 6dba29537c0f ("i40e: respect metadata on XSK Rx to skb")
> Fixes: f322a620be69 ("ixgbe: respect metadata on XSK Rx to skb")
> Fixes: f9e61d365baf ("igc: don't reserve excessive XDP_PACKET_HEADROOM
> on XSK Rx to skb")
> Fixes: 2c6196013f84 ("igb: Add AF_XDP zero-copy Rx support")
> Acked-by: Alexander Lobakin <aleksander.lobakin@intel.com>
> Signed-off-by: Björn Töpel <bjorn@kernel.org>
> ---
> 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 +--
> 4 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c
> b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
> index 5f5f33b2a097..03dd949a16b5 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
> @@ -308,8 +308,7 @@ static struct sk_buff *i40e_construct_skb_zc(struct
> i40e_ring *rx_ring,
> if (unlikely(!skb))
> goto out;
>
> - memcpy(__skb_put(skb, totalsize), xdp->data_meta,
> - ALIGN(totalsize, sizeof(long)));
> + memcpy(__skb_put(skb, totalsize), xdp->data_meta, totalsize);
>
> if (metasize) {
> skb_metadata_set(skb, metasize);
> diff --git a/drivers/net/ethernet/intel/igb/igb_xsk.c
> b/drivers/net/ethernet/intel/igb/igb_xsk.c
> index ce4a7b58cad2..aa00c36fe63f 100644
> --- a/drivers/net/ethernet/intel/igb/igb_xsk.c
> +++ b/drivers/net/ethernet/intel/igb/igb_xsk.c
> @@ -280,8 +280,7 @@ static struct sk_buff *igb_construct_skb_zc(struct
> igb_ring *rx_ring,
> if (timestamp)
> skb_hwtstamps(skb)->hwtstamp = timestamp;
>
> - memcpy(__skb_put(skb, totalsize), xdp->data_meta,
> - ALIGN(totalsize, sizeof(long)));
> + memcpy(__skb_put(skb, totalsize), xdp->data_meta, totalsize);
>
> if (metasize) {
> skb_metadata_set(skb, metasize);
> diff --git a/drivers/net/ethernet/intel/igc/igc_main.c
> b/drivers/net/ethernet/intel/igc/igc_main.c
> index 1fb5f3cbe93c..a3b153bbb081 100644
> --- a/drivers/net/ethernet/intel/igc/igc_main.c
> +++ b/drivers/net/ethernet/intel/igc/igc_main.c
> @@ -2749,8 +2749,7 @@ static struct sk_buff *igc_construct_skb_zc(struct
> igc_ring *ring,
> if (unlikely(!skb))
> return NULL;
>
> - memcpy(__skb_put(skb, totalsize), xdp->data_meta,
> - ALIGN(totalsize, sizeof(long)));
> + memcpy(__skb_put(skb, totalsize), xdp->data_meta, totalsize);
>
> if (metasize) {
> skb_metadata_set(skb, metasize);
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
> b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
> index 89f96c463f02..0d56466956c1 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
> @@ -224,8 +224,7 @@ static struct sk_buff *ixgbe_construct_skb_zc(struct
> ixgbe_ring *rx_ring,
> if (unlikely(!skb))
> return NULL;
>
> - memcpy(__skb_put(skb, totalsize), xdp->data_meta,
> - ALIGN(totalsize, sizeof(long)));
> + memcpy(__skb_put(skb, totalsize), xdp->data_meta, totalsize);
>
> if (metasize) {
> skb_metadata_set(skb, metasize);
> --
> 2.53.1-Meta
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2026-12-04 14:51 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 9:56 [PATCH net v3 0/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-12-03 9:56 ` [PATCH net v3 1/4] libeth: xsk: Count each XDP_TX buffer on its own Björn Töpel
2026-12-04 10:39 ` netdev-bot+sashiko
2026-12-04 14:08 ` Björn Töpel
2026-12-03 9:56 ` [PATCH net v3 2/4] xdp: Size zero-copy skbs from the data, not the frame size Björn Töpel
2026-12-03 14:04 ` Maciej Fijalkowski
2026-12-04 10:39 ` netdev-bot+sashiko
2026-12-04 14:09 ` Björn Töpel
2026-12-03 9:56 ` [PATCH net v3 3/4] intel: Copy the exact length of XSk packets to skbs Björn Töpel
2026-12-03 14:07 ` Maciej Fijalkowski
2026-12-04 14:51 ` Loktionov, Aleksandr
2026-12-03 9:56 ` [PATCH net v3 4/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-12-03 15:16 ` Maciej Fijalkowski
2026-12-04 9:57 ` sashiko-bot
2026-12-04 10:39 ` netdev-bot+sashiko
2026-12-04 14:12 ` Björn Töpel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox