]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
Fix ->d_lock locking order in unlazy_walk()
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 13 Jul 2011 01:40:23 +0000 (21:40 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 13 Jul 2011 01:40:23 +0000 (21:40 -0400)
Make sure that child is still a child of parent before nested locking
of child->d_lock in unlazy_walk(); otherwise we are risking a violation
of locking order and deadlocks.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namei.c

index 0223c41fb1146cb529a92c784912498e15829a00..5c867dd1c0b34c52f03b558e9dc804d3dfddfbbe 100644 (file)
@@ -433,6 +433,8 @@ static int unlazy_walk(struct nameidata *nd, struct dentry *dentry)
                        goto err_parent;
                BUG_ON(nd->inode != parent->d_inode);
        } else {
+               if (dentry->d_parent != parent)
+                       goto err_parent;
                spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
                if (!__d_rcu_to_refcount(dentry, nd->seq))
                        goto err_child;