Article View: linux.kernel.netdev
Article #26778[PATCH net v2 2/2] xsk: initialize the struct netdev_bpf passed to ndo_bpf
From: Amaan Cheval
Date: Fri, 04 Dec 2026 06:28
Date: Fri, 04 Dec 2026 06:28
83 lines
14657 bytes
14657 bytes
xp_assign_dev() and xp_disable_drv_zc() declare a struct netdev_bpf on
the stack, set command, xsk.pool and xsk.queue_id, and pass it to the
driver's ndo_bpf. Nothing else in the struct is initialized. That
includes extack, which belongs to the XDP_SETUP_PROG member of the
union and lies past the end of the xsk member, so a driver that reads
xdp->extack on this path gets whatever was on the stack.
gve and idpf read it. Since commit 091a3b6ff2b9 ("gve: Use extack to
log xdp config verification errors") gve_xdp() passes xdp->extack to
gve_verify_xdp_configuration() on the pool path, and that function
stores an error message through it whenever the configuration is
refused, for example when a zero-copy socket is bound while the RX and
TX queue counts do not allow XDP. Since commit 3d57b2c00f09 ("idpf: add
XSk pool initialization") idpf_xsk_pool_setup() passes it to
NL_SET_ERR_MSG_FMT_MOD() on its error paths. With
CONFIG_INIT_STACK_ALL_ZERO the pointer is NULL and the message is
skipped; otherwise the driver writes to wherever the uninitialized
pointer points.
Initialize the struct in both functions, so that extack is NULL on this
path for every driver. dev_xdp_install() already clears the struct it
passes to ndo_bpf with memset(), and the BPF offload code uses an empty
initializer.
This was discovered by an AI code review agent reading gve_xdp() while
preparing "gve: do not verify the XDP configuration on program or pool
removal". It was reproduced on gve, with that fix applied, on gVNIC in
GQI-QPL mode (GCE n2-standard-4) on net at
commit ef3e21c61baa ("net/tcp-ao: fix reset key lookup for IPv4
segments on IPv6 listeners"), built with
CONFIG_INIT_STACK_ALL_PATTERN, by binding a zero-copy AF_XDP socket at
the default queue counts and MTU 1460 with repro/xsk/xsk_trigger.c from
the Link below:
# ./xsk_trigger eth0 0
Oops: general protection fault, probably for non-canonical address 0xfefefefefefefefe: 0000 [#1] SMP NOPTI
RIP: 0010:gve_verify_xdp_configuration.cold+0x1d/0x2e [gve]
Call Trace:
gve_xdp+0x47/0x4d0 [gve]
xp_assign_dev+0x2c8/0x350
xsk_bind+0x1ba/0x4e0
With this patch the same bind is refused with -EINVAL and no fault.
The idpf case was found by reading the code and was not run.
Link: https://github.com/AmaanC/sticky-xdp
Fixes: 3d57b2c00f09 ("idpf: add XSk pool initialization")
Fixes: 091a3b6ff2b9 ("gve: Use extack to log xdp config verification errors")
Cc: stable@vger.kernel.org
Signed-off-by: Amaan Cheval <amaan.cheval@gmail.com>
---
v2: new; replaces "gve: do not pass extack to the XDP check on XSK pool
setup" from v1, as Maciej asked.
net/xdp/xsk_buff_pool.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
index 5ec092f7cb6f..ac2a188b2839 100644
--- a/net/xdp/xsk_buff_pool.c
+++ b/net/xdp/xsk_buff_pool.c
@@ -144,7 +144,7 @@ EXPORT_SYMBOL(xp_fill_cb);
static void xp_disable_drv_zc(struct xsk_buff_pool *pool)
{
- struct netdev_bpf bpf;
+ struct netdev_bpf bpf = {};
int err;
ASSERT_RTNL();
@@ -169,7 +169,7 @@ int xp_assign_dev(struct xsk_buff_pool *pool,
u8 umem_flags = pool->umem->flags;
bool mbuf = flags & XDP_USE_SG;
bool force_zc, force_copy;
- struct netdev_bpf bpf;
+ struct netdev_bpf bpf = {};
u32 frame_size;
int err = 0;
--
2.47.3
Technical Details
Message-ID:
<20261204062857.730993-3-amaan.cheval@gmail.com>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377116-linux-kernel-netdev=dewy.ruReferences:
<20261204062857.730993-1-amaan.cheval@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377116-linux-kernel-netdev=dewy.ru
From: amaan.cheval@gmail.com (Amaan Cheval)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v2 2/2] xsk: initialize the struct netdev_bpf passed to ndo_bpf
Date: Fri, 4 Dec 2026 11:58:57 +0530
Organization: Usenet Network
Message-ID: <20261204062857.730993-3-amaan.cheval@gmail.com>
References: <20261204062857.730993-1-amaan.cheval@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2692627"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:9fuDoWBP+nN2Yh5S5mCqGSCHWSo= sha256:Ij9lmXtDjGDfksPOa6j0S6oGQYJ80itCs+PyCHSMCl4=
sha1:QAwk97o6uvaTV7lu1aewvTecreo= sha256:t/u0d2mWBEgruNwxCjs8lge7lEfatlHyxHV6LS4xhPw=
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 0C375117B2E; Fri, 4 Dec 2026 09:30:24 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.297
X-Spam-Status: No, score=-3.297 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001,
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=gmail.com
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 bUrs5GzZB4AG;
Fri, 4 Dec 2026 09:30:21 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377116-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id CD1E0117B2B; Fri, 4 Dec 2026 09:30:12 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 22A3328333; Fri, 4 Dec 2026 06:30:10 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796365810;
b=PoJ91HW8D/jXM/JmbdPRPKpp85SfObFcAkl2XRwPi2XNCmRYOZgwdEVRUKMsGbhn3O4d
N0Xnam80K4HiEMqwwh7zTCK9kZ80EiYKr6+pKywgOPFIgQxweI2aWu9FoBSuBVEWXqgEG
9rueqa3MsIn17z38V3FbtWvHUhL6WllzKS3uACOUAZfJha+e3HfwSV7PvvwcZHAMryCoi
kXQCLa0xCtzkG7yoyWXqgcemqWi44pgQQLyIWu2KOlVnfrFxUolJ19yseHIdUaO6Te06E
yNdJW8D+gA793nTEW7drj7p079/n4GzTOSzB5rvjitFz1z7LjrzTebG1/x7MQxs17VA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796365810;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=O4NNjt0/wuUmlt5JeNmfGCoeZB7KkmMCIXSrrv0DPK8=;
b=Dsmwc2i9ziuwGGINNUf3yD8Fq0dxKo669LL9mGaRrGJh6oytmajmNzR4Ypp8oAnJuxbE
ol9ttbz58yK+djTc6sMgbC9Q9nIOxCRCzYxpumOfcWkImSMbreBdEmVfJ6FP8kV3Qc34b
Ov5j7ZYDimteRtqx+EAlKDIRvWbonDp5LA43wYaX94Yl+4/ZXHW42v+WF6lW/SRbdiEFw
ZPfAMJUpdxdeD3f05joBIPzAwIwzBON6QGYl9Gr0wUOJ+lLfxGYiZaPk83WK008BIRjQr
T08Sxyvl7Vd5VumChrAnvKQrMUA6JPRMmySCZtDlLbWYVHimSE31GCCgtC+lFu5A3iw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=eVK1TGlo;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id ED361606A32C;
Fri, 4 Dec 2026 06:30:09 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=eVK1TGlo
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.45
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796365809;
b=YRuDDxBqsqQSv4r74SFWYMJE9qUEV0HblVutQ9HG2yz6w03EtzHGKpppQypeOXgDJ4S3
QWcVNxJkFoQZz83XGT3Y8x9bJvxdl3Tg3Oba5PnROW9+NyiydcgOU3Sm6nBQ7Qaixv40o
r2h2JkhA4JS00HkQ2r293YrFQFXQv/wpSTPmtl1JjDmkZy8Yu0nXQQQeNyR6VIRy6JGoa
u6/ZjyTDoEsZhE3vgTMauiyB2/Ca7xWtUiVRVThHukcUs6qlEFLy6XHEQrsq2BzprKMDC
YaQz9KFViyFwLInZdah0nwkf+/wE4PSKyZNgNw4fqOK3/J3Kl40VBhvf81ONdDQnTTA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796365809;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
Content-Transfer-Encoding;
bh=O4NNjt0/wuUmlt5JeNmfGCoeZB7KkmMCIXSrrv0DPK8=;
b=BuR2NcpzBkCpc3NF3EMkRhe3/YY9Usl7ex9TrfAbsZxe1u0kYG+rPJEABfDX8odM5mpO
HGfwAd/pOhD3ewD37gB0XReZ/c/lRVGchrItOVAhX7o0XLVldWPL1FiZjYYBBRyPmZK18
wXJFZAAJOgEc3W/s5rmrl0z3DHdVyhRdNleJldT1OCqjduI5/Gdhw7lHsYlpmvY/61zJQ
UUTywoJ4G6Zs/FgQ1LemTPJj7Xm0CnwEWrbXAUgZjPVNaaeUnR3rTyky+3wKJBT8iph11
ZE/cKrcerjom6bWdubdlCgV+OQMpXrhz87nxQRESou52AaziVAmNfJcYJo/wdweWyiA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=eVK1TGlo;
arc=none smtp.remote-ip=74.125.82.45
X-Received: from mail-dl1-f45.google.com (mail-dl1-f45.google.com [74.125.82.45])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22A09606A333
for <netdev@vger.kernel.org>; Fri, 4 Dec 2026 06:30:07 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 22A09606A333
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-dl1-f45.google.com with SMTP id a92af1059eb24-1b59dfe466bso1122546c88.1
for <netdev@vger.kernel.org>; Thu, 03 Dec 2026 22:30:07 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796365807; x=1796970607; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=O4NNjt0/wuUmlt5JeNmfGCoeZB7KkmMCIXSrrv0DPK8=;
b=eVK1TGloNAEcZfVw9HO+ryfCHLJq+FYcCqenoTCLi57UGduSloawb+vf/gRHuXRTlj
pkC37BEYdFGNPPcW6kBBgmhfQ5wFOFpQUCov//sn1OFU23NAimHYnJ9a1r9oG5x/5sX1
FqoY+JSuXF/5frSJuUnC7O87FXIcA8cxC4Q/bZZqegqI9782tp82CLuBzPn2I5znXMUG
NvoOfXjAgx366lu6SxS05+c7l/aiboXXLt/KoD/XYaT1X8uwCwwVWCzG3QGLoDUh3YcO
8fSzHjgRakfam0KjWEFTqUSllOSIXSLYil6/hjrkzvOJ8089xXLr8fOo+r+BkZPZRJE3
Gc9A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796365807; x=1796970607;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=O4NNjt0/wuUmlt5JeNmfGCoeZB7KkmMCIXSrrv0DPK8=;
b=pYJQuLLy3zpdRQMhUo7kneVXA0+fHLr0EYtb911PPcz9AlKcFAbVH6JB341xjAPUSg
HK3FPOyizyh8Xkqbcl6OHwqKmo6ZVyGumAb5VDFQwyjEE2fGD2+0wNiN1VsMTb72QeQY
zHfZul4lqg3gs0QUhjUzGRPIEcwNC811INylBGhpB0H66pIuuwfRU1vB9hlYt1pEmiUy
Ne/bMD90LI074uGeU23oajv9HzmhX8WUr74FAWF1UKmVSkWy6fzS3J92gB/ffgswYRzF
f48OWLfhSkFOaCeKbpPIP8rdKKT5E1rUilVzLxCUVXEonItk1k3Nlj8Sbui6wX3kyK+a
FQ8w==
X-Gm-Message-State: APuU4Z+TC0MKazTyRsdRixgONSBEtvMiW4bpF0S08zV+cO9FOjxMBrLj
rPEazMHmGUGrYjdZzpwgZMyL+K8gN/kTlJ7eyn7Br1Jsd8mRYK7qSMXXN/RT+7Rw
X-Gm-Gg: AZFdTZfG4QbVWuH/blZCnAf2mbLgCMY530/RZdPX7em+WK/7LqfoE4orkjklSFTwWi3
OR4PxIAOC/ExLivfvvHCTrtWzmrZQRB5GBLgAuG+8qIO+NR1qXX/alsD3ht0nZ2K4Y8gg6khaOy
KHik/3BCYbWZlPSL3l48NZy2fhKw09pJZPAbv8xmPWZg7c2YOmLdCljr/QzkyZgYIhUaWscmqLg
uZyc1xVfgz0f+SUUrg0XSZQ2ctUF6jOmAFiFyBm8p0VIsGsg9TbWX3I0NwThNLrYG90Yva764ll
6X9V4SK6GN8u8MCFu0K8rR+TmDgQ+lef4xSH9p6F1dRiZn9d7wj38EJ8VO7IapMYXXLNBK/rvsW
5LBrg99yU2pIHonWezFdtM8HRHysBJOnxpjCBhQ0HFTZwdotTswYwu6aNInFqiroxkn/MbPo+bw
Pat5JzAwBgvi5YOTQwjSN1HHvNOfFE8JuIVyTLsaR4sIkgcWgeICmERUDPvHpXXfLPbOrLtPn7s
YjPyq28khSTi/8uxHj3/Ca//lQxS21Ff97xgmUdNX90VYpL6BWgWERyVHM8bFiMA7XqH46g6q0L
GlAQtaFHd93aYrLysDVaQljGAljaFUGzKZaJ35eoyhAQ
X-Received: by 2002:a05:7022:e80d:b0:1b2:41af:c21c with SMTP id a92af1059eb24-1b5d711b4d7mr1486810c88.39.1796365807085;
Thu, 03 Dec 2026 22:30:07 -0800 (PST)
X-Received: from localhost.localdomain ([2406:7400:51:44ac:c2b6:f9ff:fe77:10a0])
by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b5d63d04e7sm4447866c88.1.2026.12.03.22.29.58
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Thu, 03 Dec 2026 22:30:06 -0800 (PST)
X-Cc: joshwash@google.com,
hramamurthy@google.com,
andrew+netdev@lunn.ch,
davem@davemloft.net,
edumazet@kernel.org,
kuba@kernel.org,
pabeni@redhat.com,
ast@kernel.org,
daniel@iogearbox.net,
hawk@kernel.org,
john.fastabend@gmail.com,
sdf@fomichev.me,
bpf@vger.kernel.org,
willemb@google.com,
jeroendb@google.com,
pkaligineedi@google.com,
nktgrg@google.com,
jordanrhee@google.com,
przemyslaw.kitszel@intel.com,
debarghyak@google.com,
treapking@google.com,
magnus.karlsson@intel.com,
maciej.fijalkowski@intel.com,
horms@kernel.org,
michal.kubiak@intel.com,
anthony.l.nguyen@intel.com,
aleksander.lobakin@intel.com,
Amaan Cheval <amaan.cheval@gmail.com>,
stable@vger.kernel.org
X-Mailer: git-send-email 2.49.0
X-In-Reply-To: <20261204062857.730993-1-amaan.cheval@gmail.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list