diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2018-10-17 10:23:26 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-10-18 05:32:21 -0400 |
commit | 169b803397499be85bdd1e3d07d6f5e3d4bd669e (patch) | |
tree | ada4c2e05d320dd3a275f71058bca9daad15d970 /fs/cachefiles/namei.c | |
parent | eb66ae030829605d61fbef1909ce310e29f78821 (diff) |
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: 9ae326a69004 (CacheFiles: A cache that backs onto a mounted filesystem)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/cachefiles/namei.c')
-rw-r--r-- | fs/cachefiles/namei.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index af2b17b21b94..95983c744164 100644 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c | |||
@@ -343,7 +343,7 @@ try_again: | |||
343 | trap = lock_rename(cache->graveyard, dir); | 343 | trap = lock_rename(cache->graveyard, dir); |
344 | 344 | ||
345 | /* do some checks before getting the grave dentry */ | 345 | /* do some checks before getting the grave dentry */ |
346 | if (rep->d_parent != dir) { | 346 | if (rep->d_parent != dir || IS_DEADDIR(d_inode(rep))) { |
347 | /* the entry was probably culled when we dropped the parent dir | 347 | /* the entry was probably culled when we dropped the parent dir |
348 | * lock */ | 348 | * lock */ |
349 | unlock_rename(cache->graveyard, dir); | 349 | unlock_rename(cache->graveyard, dir); |