Re: [PATCH 13/19] VFS: lock dentry for ->revalidate to avoid races with rename etc

From: Al Viro
Date: Wed Feb 12 2025 - 16:22:41 EST


On Sat, Feb 08, 2025 at 01:30:43AM +0000, Al Viro wrote:
> HOWEVER, if you do not bother with doing that before ->d_unalias_trylock()
> (and there's no reason to do that), the whole thing becomes much simpler -
> you can do the check inside __d_move(), after all locks had been taken.
>
> After
> spin_lock_nested(&dentry->d_lock, 2);
> spin_lock_nested(&target->d_lock, 3);
> you have everything stable. Just make the sucker return bool instead
> of void, check that crap and have it return false if there's a problem.

... except that this requires telling __d_move() that it's an unalias -
on normal move dentries will have been locked by the caller. Might
make sense to turn that bool exchange argument into an enum...

Let me play with that a bit and see what falls out...