From: akpm@linux-foundation.org Subject: [merged] =?US-ASCII?Q?pidns-disable-pid-allocation-if-pid=5Fns=5Fprepare=5Fproc-?= =?US-ASCII?Q?is-failed-in-alloc=5Fpid.patch?= removed from -mm tree Date: Tue, 09 May 2017 11:01:56 -0700 Message-ID: <20170509180156.ifpySXXj1%akpm@linux-foundation.org> Reply-To: linux-kernel@vger.kernel.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Return-path: Received: from mail.linuxfoundation.org ([140.211.169.12]:34502 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753562AbdEISB5 (ORCPT ); Tue, 9 May 2017 14:01:57 -0400 Sender: mm-commits-owner@vger.kernel.org List-Id: mm-commits@vger.kernel.org To: agruenba@redhat.com, avagin@virtuozzo.com, ebiederm@xmission.com, gorcunov@openvz.org, keescook@chromium.org, ktkhai@virtuozzo.com, luto@amacapital.net, mingo@kernel.org, mm-commits@vger.kernel.org, mtk.manpages@googlemail.com, oleg@redhat.com, paul@paul-moore.com, serge@hallyn.com, viro@zeniv.linux.org.uk The patch titled Subject: pidns: disable pid allocation if pid_ns_prepare_proc() is failed in alloc_pid() has been removed from the -mm tree. Its filename was pidns-disable-pid-allocation-if-pid_ns_prepare_proc-is-failed-in-alloc_pid.patch This patch was dropped because it was merged into mainline or a subsystem tree ------------------------------------------------------ From: Kirill Tkhai Subject: pidns: disable pid allocation if pid_ns_prepare_proc() is failed in alloc_pid() alloc_pidmap() advances pid_namespace::last_pid. When first pid allocation fails, then next created process will have pid 2 and pid_ns_prepare_proc() won't be called. So, pid_namespace::proc_mnt will never be initialized (not to mention that there won't be a child reaper). I saw crash stack of such case on kernel 3.10: BUG: unable to handle kernel NULL pointer dereference at (null) IP: [] proc_flush_task+0x8f/0x1b0 Call Trace: [] release_task+0x3f/0x490 [] ? thread_group_cputime_adjusted+0x50/0x70 [] wait_consider_task.part.10+0x7ff/0xb00 [] do_wait+0x11f/0x280 [] SyS_wait4+0x7d/0x110 We may fix this by restore of last_pid in 0 or by prohibiting of futher allocations. Since there was a similar issue in Oleg Nesterov's 314a8ad0f18a ("pidns: fix free_pid() to handle the first fork failure"). and it was fixed via prohibiting allocation, let's follow this way, and do the same. Link: http://lkml.kernel.org/r/149201021004.4863.6762095011554287922.stgit@localhost.localdomain Signed-off-by: Kirill Tkhai Acked-by: Cyrill Gorcunov Cc: Andrei Vagin Cc: Andreas Gruenbacher Cc: Kees Cook Cc: Michael Kerrisk Cc: Al Viro Cc: Oleg Nesterov Cc: Paul Moore Cc: Eric Biederman Cc: Andy Lutomirski Cc: Ingo Molnar Cc: Serge Hallyn Signed-off-by: Andrew Morton --- kernel/pid.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff -puN kernel/pid.c~pidns-disable-pid-allocation-if-pid_ns_prepare_proc-is-failed-in-alloc_pid kernel/pid.c --- a/kernel/pid.c~pidns-disable-pid-allocation-if-pid_ns_prepare_proc-is-failed-in-alloc_pid +++ a/kernel/pid.c @@ -321,8 +321,10 @@ struct pid *alloc_pid(struct pid_namespa } if (unlikely(is_child_reaper(pid))) { - if (pid_ns_prepare_proc(ns)) + if (pid_ns_prepare_proc(ns)) { + disable_pid_allocation(ns); goto out_free; + } } get_pid_ns(ns); _ Patches currently in -mm which might be from ktkhai@virtuozzo.com are