From: Tejun Heo <tj@kernel.org>
To: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Christian Brauner <brauner@kernel.org>,
Meta kernel team <kernel-team@meta.com>,
driver-core@lists.linux.dev, linux-kernel@vger.kernel.org,
kernel test robot <lkp@intel.com>
Subject: Re: [PATCH] kernfs: avoid READ_ONCE() on a kgid_t in kernfs_new_node()
Date: Tue, 27 Oct 2026 04:36:44 -1000 [thread overview]
Message-ID: <auC2_Phxf55Py5km@slm.duckdns.org> (raw)
In-Reply-To: <20261027143247.3537239-1-shakeel.butt@linux.dev>
On Tue, Oct 27, 2026 at 07:32:47AM -0700, Shakeel Butt wrote:
> 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 <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202610261608.vItiXCGW-lkp@intel.com/
> Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
prev parent reply other threads:[~2026-10-27 14:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 14:32 [PATCH] kernfs: avoid READ_ONCE() on a kgid_t in kernfs_new_node() Shakeel Butt
2026-10-27 14:36 ` Tejun Heo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=auC2_Phxf55Py5km@slm.duckdns.org \
--to=tj@kernel.org \
--cc=brauner@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=shakeel.butt@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.