From: akpm@linux-foundation.org Subject: + pidns-fix-vfork-after-unshareclone_newpid.patch added to -mm tree Date: Fri, 23 Aug 2013 16:20:20 -0700 Message-ID: <5217ee34.pteHrz1bKis0j40D%akpm@linux-foundation.org> Reply-To: linux-kernel@vger.kernel.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from mail.linuxfoundation.org ([140.211.169.12]:32924 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756475Ab3HWXUV (ORCPT ); Fri, 23 Aug 2013 19:20:21 -0400 Sender: mm-commits-owner@vger.kernel.org List-Id: mm-commits@vger.kernel.org To: mm-commits@vger.kernel.org, walters@redhat.com, stable@vger.kernel.org, luto@amacapital.net, ebiederm@xmission.com, oleg@redhat.com Subject: + pidns-fix-vfork-after-unshareclone_newpid.patch added to -mm tree To: oleg@redhat.com,ebiederm@xmission.com,luto@amacapital.net,stable@vger.kernel.org,walters@redhat.com From: akpm@linux-foundation.org Date: Fri, 23 Aug 2013 16:20:20 -0700 The patch titled Subject: pidns: fix vfork() after unshare(CLONE_NEWPID) has been added to the -mm tree. Its filename is pidns-fix-vfork-after-unshareclone_newpid.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/pidns-fix-vfork-after-unshareclone_newpid.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/pidns-fix-vfork-after-unshareclone_newpid.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Oleg Nesterov Subject: pidns: fix vfork() after unshare(CLONE_NEWPID) 8382fcac ("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. Signed-off-by: Oleg Nesterov Reported-by: Colin Walters Acked-by: Andy Lutomirski Cc: "Eric W. Biederman" Cc: Signed-off-by: Andrew Morton --- kernel/fork.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff -puN kernel/fork.c~pidns-fix-vfork-after-unshareclone_newpid kernel/fork.c --- a/kernel/fork.c~pidns-fix-vfork-after-unshareclone_newpid +++ a/kernel/fork.c @@ -1173,10 +1173,11 @@ static struct task_struct *copy_process( return ERR_PTR(-EINVAL); /* - * 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)) return ERR_PTR(-EINVAL); _ Patches currently in -mm which might be from oleg@redhat.com are origin.patch pidns-fix-vfork-after-unshareclone_newpid.patch pidns-kill-the-unnecessary-clone_newpid-in-copy_process.patch fork-unify-and-tighten-up-clone_newuser-clone_newpid-checks.patch include-linux-schedh-dont-use-task-pid-tgid-in-same_thread_group-has_group_leader_pid.patch mm-mempolicy-turn-vma_set_policy-into-vma_dup_policy.patch mm-shift-vm_grows-check-from-mmap_region-to-do_mmap_pgoff-v2.patch mm-do_mmap_pgoff-cleanup-the-usage-of-file_inode.patch mm-mmap_region-kill-correct_wcount-inode-use-allow_write_access.patch kernel-wide-fix-missing-validations-on-__get-__put-__copy_to-__copy_from_user.patch task_work-minor-cleanups.patch task_work-documentation.patch autofs4-allow-autofs-to-work-outside-the-initial-pid-namespace.patch autofs4-translate-pids-to-the-right-namespace-for-the-daemon.patch __ptrace_may_access-should-not-deny-sub-threads.patch signals-eventpoll-set-saved_sigmask-at-the-start.patch move-exit_task_namespaces-outside-of-exit_notify-fix.patch exec-introduce-exec_binprm-for-depth-==-0-code.patch exec-kill-int-depth-in-search_binary_handler.patch exec-proc_exec_connector-should-be-called-only-once.patch exec-move-allow_write_access-fput-to-exec_binprm.patch exec-kill-load_binary-=-null-check-in-search_binary_handler.patch exec-cleanup-the-config_modules-logic.patch exec-dont-retry-if-request_module-fails.patch exec-cleanup-the-error-handling-in-search_binary_handler.patch linux-next.patch