🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #4137

Re: [PATCH v3] xsk: fix memory corruptions in net/core/xdp.c

#4137
From: Björn Töpel
Date: Fri, 16 Oct 2026 20:15
67 lines
7965 bytes
Maciej Fijalkowski <maciej.fijalkowski@intel.com> writes:

> On Fri, Oct 16, 2026 at 01:19:35PM +0200, Björn Töpel wrote:
>> Waking a dead thread: RISE FROM YOUR GRAVE!
>> 
>> Clement Lecigne <clecigne@google.com> writes:
>> 
>> > From: Clément Lecigne <clecigne@google.com>
>> >
>> > Commit 560d958c6c68 ("xsk: add generic XSk &xdp_buff -> skb conversion")
>> > introduced a vulnerability in the handling of XDP_PASS for AF_XDP zero-copy
>> > frames.
>> 
>> Hmm, I acually hit this in my WIP for UMEM page pool provider hack.
>> 
>> > Note: Currently, this specific AF_XDP zero-copy conversion path is only
>> > reachable from the drivers/net/ethernet/intel/ice and
>> > drivers/net/ethernet/intel/idpf drivers.
>> >
>> > When building an skb, xdp_build_skb_from_zc() uses the chunk size
>> > (xdp->frame_sz) for the allocation. However, napi_build_skb() automatically
>> > reserves space at the end of the allocation for the skb_shared_info
>> > structure. 
>> >
>> > Most high performance UMEM applications use 4K chunks, where the
>> > corruption cannot happen.
>> 
>> I think this can also happen with 4K UMEM chunks.
>> 
>> For example, on ice, use MTU 3800, 4K chunks, and no extra UMEM
>> headroom. Attach an xdp.frags program that returns XDP_PASS, and bind
>> the socket without XDP_USE_SG.
>> 
>> A 3814-byte Ethernet frame fits in the UMEM chunk:
>> 
>>   256 headroom + 3814 packet = 4070 bytes
>> 
>> But the copied skb also needs space for skb_shared_info. Using
>> the 320-byte size from your example:
>> 
>>   256 headroom + 3814 packet + 320 shared info = 4390 bytes
>> 
>> The old code allocates only 4096 bytes, so the packet copy
>> overwrites skb_shared_info.
>> 
>> Am I missing something?
>
> I was pushing back on relying on scenario above as we respect the tailroom
> now since some time:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a315e022a72d95ef5f1d4e58e903cb492b0ad931
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1ee1605138fc94cc8f8f273321dd2471c64977f9

Hmm, isn't that only with XDP_USE_SG? My example binds without it.

Then xsk_pool_get_rx_frame_size() returns 3840. XDP_PASS still builds an
skb with skb_shared_info, even if it's linear. So we only have 4096 -
256 - 320 = 3520 bytes for the packet.

Or am I missing another check?
Technical Details
Message-ID: <87cxt94d1t.fsf@all.your.base.are.belong.to.us>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347534-linux-kernel-netdev=dewy.ru
References: <20260629072300.1664622-1-clecigne@google.com> <87qzhp51vc.fsf@all.your.base.are.belong.to.us> <atIfJAKqp3dZdY4M@boxer>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347534-linux-kernel-netdev=dewy.ru
From: bjorn@kernel.org (Björn Töpel)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH v3] xsk: fix memory corruptions in net/core/xdp.c
Date: Fri, 16 Oct 2026 22:15:42 +0200
Organization: Usenet Network
Message-ID: <87cxt94d1t.fsf@all.your.base.are.belong.to.us>
References: <20260629072300.1664622-1-clecigne@google.com>
 <87qzhp51vc.fsf@all.your.base.are.belong.to.us> <atIfJAKqp3dZdY4M@boxer>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="2866887"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:6YQCsYo33OrKhaup7iTcegTFWfg= sha256:2ABiy+5Enwd+DGaqgLufyUOHGFjCNWB9PEMGPYvymzY=
	sha1:xwgbh0ieDMoTol3te423/eSNF9U= sha256:K0jVPSS0KY97/zj/zCuUrRlj0S61Ffk8hRNHWVdvKdo=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id CE5291105F1; Fri, 16 Oct 2026 23:21:44 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.64
X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id XshcsL4UcQGr;
	Fri, 16 Oct 2026 23:21:42 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-347534-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id A2B041105DA; Fri, 16 Oct 2026 23:21:33 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sea.lore.kernel.org (Postfix) with ESMTP id 981C8446E6; Fri, 16 Oct 2026 20:15:56 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id B6EBA400DE2;
	Fri, 16 Oct 2026 20:15:50 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ndcfiN7l"
X-Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7D0E3F4DFE;
	Fri, 16 Oct 2026 20:15:45 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1792181750; cv=none; b=nAe3Nbtkt70SrurDrlXWRspM/xAOcMj5EiXkhUgwHYk3EMx1p5fP3Adkk9awBc/HdSPtjV09GcpOC07QOjCCBuEsIDjnkZ9Gvr9iewkWuvN55stN8Fhl1cRr92VUjBLyZrExceLqXNdEG/J/I1oapzRKLpnBtlkcMJmQsSIr5Sw=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1792181750; c=relaxed/simple;
	bh=1CtdNjBP/tT+f6Z4HSlvplXa838Nfx85jUo5kW1Umdk=;
	h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID:
	 MIME-Version:Content-Type; b=WMxrBPeHZESip9QOMQkKQcMubQUsp16ohd1hchZIi5k9X56CzPVcssV7EcidrbqcrePqByQozcIXLHAVudwhMN2efkLcSk9F4eHcwOxPVOPQsiWDAcFuMfXMjfuO9Z+Gm17pO/x6tOyvHf7sOyMSrJhE+8arpufWJjAG6d4uUSQ=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ndcfiN7l; arc=none smtp.client-ip=100.103.45.18
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11A401F000C4;
	Fri, 16 Oct 2026 20:15:44 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1792181745;
	bh=PHvv5s7xTkvqkhoQfbECIs2qM/anmRUbsbBZ2oBhi/4=;
	h=From:To:Cc:Subject:In-Reply-To:References:Date;
	b=ndcfiN7lDTkzMOicy2la/SON2lfNP0pJSTx2lrPdJGuuT2vEFOMpwsik6ZHhUgVjC
	 akyhqHohEI1uaki5sly91FgO6V802YngT5LNIEN7MWTuNP8Wjrgft26QejzvzaO7OT
	 PERVh1hhoC9cltKHBWv8zw9O3UQcJqXkRWE/vjtkGZr62m8zlr8Qbj9jhQuBT6F3c4
	 jOR/19F6doBkyuh6RsUeGsykLdR07svkJgWrMdoyYzDcaw0JkhCHzhJVMiOr8+6PmZ
	 55dNpbDz6b5qhI4PCwGAC8wkbVxFbywNw7YlDEkp4Q2sXNrO8og+saIp6iOKOgQPbj
	 d3HucrKe+/0nw==
X-Cc: Clement Lecigne <clecigne@google.com>, aleksander.lobakin@intel.com,
 edumazet@google.com, netdev@vger.kernel.org, bpf@vger.kernel.org,
 linux-kernel@vger.kernel.org, kuba@kernel.org, sdf@fomichev.me,
 horms@kernel.org, john.fastabend@gmail.com, ast@kernel.org,
 daniel@iogearbox.net
X-In-Reply-To: <atIfJAKqp3dZdY4M@boxer>
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>