Date:2010-03-19 20:35:46 (12 years 6 months ago)
Author:Jeff Mahoney
Message:ecryptfs: fix use with tmpfs by removing d_drop from ecryptfs_destroy_inode

Since tmpfs has no persistent storage, it pins all its dentries in memory
so they have d_count=1 when other file systems would have d_count=0.
->lookup is only used to create new dentries. If the caller doesn't
instantiate it, it's freed immediately at dput(). ->readdir reads
directly from the dcache and depends on the dentries being hashed.

When an ecryptfs mount is mounted, it associates the lower file and dentry
with the ecryptfs files as they're accessed. When it's umounted and
destroys all the in-memory ecryptfs inodes, it fput's the lower_files and
d_drop's the lower_dentries. Commit 4981e081 added this and a d_delete in
2008 and several months later commit caeeeecf removed the d_delete. I
believe the d_drop() needs to be removed as well.

The d_drop effectively hides any file that has been accessed via ecryptfs
from the underlying tmpfs since it depends on it being hashed for it to
be accessible. I've removed the d_drop on my development node and see no
ill effects with basic testing on both tmpfs and persistent storage.

As a side effect, after ecryptfs d_drops the dentries on tmpfs, tmpfs
BUGs on umount. This is due to the dentries being unhashed.
tmpfs->kill_sb is kill_litter_super which calls d_genocide to drop
the reference pinning the dentry. It skips unhashed and negative dentries,
but shrink_dcache_for_umount_subtree doesn't. Since those dentries
still have an elevated d_count, we get a BUG().

This patch removes the d_drop call and fixes both issues.

This issue was reported at:

Reported-by: Árpád Bíró <>
Signed-off-by: Jeff Mahoney <>
Cc: Dustin Kirkland <>
Signed-off-by: Tyler Hicks <>
Files: fs/ecryptfs/super.c (1 diff)

Change Details

8585        if (lower_dentry->d_inode) {
8686            fput(inode_info->lower_file);
8787            inode_info->lower_file = NULL;
88            d_drop(lower_dentry);
8988        }
9089    }
9190    ecryptfs_destroy_crypt_stat(&inode_info->crypt_stat);

Archive Download the corresponding diff file