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=1796291843; b=JCzpU+rAITmV+EFOlTT7IBWAtqizslDhxKn3Cjm6UYihTaJe1IGWu77jwYiAqb62fexk nAADJpe6l35RPUSu38BA07p5Kxx+O7rBYmUNcXVNPXlVdGZNq7jlFASoJSOF4J8yhn6Fn pEOMUke+ybZUMXEGyPrXr7ZrUjVfeUnkpa9XY6F+TuzeTxdEoasRkfB2HBx+aFhb+ZpJj SplbRAOKg/OUpRSafOKr4jD1jCAprLX4DCdPe89QwC50v1SdM+Z09Yob19Q069iA1/TEN xgmXWYndmBum50TI5f+BDEEY6DOoaFRzOWBB1TvFaz6lbIH/d73nlgntuPmooDzNu1A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796291843; 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=afqjaRYxkw8xtrF+SlE14S9cquJPrHkuMpepDIoV3Wk=; b=0J6icYpp1VHxW4Z2PZjTPqUtaSRxuUpzE4e3EbiFv2VC1t+VHTtsfF3StMvcvVEkYVr0 1u9vCWZKYPIQ26Oh7CH4oDMzUbfJaRfI8j86SU38lHV1kAM/Z6grvzYTDKWZ5SxHqqxTZ 2AZYr4V/IKPC3AhaKKdzQlpSyHcUb+49Z4UBfd+W2m5n9oNlu4B9KW+65t33B0SwRfFs5 MDWoG9/ZpgQRVPnEw3BcHQZ3rNKUehF4rVOEmU7GQg6fN5Yumli36bl2wIOSNcGZgFP52 MCuyyrTF5erac+UA2C0l0D9tAODV7eIFjPjkn1Qx/7tjOED9G7G0DZMzIBgOcXsjevg== 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=eiD+EXsY; 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 EA880606A339; Thu, 3 Dec 2026 09:57:22 +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=eiD+EXsY Received: by smtp.kernel.org (Postfix) with ESMTPSA id 880641F00898; Thu, 3 Dec 2026 09:57:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796291842; bh=afqjaRYxkw8xtrF+SlE14S9cquJPrHkuMpepDIoV3Wk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eiD+EXsYqwMuGtrhX5TiV2X6hClrNyryPqGRHJq2rGXOGc7SnwYpirJKsj2uhpKSJ sZsKFbFiTuzcGIVlRmhMUR7Xb7UtFOO77YOwVthALjKTjUhHkgWVNGz53d1nWtVhpE TYoXccI9UR00iIdty84/tM0gOM46c2ckTAQUmwgSjMD3NFV8TGtnpKryHOxtydAi7G 8oaFOsa+9h20K0RF57AB8Kwk8o0UnPXz3crZANhtKFnSAkfUGkyB4ryY6VCkoK0G3k RvrwGpLa0E99N1T2bc/a1xSHUvPmDX/G3tr+nca/B/ERyLhIh2irGvQD5ZPwHpwd+7 3sgNZR0YfRYbg== 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 Subject: [PATCH net v3 3/4] intel: Copy the exact length of XSk packets to skbs Date: Thu, 3 Dec 2026 10:56:44 +0100 Message-ID: <20261203095647.3448925-4-bjorn@kernel.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261203095647.3448925-1-bjorn@kernel.org> References: <20261203095647.3448925-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") Acked-by: Alexander Lobakin 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-Meta