From: Erez Zadok Date: Thu, 18 Sep 2008 23:55:19 +0000 (-0400) Subject: Unionfs: unionfs_permission locking fixes X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=8dbb9f510cf4efd79f43b0b2434cda227b37f29b;p=unionfs-2.6.39.y.git Unionfs: unionfs_permission locking fixes Signed-off-by: Erez Zadok --- diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c index 8d42f7213a9..800648e6017 100644 --- a/fs/unionfs/inode.c +++ b/fs/unionfs/inode.c @@ -785,6 +785,11 @@ static int unionfs_permission(struct inode *inode, int mask) int bindex, bstart, bend; const int is_file = !S_ISDIR(inode->i_mode); const int write_mask = (mask & MAY_WRITE) && !(mask & MAY_READ); + struct inode *inode_grabbed = igrab(inode); + struct dentry *dentry = d_find_alias(inode); + + if (dentry) + unionfs_lock_dentry(dentry, UNIONFS_DMUTEX_CHILD); if (!UNIONFS_I(inode)->lower_inodes) { if (is_file) /* dirs can be unlinked but chdir'ed to */ @@ -859,6 +864,11 @@ static int unionfs_permission(struct inode *inode, int mask) out: unionfs_check_inode(inode); + if (dentry) { + unionfs_unlock_dentry(dentry); + dput(dentry); + } + iput(inode_grabbed); return err; }