]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] proc_check_root() locking fix
authorAndrew Morton <akpm@osdl.org>
Wed, 4 Feb 2004 02:48:48 +0000 (18:48 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Wed, 4 Feb 2004 02:48:48 +0000 (18:48 -0800)
From: Maneesh Soni <maneesh@in.ibm.com>

The patch fixes locking in proc_check_root().  It brings is_subdir() call
under vfsmount_lock.  Holding vfsmount_lock will ensure mnt_mountpoint
dentry is intact and the dentry does not go away while it is being checked
in is_subdir().

fs/proc/base.c

index 363af5b73d24fd4ede37a02c5a280d8953237f57..7f2ab96dfd957202e8f13562614b15126fdf1608 100644 (file)
@@ -425,17 +425,15 @@ static int proc_check_root(struct inode *inode)
        mnt = vfsmnt;
 
        while (vfsmnt != our_vfsmnt) {
-               if (vfsmnt == vfsmnt->mnt_parent) {
-                       spin_unlock(&vfsmount_lock);
+               if (vfsmnt == vfsmnt->mnt_parent)
                        goto out;
-               }
                de = vfsmnt->mnt_mountpoint;
                vfsmnt = vfsmnt->mnt_parent;
        }
-       spin_unlock(&vfsmount_lock);
 
        if (!is_subdir(de, base))
                goto out;
+       spin_unlock(&vfsmount_lock);
 
 exit:
        dput(base);
@@ -444,6 +442,7 @@ exit:
        mntput(mnt);
        return res;
 out:
+       spin_unlock(&vfsmount_lock);
        res = -EACCES;
        goto exit;
 }