__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 --- fs/namei.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 19ce43c9a6e6..cc8e8d961d7e 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1687,7 +1687,7 @@ EXPORT_SYMBOL(follow_down); static bool __follow_mount_rcu(struct nameidata *nd, struct path *path) { struct dentry *dentry = path->dentry; - unsigned int flags = dentry->d_flags; + unsigned int flags = READ_ONCE(dentry->d_flags); if (unlikely(nd->flags & LOOKUP_NO_XDEV)) return false; @@ -1701,7 +1701,7 @@ static bool __follow_mount_rcu(struct nameidata *nd, struct path *path) int res = dentry->d_op->d_manage(path, true); if (res) return res == -EISDIR; - flags = dentry->d_flags; + flags = READ_ONCE(dentry->d_flags); } if (flags & DCACHE_MOUNTED) { @@ -1711,7 +1711,7 @@ static bool __follow_mount_rcu(struct nameidata *nd, struct path *path) dentry = path->dentry = mounted->mnt.mnt_root; nd->state |= ND_JUMPED; nd->next_seq = read_seqcount_begin(&dentry->d_seq); - flags = dentry->d_flags; + flags = READ_ONCE(dentry->d_flags); // makes sure that non-RCU pathwalk could reach // this state. if (read_seqretry(&mount_lock, nd->m_seq)) -- 2.43.0