BPF 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>,
	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>,
	intel-wired-lan@lists.osuosl.org,
	"Clément Lecigne" <clecigne@google.com>
Subject: [PATCH net v2 3/4] intel: Copy the exact length of XSk packets to skbs
Date: Mon, 30 Nov 2026 13:37:34 +0100	[thread overview]
Message-ID: <20261130123737.125432-4-bjorn@kernel.org> (raw)
In-Reply-To: <20261130123737.125432-1-bjorn@kernel.org>

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")
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.56.1


  parent reply	other threads:[~2026-11-30 12:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 12:37 [PATCH net v2 0/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-11-30 12:37 ` [PATCH net v2 1/4] libeth: xsk: Count each XDP_TX buffer on its own Björn Töpel
2026-11-30 12:37 ` [PATCH net v2 2/4] xdp: Size zero-copy skbs from the data, not the frame size Björn Töpel
2026-11-30 12:37 ` Björn Töpel [this message]
2026-11-30 12:37 ` [PATCH net v2 4/4] 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=20261130123737.125432-4-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=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=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=song@kernel.org \
    --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