X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=kernel%2Fnsproxy.c;h=21575fc46d0597914d4b92b5749c53f59f9be4e1;hb=66e855f3f5197fec1162c5235fdb5f92b956d618;hp=f5d332cf8c631704b1ee440c35317644e4f6eff9;hpb=f9166e736e516a4b1de16577b5428afd0cffe325;p=linux-2.6 diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c index f5d332cf8c..21575fc46d 100644 --- a/kernel/nsproxy.c +++ b/kernel/nsproxy.c @@ -139,15 +139,21 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk) goto out; } - new_ns = create_new_namespaces(flags, tsk, tsk->fs); - if (IS_ERR(new_ns)) { - err = PTR_ERR(new_ns); + /* + * CLONE_NEWIPC must detach from the undolist: after switching + * to a new ipc namespace, the semaphore arrays from the old + * namespace are unreachable. In clone parlance, CLONE_SYSVSEM + * means share undolist with parent, so we must forbid using + * it along with CLONE_NEWIPC. + */ + if ((flags & CLONE_NEWIPC) && (flags & CLONE_SYSVSEM)) { + err = -EINVAL; goto out; } - err = ns_cgroup_clone(tsk); - if (err) { - put_nsproxy(new_ns); + new_ns = create_new_namespaces(flags, tsk, tsk->fs); + if (IS_ERR(new_ns)) { + err = PTR_ERR(new_ns); goto out; } @@ -197,7 +203,7 @@ int unshare_nsproxy_namespaces(unsigned long unshare_flags, goto out; } - err = ns_cgroup_clone(current); + err = ns_cgroup_clone(current, task_pid(current)); if (err) put_nsproxy(*new_nsp);