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=1796042284; b=yit/CmplhIStujGX7Vqd+3/uxd12RE1QB8yiG0caA3Ra6OcDhrbMHd7iHNZMGIa+v/II WDzLzKT8Hvpt2i5SEVImzaECQN1RmTXicxsujNgoM9cmDHNJ7/MrANbIBbB0G8+L76VP2 LKoDnwfKpfFMFFvg4eQTM9STSV2flWls3aaiBOMU0so07eVrbeuV1bEC7IQ5qsyfBXYZJ Y+OsGQ8nizCMGxmRidekVtZ1Slgeu70Hh9Ed98y5UXWgO68L5IGqF82VNKZyHDrb+eeYD ForzeNKYw650aeB7IZmWzEd5Tk/jbK9i84gSk1mvn5tb74LKlrf15vZsbXqeQ/J3rCg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796042284; 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=tvgy8f9Egaag+DNrNfmB5tL4azrblj/kK4sZMVVyIms=; b=gtgCfwvnPK47i0evqBgg4rwInS5Tu/UZo5xMomfoobURzSI7lfC4nmiFchx30EooyUR4 xICTCepm6b8GfbuEHDtguDFdXoTavps5ngdNHUtLxrbSQp5LLWzqDrv7z39Y5Fesw3xaX OtidyzUH7DXT9giBAa+e/nlLWqLjcAltBPzHc+sng2JSipRb/T0IMDRnOnqeO+qL2RT5S I4C6E4aDqoYoyAXk5UMWbrOXEOUoSVnwZb4XFZs5B7p/zK5A0YcD1x++thkz/8Ac5Cjv1 dcaorsH2qmJVg4u4T5Vn0Mn/fFEFMgU0GihNt8mQSVuN+4aOqGq+NQ/VQIVCHYfg8dA== 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=IKpGjVPl; 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 CA898606A31C; Mon, 30 Nov 2026 12:38:04 +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=IKpGjVPl Received: by smtp.kernel.org (Postfix) with ESMTPSA id E347E1F00925; Mon, 30 Nov 2026 12:37:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796042284; bh=tvgy8f9Egaag+DNrNfmB5tL4azrblj/kK4sZMVVyIms=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IKpGjVPlZ9HaENvYhzhu8vBz/YyYZemBDQ0C+5ON+RJfzl7UnIC7m1WHhc7TnP/pL VNhzO7AFCp7lqUwMK078YcsVgqBJXGy3CxZOgrjJge+3k3yA+8tBAb8gB4lU+m5sFe a6MYZL1IeHUtjIqO1I4NRjhihC96WZvoEclmt1ELK71v/cCMSTIL7ppgycKWf/r2ZR ZbF0eLMMtQAv6cC1Q64oWT8m+NzOqTxqAxXv56ZA+WuP4kdjCiOOMADGD+llpf6U1j CR/8XWGOPbdu9j/wPSFZmkQ5FAGs/gnjWF8ahcjk6n0lHF7nriG1ugfpz1pP2yuE6R g9f2rBZXc7UaA== 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 , 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 , Tony Nguyen , Przemek Kitszel , intel-wired-lan@lists.osuosl.org, =?UTF-8?q?Cl=C3=A9ment=20Lecigne?= 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 Message-ID: <20261130123737.125432-4-bjorn@kernel.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261130123737.125432-1-bjorn@kernel.org> References: <20261130123737.125432-1-bjorn@kernel.org> X-Mailing-List: bpf@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") 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.56.1