diff options
author | Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk> | 2004-07-22 03:01:38 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-07-22 03:01:38 -0700 |
commit | c8465172e6f7749fcd23f11d7ff9fef4ce1199f0 (patch) | |
tree | bd9b580c19c2fb5753972dcdee9160ba72bd01d0 /fs | |
parent | 423f871131246de2ec3819a76e79f5c94edd052b (diff) | |
download | history-c8465172e6f7749fcd23f11d7ff9fef4ce1199f0.tar.gz |
[PATCH] Missing mnt_namespace update in copy_namespace()
copy_namespace() forgets to switch the new 'mnt_namespace' field in the
vfsmounts of the new namespace.
Diffstat (limited to 'fs')
-rw-r--r-- | fs/namespace.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index a8d4d0092e15d5..9e8350d458f25b 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1037,6 +1037,7 @@ int copy_namespace(int flags, struct task_struct *tsk) 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 @@ int copy_namespace(int flags, struct task_struct *tsk) 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 @@ int copy_namespace(int flags, struct task_struct *tsk) 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); |