]> git.baikalelectronics.ru Git - kernel.git/commit
cachefiles: fix the race between cachefiles_bury_object() and rmdir(2)
authorAl Viro <viro@zeniv.linux.org.uk>
Fri, 5 Oct 2018 18:29:46 +0000 (14:29 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 5 Oct 2018 18:37:28 +0000 (14:37 -0400)
commit907d6f05ac2c5a8bb30145cbde7e5a167c86f63a
tree1e932e63894e23c27a6c332dedda164c02e78fbd
parent26df40bf24140f5246a79fb60ad65d619617792e
cachefiles: fix the race between cachefiles_bury_object() and rmdir(2)

the victim might've been rmdir'ed just before the lock_rename();
unlike the normal callers, we do not look the source up after the
parents are locked - we know it beforehand and just recheck that it's
still the child of what used to be its parent.  Unfortunately,
the check is too weak - we don't spot a dead directory since its
->d_parent is unchanged, dentry is positive, etc.  So we sail all
the way to ->rename(), with hosting filesystems _not_ expecting
to be asked renaming an rmdir'ed subdirectory.

The fix is easy, fortunately - the lock on parent is sufficient for
making IS_DEADDIR() on child safe.

Cc: stable@vger.kernel.org
Fixes: 5f60092fcbc4 (CacheFiles: A cache that backs onto a mounted filesystem)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/cachefiles/namei.c