From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 267CC606A31C for ; Mon, 30 Nov 2026 12:38:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=3eRcuMwi; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=IKpGjVPl Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 0442B80DA7; Mon, 30 Nov 2026 12:38:09 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 75SQE7a5cjKx; Mon, 30 Nov 2026 12:38:08 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp1.osuosl.org 54CA280DA1 Authentication-Results: smtp1.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1796042288; b=mVlV7p//kmqGLqkNki2RQdqbxidaRxmB45F1IzbfbR86Cu53PjKnN3NKzn9UVrifythv 6awZx70rSnhkfYhwcPTjj0HsS3dLo7NbDp+AgT9ZieTV8K1xm3NX5jwVvKngDmQcRtmMn dBegHPLpUEbXn63387CzgiO/WQPeBq7HZvPIgjWesGmEtsVRX5ZPljCRUgdpREH/QiG65 HDVLZ/BzMrwmS96E02uySr5dFSbIdE1EV44Yim5FVJYkjQkSrKhgigA5NFZgvSaGbAITT gunhFwRTMRR/E2up9yeVPgY6zeq43yNETH5V1vP6OCIVfznnP5FyWynT9CJrE60heRA== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1796042288; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received:Received: Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding:X-BeenThere:X-Mailman-Version:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help: List-Subscribe:Errors-To; bh=tvgy8f9Egaag+DNrNfmB5tL4azrblj/kK4sZMVVyIms=; b=sufphH+EGMuKIqEX4pExcf5vfUk7gsJgkFdkvcwww0Ghk08QjjPpEe2GTl7XkJiQxGxt KNv4YDXYyQuhIvHI1dA6ck6WO9etvVpUJxDw4bOEAbxsoacEejJ2TBBFCFYOG7bg7tnH+ tEsV7MDsBqOoVIkHR9JEOM+8Gm1jkM3rO2wMsqyGmn97ZLeI66bbdvOqMq639tOGkdVPV MV5lCm83spKHjvjKpBnz3QhW4J4SjsgBqQd0lWfZaIan2Wd2tHKLIN3/gwS4VD1k3m0Ft lKgXJ2P+qybMBD5IKjUNMgwd4GwB5zfP9IcW/bejIei5WWk41DQILd66FCYk0RLGrPw== ARC-Authentication-Results: i=1; smtp1.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1796042288; bh=tvgy8f9Egaag+DNrNfmB5tL4azrblj/kK4sZMVVyIms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=3eRcuMwiAFa2VUC5c4jKzX667DXCANYLVOrhx9VYWbD9XwUFPwMrpZM4Ep2nUuCym FQiUPPT8bFgQNw0bsYO+Nbr85nSwFnmCaQRFoG0f8PGbY0A1GZZFCVqiRDMCrn6OLe 0qkVm7+1upC2CtJNR3eQl97xJCv4YSjcDAfsiIlLxEBfXAPz9w5qXJZtSUSbYwICHO YZ+pmmQceNv6PUrr3rGxugbfTTsETgz1ulZbjGWzs04Glbm90pSqB5wV9Qdbzc5ZGy sFaTvO+kebx0XTGp9EysoEj4lMumaLILC/BT84bmWS3t9r8y84Zy4Fs3fBRlHbGesg NEGYKqsGiaV2g== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp1.osuosl.org (Postfix) with ESMTP id 54CA280DA1; Mon, 30 Nov 2026 12:38:08 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists1.osuosl.org (Postfix) with ESMTP id 639EBD1 for ; Mon, 30 Nov 2026 12:38:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 5545F60708 for ; Mon, 30 Nov 2026 12:38:06 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id iU1RnFW31LFM for ; Mon, 30 Nov 2026 12:38:05 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp3.osuosl.org 8D642605E4 Authentication-Results: smtp3.osuosl.org; arc=none smtp.remote-ip="2600:3c0a:e001:78e:0:1991:8:25" Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2600:3c0a:e001:78e:0:1991:8:25; helo=sea.source.kernel.org; envelope-from=bjorn@kernel.org; receiver= Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=IKpGjVPl Received: from sea.source.kernel.org (sea.source.kernel.org [IPv6:2600:3c0a:e001:78e:0:1991:8:25]) by smtp3.osuosl.org (Postfix) with ESMTPS id 8D642605E4 for ; Mon, 30 Nov 2026 12:38:04 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id C218742A87; Mon, 30 Nov 2026 12:38:04 +0000 (UTC) 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-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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