diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-04-12 19:05:36 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-04-12 23:01:35 -0400 |
commit | 03a8bb0e53d9562276045bdfcf2b5de2e4cff5a1 (patch) | |
tree | 558c4c5fe4471d2570a23bb16dbe85c8ee0999ed | |
parent | b32e4482aadfd1322357f46d4ed8a990603664d9 (diff) |
ext4/fscrypto: avoid RCU lookup in d_revalidate
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>
-rw-r--r-- | fs/crypto/crypto.c | 4 | ||||
-rw-r--r-- | fs/ext4/crypto.c | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c index da70520f3ab4..2fc8c43ce531 100644 --- a/fs/crypto/crypto.c +++ b/fs/crypto/crypto.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/ratelimit.h> | 26 | #include <linux/ratelimit.h> |
27 | #include <linux/bio.h> | 27 | #include <linux/bio.h> |
28 | #include <linux/dcache.h> | 28 | #include <linux/dcache.h> |
29 | #include <linux/namei.h> | ||
29 | #include <linux/fscrypto.h> | 30 | #include <linux/fscrypto.h> |
30 | #include <linux/ecryptfs.h> | 31 | #include <linux/ecryptfs.h> |
31 | 32 | ||
@@ -353,6 +354,9 @@ static int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags) | |||
353 | struct fscrypt_info *ci; | 354 | struct fscrypt_info *ci; |
354 | int dir_has_key, cached_with_key; | 355 | int dir_has_key, cached_with_key; |
355 | 356 | ||
357 | if (flags & LOOKUP_RCU) | ||
358 | return -ECHILD; | ||
359 | |||
356 | dir = dget_parent(dentry); | 360 | dir = dget_parent(dentry); |
357 | if (!d_inode(dir)->i_sb->s_cop->is_encrypted(d_inode(dir))) { | 361 | if (!d_inode(dir)->i_sb->s_cop->is_encrypted(d_inode(dir))) { |
358 | dput(dir); | 362 | dput(dir); |
diff --git a/fs/ext4/crypto.c b/fs/ext4/crypto.c index db9ae6e18154..6a6c27373b54 100644 --- a/fs/ext4/crypto.c +++ b/fs/ext4/crypto.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/random.h> | 32 | #include <linux/random.h> |
33 | #include <linux/scatterlist.h> | 33 | #include <linux/scatterlist.h> |
34 | #include <linux/spinlock_types.h> | 34 | #include <linux/spinlock_types.h> |
35 | #include <linux/namei.h> | ||
35 | 36 | ||
36 | #include "ext4_extents.h" | 37 | #include "ext4_extents.h" |
37 | #include "xattr.h" | 38 | #include "xattr.h" |
@@ -482,6 +483,9 @@ static int ext4_d_revalidate(struct dentry *dentry, unsigned int flags) | |||
482 | struct ext4_crypt_info *ci; | 483 | struct ext4_crypt_info *ci; |
483 | int dir_has_key, cached_with_key; | 484 | int dir_has_key, cached_with_key; |
484 | 485 | ||
486 | if (flags & LOOKUP_RCU) | ||
487 | return -ECHILD; | ||
488 | |||
485 | dir = dget_parent(dentry); | 489 | dir = dget_parent(dentry); |
486 | if (!ext4_encrypted_inode(d_inode(dir))) { | 490 | if (!ext4_encrypted_inode(d_inode(dir))) { |
487 | dput(dir); | 491 | dput(dir); |