[ 3.8.y.z extended stable ] Patch "pidns: fix vfork() after unshare(CLONE_NEWPID)" has been added to staging queue
kamal at canonical.com
Fri Sep 20 00:36:30 UTC 2013
This is a note to let you know that I have just added a patch titled
pidns: fix vfork() after unshare(CLONE_NEWPID)
to the linux-3.8.y-queue branch of the 3.8.y.z extended stable tree
which can be found at:
This patch is scheduled to be released in version 184.108.40.206.
If you, or anyone else, feels it should not be added to this tree, please
reply to this email.
For more information about the 3.8.y.z tree, see
>From 0d863c98ce9b3cb4c096d74bdadf0864bd26c72c Mon Sep 17 00:00:00 2001
From: Oleg Nesterov <oleg at redhat.com>
Date: Wed, 11 Sep 2013 14:19:38 -0700
Subject: pidns: fix vfork() after unshare(CLONE_NEWPID)
commit e79f525e99b04390ca4d2366309545a836c03bf1 upstream.
Commit 8382fcac1b81 ("pidns: Outlaw thread creation after
unshare(CLONE_NEWPID)") nacks CLONE_VM if the forking process unshared
pid_ns, this obviously breaks vfork:
assert(unshare(CLONE_NEWUSER | CLONE_NEWPID) == 0);
assert(vfork() >= 0);
fails without this patch.
Change this check to use CLONE_SIGHAND instead. This also forbids
CLONE_THREAD automatically, and this is what the comment implies.
We could probably even drop CLONE_SIGHAND and use CLONE_THREAD, but it
would be safer to not do this. The current check denies CLONE_SIGHAND
implicitely and there is no reason to change this.
Eric said "CLONE_SIGHAND is fine. CLONE_THREAD would be even better.
Having shared signal handling between two different pid namespaces is
the case that we are fundamentally guarding against."
Signed-off-by: Oleg Nesterov <oleg at redhat.com>
Reported-by: Colin Walters <walters at redhat.com>
Acked-by: Andy Lutomirski <luto at amacapital.net>
Reviewed-by: "Eric W. Biederman" <ebiederm at xmission.com>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
[ kamal: backport to 3.8 (context) ]
Signed-off-by: Kamal Mostafa <kamal at canonical.com>
kernel/fork.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/kernel/fork.c b/kernel/fork.c
index 1c53e38..5c992f8 100644
@@ -1170,10 +1170,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
- * If the new process will be in a different pid namespace
- * don't allow the creation of threads.
+ * If the new process will be in a different pid namespace don't
+ * allow it to share a thread group or signal handlers with the
+ * forking task.
- if ((clone_flags & (CLONE_VM|CLONE_NEWPID)) &&
+ if ((clone_flags & (CLONE_SIGHAND | CLONE_NEWPID)) &&
(task_active_pid_ns(current) != current->nsproxy->pid_ns))
More information about the kernel-team