From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388041; b=1PO1z10iZwq56b36CVX+mhGcL0c1ct7/cBwtRjlKbXr1C/3bVceNZyau+wDl63wgDUlp blqFqhpMm7z3w3DONik0ya+yRnKtG1LNn6eNChCjlW8WWHATu4Rox2EGfK0tduj3S1NOP cU4VM3uqFZKgujH0NS4isVVwTbYMPKzNkhWIe55LWsMfdCTjYCVRX6ekwCyCp1AAertoG 6lO+V+Hb9xFaBaccKXvU1xbTxf1TSwLzSXnwzamPiIGIQmKHd+/VZhNgomMmYkjEoG/V9 NZ5yiHjlIoILSpi8AGlf/f96eabtXDLz3earttb7Jz/VuyvnzET+aRBMpoGN8Edt7JA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388041; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=P3RKIYkYTxpCW5qBR6jkZBF65draTnD0CNssFQmlFU8=; b=C0yzDkqg8EWRl+8SuSKecQxO8KfrFENmxOJGdM1htYuW9kmVpq97VKf2hDwbv4rUwA7m 8cfoFkMaQxcIljMRGTKDcTJyRRxQCfU0SphZ85TmcqmzegGCdzWFfN5NrVYhV6iYH7ygh iz5vYmGR2RDI0vFAxQd98N7/G0kSYsNkiEtzkSE+kyH7FD9flORhNixyEFZwXi4RpNTVe UhcVRrfaE3GF4JSymSlT/pwYHeyMkSOSWGTo7SzpQJEE7CjKJdEpb685AIFZUSHLaeyUS Ue4OZv50MfXPj40aZWIfaKi8/XeZrGmphkc/19yzVsxDWoHIwsahw8wJ8OGDWN5AZ0g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=jcv0GVF2; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4BEB606A32F; Fri, 4 Dec 2026 12:40:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=jcv0GVF2 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 821421F000CE; Fri, 4 Dec 2026 12:40:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388041; bh=P3RKIYkYTxpCW5qBR6jkZBF65draTnD0CNssFQmlFU8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jcv0GVF2rB1GuNbIgH74vexRobdA7jnNFlwPen1V+Ti/A66wLZ0EwgwmBPPtw3RL8 F/ZQpKO+taB/mnV9BcEYYdZdiwV9EWbwFWaP2GoY4j/FhIC4Hcd8Ap7mlfsZ20WxrA LFTB8eIDW2YuFXu5Xsri+TpesraxLvKrm8sNqgK0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, kernel test robot , Shakeel Butt , Tejun Heo , Danilo Krummrich , Sasha Levin Subject: [PATCH 6.1 0462/1059] kernfs: avoid READ_ONCE() on a kgid_t in kernfs_new_node() Date: Fri, 4 Dec 2026 18:59:53 +0900 Message-ID: <20261204100656.238793422@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore 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 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shakeel Butt [ Upstream commit ef179363b04306dbc645c53207b9ad3516ebc75f ] kernfs_new_node() reads the parent's gid with READ_ONCE(attrs->ia_gid). That gid is a kgid_t, which is a struct. On SMP alpha, READ_ONCE() ends by casting the value it loaded back to the type of its argument. Here that is a cast from a struct to the same struct. GCC accepts that as an extension, but ISO C does not allow a cast to or from a struct type, so sparse warns: fs/kernfs/dir.c:751:31: sparse: sparse: cast to non-scalar fs/kernfs/dir.c:751:31: sparse: sparse: cast from non-scalar Read the gid_t inside the kgid_t instead, and wrap it back up with KGIDT_INIT(). This is still a single marked load of the same four bytes. There is no functional change. With GCC 12 for alpha (the config from the report) and GCC 14 for x86-64 (with and without KCSAN), fs/kernfs/dir.o has the same object code before and after this change. Fixes: 81bdc85b4c08 ("kernfs: fix up the unlocked attribute reads on the creation paths") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202610261608.vItiXCGW-lkp@intel.com/ Signed-off-by: Shakeel Butt Acked-by: Tejun Heo Link: https://patch.msgid.link/20261027143247.3537239-1-shakeel.butt@linux.dev Signed-off-by: Danilo Krummrich Signed-off-by: Sasha Levin --- fs/kernfs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index 0798f582149f1..7d422925fc8de 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c @@ -687,7 +687,7 @@ struct kernfs_node *kernfs_new_node(struct kernfs_node *parent, struct kernfs_iattrs *attrs = READ_ONCE(parent->iattr); if (attrs) - gid = READ_ONCE(attrs->ia_gid); + gid = KGIDT_INIT(READ_ONCE(attrs->ia_gid.val)); if (flags & KERNFS_DIR) mode |= S_ISGID; -- 2.53.0