From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796365808; b=1BFPU7QuITDjrVhvZd0hhbtXgoYDeYzsTPJ2EjG0NRju6bHIMb1OTNPXOG6MlNzoG0XJ Dy7wkntZUbXYoTbCHSrzjoI2LxR+iow0sIhhQjRfhVy+kseKh5QJx/PfX1Osy0wfmpyUR 2gPqxf4fCZlgNeKRkLknkInGtolv+ew6v53b9NeyfgzZgNwYn3BXf/LpaQfMfRFXcXJ/O uhKIImiyF5JztmunC504XdmJENrwIuV9Uya4e+ukc4wsYygqDF7EWU5w16ypt1I9+nc7j 18UMREjFv6x9ji0jn6U9sJCc93f1BDD8MpmZv3L8anejTG3O+E7b35lmxzgDUQ6MHVg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796365808; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted: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=Z07RSqwTWkUkljntmg89THbZVH/VBDehL80ldGfdEqDyFFX8Woi//L7KKeWSRwa97HvL 1d+eOijQiukRpBrQxRS83FBdzSM1ROA8FncMukqWrRjz7WdmvyeY4KmeQfigEX72Yxr4G 8eawX7dO9jZoQyvqLhEZUBp/0vsy8/kOaJtNK/FU3neJ1cfGNU3i64Y7gPBK0zZ3XouH8 jNbz27EU+r2IGoJbQMnBRSHx4Oeq/ZJM33x/IqkPslbsqEK6FK2OTML8OJ09JLrAyfaVM lkjWM3Ck5/ZLdwwAIw8mxfstZ3U3MQNZTW4K/0n+9/+Yl/0HHXwFtpnHnTve5vqvKiw== 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.43 Received: from mail-dl1-f43.google.com (mail-dl1-f43.google.com [74.125.82.43]) (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 18EB5606A330 for ; Fri, 4 Dec 2026 06:30:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 18EB5606A330 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-f43.google.com with SMTP id a92af1059eb24-1b59dfe466bso1122539c88.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=m70LiA/AU6rajgh7+EyCLTJzNh1g90RFoaiUcy7QN9LumKE5AkxXMYE59PlpiQpvJI iWMCoaa38sWyAXTq4/s6TN8w5ogy4YvhKneQ/Fxly9HzNynBt5D5hNBxAepgmxwM0QOD YWI071G9yzHhn5ujyFP2K2apPmlzkIOso8DB1iomY7C8IZLcEy7X2Y8i6Y8UI7TaH/B5 tzIB92rv8bmL8iRtZtlKdHx8/ayMuJ72QGY/yzs4F+nX0lSHHLCjfvJ/pZZgUBcmGcT2 nGQ1zyAwVUkUKaMXXYMETq5WYBMta79IV1I+FUKKjDrZYA3DilkU7FggjJ1jljcYH9sj E61w== X-Forwarded-Encrypted: i=1; AL+hErHqRHYAthEcXS9XbncjOuPGzyRWrEwytPMmxbCMbDhbXMFXkwvyfMAHeXFNO8nBHelBNj0=@vger.kernel.org X-Gm-Message-State: APuU4Z+UCTdzGRODjxjD+6FX4h0qv2NQaS4NMpll8zpZe0ka7WD5XD3S ZmNggSFvBXXgWBEXMLfXeBG31bl5AEqdMkS4ROKgdo2vpav4mYfey978 X-Gm-Gg: AZFdTZdESzFeJAIrD5rbsAVJUBSFQr3oM7jlAWPBQo8dlUDDacDZUQyfc3T6Jjg4bXg AG+2PR4t+8N0Edm8kiWy/pJZU2QKAWUA/WdEf4D2kaluNJ1neMwOOXBjrbC0PiaOgDeVqPGUaWe eT3rZb2RxwDrhEY5Pr1j8lBgW4j59qa5w6uSSlUDnXEEBy/mTBJ+apcTgRSENTegHO5SSMGlldP 1LUJdZutXRTEpPQ3SQlLznuarchQT/rve4KVTzRxUL6QRHF4wf71VLHK01aSj1rDsDEHCdsszcF 03rpyNp4+WTnvCPmLiFb8N605pFyD0HWvnymUHcTyRpflxiVo7doua9WUPDZ0OayDLejhv06KYC X1mXoaMUBpm3ybgfraRUcrL2fZ4lx4InmMZd6sUO2GNmJbup6uUDIVn8o+sPhPXErktkh3+z81S Z0xXH5nB6RBAmX9eiQw8L1htWhn/1j0n2QHIToWXYJkkWhGDx3d3Muu1JROkbOeggsOdQIyM8+z 2fbFmqCgGyFxJcOM1SGCWPJsjue03G0SqL3jRzGTKc4Vg/lGs8qQ0Ajib1zcPRiMgU+/4o0Dqnc 4kCVYnAbcxAWLXtXlbkW/81W95vtorOIM+eLKLTOWHBV 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: bpf@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