From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.45 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== 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== 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 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 ; Fri, 4 Dec 2026 06:30:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 22A09606A333 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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 Received: by mail-dl1-f45.google.com with SMTP id a92af1059eb24-1b59dfe466bso1122546c88.1 for ; Thu, 03 Dec 2026 22:30:07 -0800 (PST) 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) 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) From: Amaan Cheval To: netdev@vger.kernel.org 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 , stable@vger.kernel.org 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 Message-ID: <20261204062857.730993-3-amaan.cheval@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20261204062857.730993-1-amaan.cheval@gmail.com> References: <20261204062857.730993-1-amaan.cheval@gmail.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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