tree 807d693b22a11f7667cd16e90b43618f85f8a4e0
parent 9ae5b3c703cce89a7d8ccf25fe16955ec6f016c0
author Miklos Szeredi <[EMAIL PROTECTED]> Sun, 07 Aug 2005 23:42:25 -0700
committer Linus Torvalds <[EMAIL PROTECTED]> Mon, 08 Aug 2005 00:00:38 -0700

[PATCH] namespace.c: fix bind mount from foreign namespace

I'm resending this patch, because I still believe it's the correct fix.

Tested before/after applying the patch with a test application
available from:

Bind mount from a foreign namespace results in an un-removable mount.
The reason is that mnt->mnt_namespace is copied from the old mount in
clone_mnt().  Because of this check_mnt() in sys_umount() will fail.

The solution is to set mnt->mnt_namespace to current->namespace in
clone_mnt().  clone_mnt() is either called from do_loopback() or
copy_tree().  copy_tree() is called from do_loopback() or

When called (directly or indirectly) from do_loopback(), always
current->namspace is being modified: check_mnt(nd->mnt).  So setting
mnt->mnt_namespace to current->namspace is the right thing to do.

When called from copy_namespace(), the setting of mnt_namespace is
irrelevant, since mnt_namespace is reset later in that function for
all copied mounts.

Jamie said:

  This patch is correct.  The old code was buggy for more fundamental and
  serious reason: it broke the invariant that a tree of vfsmnts all have the
  same value of mnt_namespace (and the same for the mnt_list list).

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

 fs/namespace.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/namespace.c b/fs/namespace.c
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -160,7 +160,7 @@ clone_mnt(struct vfsmount *old, struct d
                mnt->mnt_root = dget(root);
                mnt->mnt_mountpoint = mnt->mnt_root;
                mnt->mnt_parent = mnt;
-               mnt->mnt_namespace = old->mnt_namespace;
+               mnt->mnt_namespace = current->namespace;
                /* stick the duplicate mount on the same expiry list
                 * as the original if that was on one */
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