mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* check_mnt() breaks namespaces
@ 2004-07-14 23:36 Herbert Poetzl
  2004-07-18 21:28 ` [PATCH] " viro
  0 siblings, 1 reply; 2+ messages in thread
From: Herbert Poetzl @ 2004-07-14 23:36 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, viro


Hi Andrew!

the check_mnt() in do_add_mount() breaks namespaces
in that way, that it forbids mounting single sb 
filesystems (like procfs) to be mounted in different
namespaces ...

I guess this is unintentional, but who knows ...
(this was introduced in 2.6.8-rc1, 2.6.7-bk20 works
as expected) 


something like this (untested) fixes? it ...

diff -NurpP --minimal linux-2.6.8-rc1/fs/namei.c linux-2.6.8-rc1-fix/fs/namei.c
--- linux-2.6.8-rc1/fs/namei.c  2004-07-12 14:47:08.000000000 +0200
+++ linux-2.6.8-rc1-fix/fs/namei.c        2004-07-12 14:59:08.000000000 +0200
@@ -794,7 +819,5 @@ int do_add_mount(struct vfsmount *newmnt
                ;
-       err = -EINVAL;
-       if (!check_mnt(nd->mnt))
-               goto unlock;

        /* Refuse the same filesystem on the same mount point */
        err = -EBUSY;

best,
Herbert


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] Re: check_mnt() breaks namespaces
  2004-07-14 23:36 check_mnt() breaks namespaces Herbert Poetzl
@ 2004-07-18 21:28 ` viro
  0 siblings, 0 replies; 2+ messages in thread
From: viro @ 2004-07-18 21:28 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel; +Cc: Linus Torvalds

	It's not check_mnt(), it's breakage in copy_namespace().
It forgets to switch new field (->mnt_namespace) in the vfsmounts
of new namespace.

--- ../RC8-rc2/fs/namespace.c	Sun Jul 18 09:08:42 2004
+++ fs/namespace.c	Sun Jul 18 17:23:15 2004
@@ -1037,6 +1037,7 @@
 	struct namespace *new_ns;
 	struct vfsmount *rootmnt = NULL, *pwdmnt = NULL, *altrootmnt = NULL;
 	struct fs_struct *fs = tsk->fs;
+	struct vfsmount *p, *q;
 
 	if (!namespace)
 		return 0;
@@ -1071,14 +1072,16 @@
 	list_add_tail(&new_ns->list, &new_ns->root->mnt_list);
 	spin_unlock(&vfsmount_lock);
 
-	/* Second pass: switch the tsk->fs->* elements */
-	if (fs) {
-		struct vfsmount *p, *q;
-		write_lock(&fs->lock);
-
-		p = namespace->root;
-		q = new_ns->root;
-		while (p) {
+	/*
+	 * Second pass: switch the tsk->fs->* elements and mark new vfsmounts
+	 * as belonging to new namespace.  We have already acquired a private
+	 * fs_struct, so tsk->fs->lock is not needed.
+	 */
+	p = namespace->root;
+	q = new_ns->root;
+	while (p) {
+		q->mnt_namespace = new_ns;
+		if (fs) {
 			if (p == fs->rootmnt) {
 				rootmnt = p;
 				fs->rootmnt = mntget(q);
@@ -1091,10 +1094,9 @@
 				altrootmnt = p;
 				fs->altrootmnt = mntget(q);
 			}
-			p = next_mnt(p, namespace->root);
-			q = next_mnt(q, new_ns->root);
 		}
-		write_unlock(&fs->lock);
+		p = next_mnt(p, namespace->root);
+		q = next_mnt(q, new_ns->root);
 	}
 	up_write(&tsk->namespace->sem);
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-07-18 21:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-14 23:36 check_mnt() breaks namespaces Herbert Poetzl
2004-07-18 21:28 ` [PATCH] " viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®