diff options
author | Tyler Hicks <tyhicks@canonical.com> | 2015-08-05 12:26:36 -0400 |
---|---|---|
committer | Tyler Hicks <tyhicks@canonical.com> | 2015-08-18 18:29:48 -0400 |
commit | 5556e7e6d30e8e9b5ee51b0e5edd526ee80e5e36 (patch) | |
tree | 58681123e05bcd96b246de427babcfa756acd27e /fs/ecryptfs/dentry.c | |
parent | 4469942bbbe5ebf845e04971d8c74e9b6178f9fa (diff) |
eCryptfs: Invalidate dcache entries when lower i_nlink is zero
Consider eCryptfs dcache entries to be stale when the corresponding
lower inode's i_nlink count is zero. This solves a problem caused by the
lower inode being directly modified, without going through the eCryptfs
mount, leaving stale eCryptfs dentries cached and the eCryptfs inode's
i_nlink count not being cleared.
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Reported-by: Richard Weinberger <richard@nod.at>
Cc: stable@vger.kernel.org
Diffstat (limited to 'fs/ecryptfs/dentry.c')
-rw-r--r-- | fs/ecryptfs/dentry.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/fs/ecryptfs/dentry.c b/fs/ecryptfs/dentry.c index 8db0b464483f..63cd2c147221 100644 --- a/fs/ecryptfs/dentry.c +++ b/fs/ecryptfs/dentry.c | |||
@@ -45,20 +45,20 @@ | |||
45 | static int ecryptfs_d_revalidate(struct dentry *dentry, unsigned int flags) | 45 | static int ecryptfs_d_revalidate(struct dentry *dentry, unsigned int flags) |
46 | { | 46 | { |
47 | struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry); | 47 | struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry); |
48 | int rc; | 48 | int rc = 1; |
49 | |||
50 | if (!(lower_dentry->d_flags & DCACHE_OP_REVALIDATE)) | ||
51 | return 1; | ||
52 | 49 | ||
53 | if (flags & LOOKUP_RCU) | 50 | if (flags & LOOKUP_RCU) |
54 | return -ECHILD; | 51 | return -ECHILD; |
55 | 52 | ||
56 | rc = lower_dentry->d_op->d_revalidate(lower_dentry, flags); | 53 | if (lower_dentry->d_flags & DCACHE_OP_REVALIDATE) |
54 | rc = lower_dentry->d_op->d_revalidate(lower_dentry, flags); | ||
55 | |||
57 | if (d_really_is_positive(dentry)) { | 56 | if (d_really_is_positive(dentry)) { |
58 | struct inode *lower_inode = | 57 | struct inode *inode = d_inode(dentry); |
59 | ecryptfs_inode_to_lower(d_inode(dentry)); | ||
60 | 58 | ||
61 | fsstack_copy_attr_all(d_inode(dentry), lower_inode); | 59 | fsstack_copy_attr_all(inode, ecryptfs_inode_to_lower(inode)); |
60 | if (!inode->i_nlink) | ||
61 | return 0; | ||
62 | } | 62 | } |
63 | return rc; | 63 | return rc; |
64 | } | 64 | } |