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 <bjo…@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