From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: "Björn Töpel" <bjorn@kernel.org>
Cc: "Magnus Karlsson" <magnus.karlsson@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,
"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: Re: [PATCH net v3 3/4] intel: Copy the exact length of XSk packets to skbs
Date: Thu, 3 Dec 2026 15:07:12 +0100 [thread overview]
Message-ID: <axF3kKV8j5ouxfng@boxer> (raw)
In-Reply-To: <20261203095647.3448925-4-bjorn@kernel.org>
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
>
>
next prev parent reply other threads:[~2026-12-03 14:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 14:04 ` Maciej Fijalkowski
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 [this message]
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
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=axF3kKV8j5ouxfng@boxer \
--to=maciej.fijalkowski@intel.com \
--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=bjorn@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=magnus.karlsson@intel.com \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.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