diff options
author | Oleg Nesterov <oleg@redhat.com> | 2013-09-11 17:19:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-11 18:56:19 -0400 |
commit | e79f525e99b04390ca4d2366309545a836c03bf1 (patch) | |
tree | 06fcca5d6cf0e093b7642f7192bfddc92baed108 /kernel | |
parent | 3b8967d713d7426e9dd107d065208b84adface91 (diff) |
pidns: fix vfork() after unshare(CLONE_NEWPID)
Commit 8382fcac1b81 ("pidns: Outlaw thread creation after
unshare(CLONE_NEWPID)") nacks CLONE_VM if the forking process unshared
pid_ns, this obviously breaks vfork:
int main(void)
{
assert(unshare(CLONE_NEWUSER | CLONE_NEWPID) == 0);
assert(vfork() >= 0);
_exit(0);
return 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@redhat.com>
Reported-by: Colin Walters <walters@redhat.com>
Acked-by: Andy Lutomirski <luto@amacapital.net>
Reviewed-by: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/fork.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index c9eaf2013002..3561391ca450 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -1173,10 +1173,11 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1173 | return ERR_PTR(-EINVAL); | 1173 | return ERR_PTR(-EINVAL); |
1174 | 1174 | ||
1175 | /* | 1175 | /* |
1176 | * If the new process will be in a different pid namespace | 1176 | * If the new process will be in a different pid namespace don't |
1177 | * don't allow the creation of threads. | 1177 | * allow it to share a thread group or signal handlers with the |
1178 | * forking task. | ||
1178 | */ | 1179 | */ |
1179 | if ((clone_flags & (CLONE_VM|CLONE_NEWPID)) && | 1180 | if ((clone_flags & (CLONE_SIGHAND | CLONE_NEWPID)) && |
1180 | (task_active_pid_ns(current) != | 1181 | (task_active_pid_ns(current) != |
1181 | current->nsproxy->pid_ns_for_children)) | 1182 | current->nsproxy->pid_ns_for_children)) |
1182 | return ERR_PTR(-EINVAL); | 1183 | return ERR_PTR(-EINVAL); |