Miklos Szeredi 68b47139ea [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:

  http://www.inf.bme.hu/~mszeredi/nstest.c

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
copy_namespace().

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 <miklos@szeredi.hu>
Acked-by: Jamie Lokier <jamie@shareable.org>
Cc: <viro@parcelfarce.linux.theplanet.co.uk>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-08-07 10:00:38 -07:00
..
2005-06-30 22:29:48 -07:00
2005-06-30 08:45:12 -07:00
2005-07-14 09:00:25 -07:00
2005-08-06 09:42:06 -07:00
2005-07-15 08:14:44 +02:00
2005-06-28 21:20:31 -07:00
2005-07-12 20:38:38 -07:00
2005-07-29 13:12:49 -07:00
2005-06-30 08:45:11 -07:00
2005-07-12 20:38:38 -07:00
2005-08-07 10:00:38 -07:00
2005-07-12 16:01:02 -07:00
2005-07-12 20:38:38 -07:00
2005-06-24 00:05:19 -07:00
2005-07-27 16:26:06 -07:00
2005-07-12 20:38:38 -07:00
2005-08-04 13:11:15 -07:00
2005-07-27 16:26:06 -07:00
2005-07-12 20:38:38 -07:00
2005-07-12 20:38:38 -07:00
2005-07-12 20:38:38 -07:00
2005-07-12 20:38:38 -07:00