]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ext4/fscrypto: avoid RCU lookup in d_revalidate
authorJaegeuk Kim <jaegeuk@kernel.org>
Tue, 12 Apr 2016 23:05:36 +0000 (16:05 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 May 2016 21:49:12 +0000 (14:49 -0700)
commit 03a8bb0e53d9562276045bdfcf2b5de2e4cff5a1 upstream.

As Al pointed, d_revalidate should return RCU lookup before using d_inode.
This was originally introduced by:
commit 34286d666230 ("fs: rcu-walk aware d_revalidate method").

Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/crypto.c

index ecb54394492acbe7815410c9dfe66d9acd5b644b..25634c3531910a01cb889d45b8689ba7a7776feb 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/random.h>
 #include <linux/scatterlist.h>
 #include <linux/spinlock_types.h>
+#include <linux/namei.h>
 
 #include "ext4_extents.h"
 #include "xattr.h"
@@ -479,6 +480,9 @@ static int ext4_d_revalidate(struct dentry *dentry, unsigned int flags)
        struct ext4_crypt_info *ci;
        int dir_has_key, cached_with_key;
 
+       if (flags & LOOKUP_RCU)
+               return -ECHILD;
+
        dir = dget_parent(dentry);
        if (!ext4_encrypted_inode(d_inode(dir))) {
                dput(dir);