Skip to content

Commit

Permalink
eCryptfs: Invalidate dcache entries when lower i_nlink is zero
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reported-by: Richard Weinberger <[email protected]>
Cc: [email protected]
  • Loading branch information
tyhicks committed Aug 18, 2015
1 parent 4469942 commit 5556e7e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions fs/ecryptfs/dentry.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@
static int ecryptfs_d_revalidate(struct dentry *dentry, unsigned int flags)
{
struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
int rc;

if (!(lower_dentry->d_flags & DCACHE_OP_REVALIDATE))
return 1;
int rc = 1;

if (flags & LOOKUP_RCU)
return -ECHILD;

rc = lower_dentry->d_op->d_revalidate(lower_dentry, flags);
if (lower_dentry->d_flags & DCACHE_OP_REVALIDATE)
rc = lower_dentry->d_op->d_revalidate(lower_dentry, flags);

if (d_really_is_positive(dentry)) {
struct inode *lower_inode =
ecryptfs_inode_to_lower(d_inode(dentry));
struct inode *inode = d_inode(dentry);

fsstack_copy_attr_all(d_inode(dentry), lower_inode);
fsstack_copy_attr_all(inode, ecryptfs_inode_to_lower(inode));
if (!inode->i_nlink)
return 0;
}
return rc;
}
Expand Down

0 comments on commit 5556e7e

Please sign in to comment.