tree 1d0fd24ce8d49c139b0b01c5ce59f073d3ae20a9
parent deac66ae454cacf942c051b86d9232af546fb187
author Miklos Szeredi <[EMAIL PROTECTED]> Wed, 07 Sep 2005 05:19:36 -0700
committer Linus Torvalds <[EMAIL PROTECTED]> Thu, 08 Sep 2005 06:58:01 -0700

[PATCH] pivot_root() circular reference fix


When pivot_root is called from an init script in an initramfs environment,
it causes a circular reference in the mount tree.

The cause of this is that pivot_root() is not prepared to handle pivoting
an unattached mount.  In an initramfs environment, rootfs is the root of
the namespace, and so it is not attached.

This patch fixes this and related problems, by returning -EINVAL if either
the current root or the new root is detached.

Signed-off-by: Miklos Szeredi <[EMAIL PROTECTED]>
Acked-by: Al Viro <[EMAIL PROTECTED]>
Cc: Christoph Hellwig <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>

 fs/namespace.c |    4 ++++
 1 files changed, 4 insertions(+)

diff --git a/fs/namespace.c b/fs/namespace.c
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1334,8 +1334,12 @@ asmlinkage long sys_pivot_root(const cha
        error = -EINVAL;
        if (user_nd.mnt->mnt_root != user_nd.dentry)
                goto out2; /* not a mountpoint */
+       if (user_nd.mnt->mnt_parent == user_nd.mnt)
+               goto out2; /* not attached */
        if (new_nd.mnt->mnt_root != new_nd.dentry)
                goto out2; /* not a mountpoint */
+       if (new_nd.mnt->mnt_parent == new_nd.mnt)
+               goto out2; /* not attached */
        tmp = old_nd.mnt; /* make sure we can reach put_old from new_root */
        if (tmp != new_nd.mnt) {
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at

Reply via email to