Re: [PATCH] namei: Use READ_ONCE() for d_flags in __follow_mount_rcu()

From: Christian Brauner

Date: Wed Jul 22 2026 - 05:28:46 EST


On Wed, Jul 15, 2026 at 05:51:45PM +0200, Jan Kara wrote:
> On Wed 15-07-26 20:50:57, Ze Tan wrote:
> > __follow_mount_rcu() reads dentry->d_flags without holding d_lock.
> >
> > Use READ_ONCE() for these reads to make the lockless access clear.
> >
> > Signed-off-by: Ze Tan <tanze@xxxxxxxxxx>
>
> Hum, so we are somewhat sloppy with the access to d_flags. Strictly
> speaking we should be using WRITE_ONCE when updating them (and we do in
> some places but not in others) and READ_ONCE when accessing them. OTOH the
> only practical problem is KCSAN complaining, the problems that the compiler
> could somehow tear stores to the d_flags are IMHO theoretical.
>
> Having two accesses without READ_ONCE more or less doesn't really matter in
> my opinion. Cleaning up all the d_flags accesses would make some sense but
> I'm not sure it's worth the churn for mostly theoretical issues (I believe
> Al or Christian was against it if my memory serves well).

I don't care for the churn but personally I wouldn't oppose the change.