From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796365808; b=VnCJCO3qdbq+MNvuKjKBIjCrUFghBh3HxZ1yeLBBckU1tnf3Lt4LV7A3KQkwOLCm/Q7o owN3wRTT0nrq5+fjYDeZ1dhs16hUswJsNcWA0MiGQZLJaFzQnxXuw0QTnIth/z4Kvq++o B/Ufl3mtQnrZ7YqJaGY8+fXwSyeLORfdRC6yb/1poR2GGS/y2+84uTH4r0yQSi0Cch2zF EvLWSZ7RtNvbgwtaKrdm8OTYEq5vLPz3xgFThV16VJY1N6XSClrqRiFbaxm9er5VQ12db ITTaWbreWPBBlbQMnzn3YAmovtMuOpN43b6fILG1MEwAgzZQHsqKJrISolEilJeNM2w== 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=Yzx8C00KIFJYgX8M1zTvIK8ImN+n9QS5UNvM5cZp7iABXoRqAfBEail8uFg35cWYwC4J 9YsZZrJHIm9Wm1Rw+PabdqpS93dq2SIP1vFb7gROhMOkHN7judsISdJceZp3mP6RgnELN uYMwkASZZqGmq0s5fbOmkSE0Ugr78DtI+mb9akhBodl2yp7Q9RwO2FnwEKXqw/Sn5TN7l asJ1woqsNrA8vpGZN8hSng5h0qUNXz7XSmcKr5Jo9Ss5hh1vJT///18YXllHpAAGAXWxD X+Ca9W/zl2Ibw3xXcYRsaJbzJndBQyMP42KKgvGe+lXB2DmAsu08JJL2XWXsLWM+BQg== 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.47 Received: from mail-dl1-f47.google.com (mail-dl1-f47.google.com [74.125.82.47]) (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 14312606A32C for ; Fri, 4 Dec 2026 06:30:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 14312606A32C 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-f47.google.com with SMTP id a92af1059eb24-1b589050416so523474c88.0 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=KaO3Wo1r3lCxHuhWro/3mAbLcPnRUb7HuiuVbhCJlwtH1AgoaGXtgO/toCLzGxovQb 6w3Zbad/xeKybjUjYpw0JlnufOWuJX9iPQkWTNUcf7XQdrhS+FpqCwo3vhie16M401jP zJgcrps7eOutvBEw8KQp6x1MO+oucuLtMxnuwLRHNIMUa62U7oaESlRoNTC2G+l5uY3O vqDBmNyFIvwKHzz1WLQird+QFaxbxP2OB+VlKeQbe+KcZJ1fcOemYZ6VhKycJ4hZFuh+ T+4Y0FDcSA8ivPNgY2sDXfxSEWTJbWnKr7eo7R8oZFMtXQXwNkJ3thEq2jpupgERSO+6 SwaQ== X-Forwarded-Encrypted: i=1; AL+hErE5hl/Jl5dsN6dfnWI3cTruIcNJ3OC5lsRGk1Pkf75fePRSdDFmfZc4MYBm8231oQd6+2ktrF8=@vger.kernel.org X-Gm-Message-State: APuU4Z+N81q40M5l0IzholcyttgyIFfQcY/3R7/2r2ilcANQTkKBfOgp wi5WnBaChbABAZhAh1U21iZfXIvDYqQBIkgTVcjL2FcxNjkwqoKrXtmP X-Gm-Gg: AZFdTZe5FbzhIiujUikdA3O+cNvf1bpFC/zST95v7JlWmBK+fH6G2SW5oLotvn/JlZt c3LFUZ3DxE12aBv8xxaktiXpYxfFF/nQMTorXtqxMiVxu2wXNjB6/kZW/kP9N1QSnS5adRpQUer nJdvLqws9j49RVDJxGx+PKvjbrzWfNlBU8jzwBSwa5RofhEb14fDkSjyhs9jRdWXIXoqpwmA65o nI5mXDAZvQcuPFcmgG751N5SyiNniBpd53VeLZ5twfVz7/5Jbaz1qRwkmHNslYHlv9RQh5kna5X 7tjtVyaOEv9MnDSceWLBpLNOGsf5nxHRZ0xB4ohn3iisljSB5q0Im90lk8gpWhAq6yAwWZT73xb zMVpTbSupRnAHUoTVOotA3mTeGcvQ9FpRq2ps4EFeUgQTZsD7fesM5ez7riPpERQF+sRDPThunI 6OcIR2orhBb9VCHFCCHXfTwpY8GMGEYFrYIzTQppBK0p/2GTzP5MMBZYzZBKFszT528MbXbJXTp 211tOYsFamOjMsN6GmPOunWRpPcEMVA683A1kxLjnfaEQhae98bFeiIQxDICI0VBZ/4ToCiZ+K7 E1feFcJDmGIacQhg+DnQQrJopVT//Nrpa1ExPmBB3ofw 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: stable@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