Commit c8465172 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[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.
parent 423f8711
...@@ -1037,6 +1037,7 @@ int copy_namespace(int flags, struct task_struct *tsk) ...@@ -1037,6 +1037,7 @@ int copy_namespace(int flags, struct task_struct *tsk)
struct namespace *new_ns; struct namespace *new_ns;
struct vfsmount *rootmnt = NULL, *pwdmnt = NULL, *altrootmnt = NULL; struct vfsmount *rootmnt = NULL, *pwdmnt = NULL, *altrootmnt = NULL;
struct fs_struct *fs = tsk->fs; struct fs_struct *fs = tsk->fs;
struct vfsmount *p, *q;
if (!namespace) if (!namespace)
return 0; return 0;
...@@ -1071,14 +1072,16 @@ int copy_namespace(int flags, struct task_struct *tsk) ...@@ -1071,14 +1072,16 @@ int copy_namespace(int flags, struct task_struct *tsk)
list_add_tail(&new_ns->list, &new_ns->root->mnt_list); list_add_tail(&new_ns->list, &new_ns->root->mnt_list);
spin_unlock(&vfsmount_lock); spin_unlock(&vfsmount_lock);
/* Second pass: switch the tsk->fs->* elements */ /*
if (fs) { * Second pass: switch the tsk->fs->* elements and mark new vfsmounts
struct vfsmount *p, *q; * as belonging to new namespace. We have already acquired a private
write_lock(&fs->lock); * fs_struct, so tsk->fs->lock is not needed.
*/
p = namespace->root; p = namespace->root;
q = new_ns->root; q = new_ns->root;
while (p) { while (p) {
q->mnt_namespace = new_ns;
if (fs) {
if (p == fs->rootmnt) { if (p == fs->rootmnt) {
rootmnt = p; rootmnt = p;
fs->rootmnt = mntget(q); fs->rootmnt = mntget(q);
...@@ -1091,11 +1094,10 @@ int copy_namespace(int flags, struct task_struct *tsk) ...@@ -1091,11 +1094,10 @@ int copy_namespace(int flags, struct task_struct *tsk)
altrootmnt = p; altrootmnt = p;
fs->altrootmnt = mntget(q); fs->altrootmnt = mntget(q);
} }
}
p = next_mnt(p, namespace->root); p = next_mnt(p, namespace->root);
q = next_mnt(q, new_ns->root); q = next_mnt(q, new_ns->root);
} }
write_unlock(&fs->lock);
}
up_write(&tsk->namespace->sem); up_write(&tsk->namespace->sem);
tsk->namespace = new_ns; tsk->namespace = new_ns;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment