Commit 209a7a67 authored by Tyler Hicks's avatar Tyler Hicks Committed by Ben Hutchings

eCryptfs: Invalidate dcache entries when lower i_nlink is zero

commit 5556e7e6 upstream.

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: default avatarTyler Hicks <tyhicks@canonical.com>
Reported-by: default avatarRichard Weinberger <richard@nod.at>
[bwh: Backported to 3.2:
 - Test d_revalidate pointer directly rather than a DCACHE_OP flag
 - Open-code d_inode()
 - Adjust context]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 392a99c8
...@@ -55,26 +55,26 @@ static int ecryptfs_d_revalidate(struct dentry *dentry, struct nameidata *nd) ...@@ -55,26 +55,26 @@ static int ecryptfs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
lower_dentry = ecryptfs_dentry_to_lower(dentry); lower_dentry = ecryptfs_dentry_to_lower(dentry);
lower_mnt = ecryptfs_dentry_to_lower_mnt(dentry); lower_mnt = ecryptfs_dentry_to_lower_mnt(dentry);
if (!lower_dentry->d_op || !lower_dentry->d_op->d_revalidate) if (lower_dentry->d_op && lower_dentry->d_op->d_revalidate) {
goto out; if (nd) {
if (nd) { dentry_save = nd->path.dentry;
dentry_save = nd->path.dentry; vfsmount_save = nd->path.mnt;
vfsmount_save = nd->path.mnt; nd->path.dentry = lower_dentry;
nd->path.dentry = lower_dentry; nd->path.mnt = lower_mnt;
nd->path.mnt = lower_mnt; }
} rc = lower_dentry->d_op->d_revalidate(lower_dentry, nd);
rc = lower_dentry->d_op->d_revalidate(lower_dentry, nd); if (nd) {
if (nd) { nd->path.dentry = dentry_save;
nd->path.dentry = dentry_save; nd->path.mnt = vfsmount_save;
nd->path.mnt = vfsmount_save; }
} }
if (dentry->d_inode) { if (dentry->d_inode) {
struct inode *lower_inode = struct inode *inode = dentry->d_inode;
ecryptfs_inode_to_lower(dentry->d_inode);
fsstack_copy_attr_all(dentry->d_inode, lower_inode); fsstack_copy_attr_all(inode, ecryptfs_inode_to_lower(inode));
if (!inode->i_nlink)
return 0;
} }
out:
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment