]> git.kernelconcepts.de Git - karo-tx-linux.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)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 13 Apr 2016 03:01:35 +0000 (20:01 -0700)
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>
Cc: stable <stable@vger.kernel.org>
fs/crypto/crypto.c
fs/ext4/crypto.c

index da70520f3ab4b588eb2d30715abd5bfa2233a955..2fc8c43ce531de02379c93e85c03f95c0d3ca793 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/ratelimit.h>
 #include <linux/bio.h>
 #include <linux/dcache.h>
+#include <linux/namei.h>
 #include <linux/fscrypto.h>
 #include <linux/ecryptfs.h>
 
@@ -353,6 +354,9 @@ static int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags)
        struct fscrypt_info *ci;
        int dir_has_key, cached_with_key;
 
+       if (flags & LOOKUP_RCU)
+               return -ECHILD;
+
        dir = dget_parent(dentry);
        if (!d_inode(dir)->i_sb->s_cop->is_encrypted(d_inode(dir))) {
                dput(dir);
index db9ae6e18154d851126d9b9ca4785af012893a2d..6a6c27373b5467d11dcfc056b3c17dec5cccde3b 100644 (file)
@@ -32,6 +32,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"
@@ -482,6 +483,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);