Re: [RFC PATCH] namei: revalidate the symlink dentry before invoking get_link in RCU-walk

From: Christian Brauner

Date: Fri Nov 20 2026 - 09:00:56 EST


On Wed, Nov 18, 2026 at 04:39:45PM +0800, Qing Zhang wrote:
> XFS can recycle a reclaimable inode in place without waiting for
> pre-existing RCU readers to complete. The recycle path calls
> xfs_reinit_inode(), which calls inode_init_always() and resets i_op
> to empty_iops. A reader retaining an inode pointer from the previous
> VFS lifetime can therefore sample a NULL get_link callback.

Thanks for the very detailed analysis. This can't be fixed by namei.

> + /* Reject a stale snapshot before invoking the callback. */
> + if (unlikely(read_seqcount_retry(&link->dentry->d_seq,
> + last->seq) || !get))
> + return ERR_PTR(-ECHILD);

This only makes the window smaller.

XFS can still reinitialize the inode right after this check and while
get() is running. Then ->get_link() operates on an inode that is being
reset underneath it. And the !get check only catches the case where the
that re-init already finished before we loaded ->get_link.

RCU pathwalk relies on inode memory not being reused before a grace
period has passed. XFS itself frees inodes via call_rcu() but the
recycle path hands the same struct inode out again without waiting for
existing RCU walkers.

So that should be fixed in XFS, either by not recycling an inode in
place while RCU walkers can still see it or by keeping i_op and the link
state valid across a recycle.