]> Git Repo - linux.git/commit
rename(): avoid a deadlock in the case of parents having no common ancestor
authorAl Viro <[email protected]>
Tue, 21 Nov 2023 01:02:11 +0000 (20:02 -0500)
committerAl Viro <[email protected]>
Sat, 25 Nov 2023 07:54:14 +0000 (02:54 -0500)
commita8b0026847b8c43445c921ad2c85521c92eb175f
tree39078ede8594fab57ee0486e522655df86cb131f
parentdbd4540df2b2857a91593754275c02f3e415fc30
rename(): avoid a deadlock in the case of parents having no common ancestor

... and fix the directory locking documentation and proof of correctness.
Holding ->s_vfs_rename_mutex *almost* prevents ->d_parent changes; the
case where we really don't want it is splicing the root of disconnected
tree to somewhere.

In other words, ->s_vfs_rename_mutex is sufficient to stabilize "X is an
ancestor of Y" only if X and Y are already in the same tree.  Otherwise
it can go from false to true, and one can construct a deadlock on that.

Make lock_two_directories() report an error in such case and update the
callers of lock_rename()/lock_rename_child() to handle such errors.

And yes, such conditions are not impossible to create ;-/

Reviewed-by: Jan Kara <[email protected]>
Signed-off-by: Al Viro <[email protected]>
Documentation/filesystems/directory-locking.rst
Documentation/filesystems/porting.rst
fs/cachefiles/namei.c
fs/ecryptfs/inode.c
fs/namei.c
fs/nfsd/vfs.c
fs/overlayfs/copy_up.c
fs/overlayfs/dir.c
fs/overlayfs/super.c
fs/overlayfs/util.c
fs/smb/server/vfs.c
This page took 0.05998 seconds and 4 git commands to generate.