From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796394073; b=wuO6LXx+y7IDPpGxlRISsIWcUyFN+KsE8eKacY9Gx04YjWpLAWxHwXLSC5i+dv2gUMUm JKGyfvWw8IWvsHAxr6M0/qit7fwiinR8gBzIGPAEAeBdca58LNMxaissHtptxsswSTjz6 mMXjNDeGXVVijPsjKGmRL7JK1oI8m3TsQ7YHIq6TLl/KWSTHaXL0T5awlb/gND8neZMYY SpKSGxpZN3v/NZwMStsbB5zjN5k78rubWeuX2mm667X6RZ6dkWaPQw2f9+aoaBnM07u3l JTPlxvcoR965Cmp98QPGNtg820yOOFuVI8dCefbOsTOy4+wURI3jMsOggXmPT9mfbxw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796394073; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=+3tb7Dnp6paNpzvXf7dB7IJJ4MYHToj6PZ7fwpGTNSo=; b=rlyRCAoBEqJ/m/iRwuMoNPPsoDqPKeCjdECF+6JPTWXlrcF3+VGCGZXFnzDP7PPZpf9h JfyEBmPf7X8nu8M+5ZQXysRpLySGj9ZsgP4XHBxcZschXMVFIgh/PhiGA/j1WLHbHmUU8 WbWTmgDNRiHUNFFGkt7nXWNUfXMuxBhf8AXwvh8PF/oLgZdHsjiu6niZb7UU9LW1YuMeo NstDn97IaYuZHGz92kzjZ3djjkRVCvZfOsoKwnsnnzSxmbscNTekhs/fsBRK2jPuw9DzU jk78xtL97Rp1nB9QpYVmdLMFEvlBEPQfh9XEVo1OqKiTl2/IRv8UyxuEwfETz+sMdGQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Iv4CaInB; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFA0D606A32F; Fri, 4 Dec 2026 14:21:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Iv4CaInB Received: by smtp.kernel.org (Postfix) with ESMTPSA id C847B1F00897; Fri, 4 Dec 2026 14:21:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796394072; bh=+3tb7Dnp6paNpzvXf7dB7IJJ4MYHToj6PZ7fwpGTNSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Iv4CaInB4io0zl8tdZiiCHiUeUNWfaijd4oQn2VZuw9eFSKTrjHFjGALgxml0jlyK UokLHACeXercm8W8y0zeJxCT61KwEVhQ8z/mFlRwDU/XYmq1gg0MtbJmrL/JIQYXKm IkahLZaubcX7ZOVMPehSHV9dtGddsfUoGKto7/VKgfyiO0T/MJ15Pr+/N5vHBSd65E e3sj9Tr4MCAUnrCxxCOH78TKpIYwnI9be8Dgqd7hodZRsiXHM3ZXu5s1xfIwXZ72wk uwviF93aUco2QTjndZgOAI7hgDegqM9MWeOq6LkmqHwrQPveoLz7Geg2a6sENpxXdx hTnANWiYJ1fQQ== From: =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= 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@vger.kernel.org, bpf@vger.kernel.org Cc: =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Simon Horman , Stanislav Fomichev , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , intel-wired-lan@lists.osuosl.org, =?UTF-8?q?Cl=C3=A9ment=20Lecigne?= , Michal Swiatkowski , Sriram Yagnaraman , Kurt Kanzenbach , Michal Kubiak Subject: [PATCH net v4 4/5] intel: Copy the exact length of XSk packets to skbs Date: Fri, 4 Dec 2026 15:20:24 +0100 Message-ID: <20261204142030.626820-5-bjorn@kernel.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204142030.626820-1-bjorn@kernel.org> References: <20261204142030.626820-1-bjorn@kernel.org> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Maciej Fijalkowski Signed-off-by: Björn Töpel --- 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