Skip to contentSkip to conversation

pid-document-the-pidns_adding-checks-in-alloc_pid-and-copy_process.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Mar 28

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: pid: document the PIDNS_ADDING checks in alloc_pid() and copy_process()
has been removed from the -mm tree. Its filename was
pid-document-the-pidns_adding-checks-in-alloc_pid-and-copy_process.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Oleg Nesterov <[email protected]>
Subject: pid: document the PIDNS_ADDING checks in alloc_pid() and copy_process()
Date: Fri, 27 Feb 2026 13:04:20 +0100

Both copy_process() and alloc_pid() do the same PIDNS_ADDING check. The reasons for these checks, and the fact that both are necessary, are not immediately obvious. Add the comments.

Cc Adrian Reber <[email protected]>
Cc Aleksa Sarai <[email protected]>
Cc Alexander Mikhalitsyn <[email protected]>
Cc Andrei Vagin <[email protected]>
Cc Christian Brauner <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jan Kara <[email protected]>
Cc Juri Lelli <[email protected]>
Cc Kees Cook <[email protected]>
Cc Kirill Tkhai <[email protected]>
Cc Pavel Tikhomirov <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Shuah Khan <[email protected]>
Cc Vincent Guittot <[email protected]>

---

 kernel/fork.c |    6 +++++-
 kernel/pid.c  |    5 +++++
 2 files changed, 10 insertions(+), 1 deletion(-)
kernel/fork.c renamed from kernel/fork.c~pid-document-the-pidns_adding-checks-in-alloc_pid-and-copy_process +5 -1
@@ -2393,7 +2393,11 @@ __latent_entropy struct task_struct *cop
 
 	rseq_fork(p, clone_flags);
 
-	/* Don't start children in a dying pid namespace */
+	/*
+	 * If zap_pid_ns_processes() was called after alloc_pid(), the new
+	 * child missed SIGKILL.  If current is not in the same namespace,
+	 * we can't rely on fatal_signal_pending() below.
+	 */
 	if (unlikely(!(ns_of_pid(pid)->pid_allocated & PIDNS_ADDING))) {
 		retval = -ENOMEM;
 		goto bad_fork_core_free;
kernel/pid.c renamed from kernel/pid.c~pid-document-the-pidns_adding-checks-in-alloc_pid-and-copy_process +5 -0
@@ -314,6 +314,11 @@ struct pid *alloc_pid(struct pid_namespa
 	 *
 	 * This can't be done earlier because we need to preserve other
 	 * error conditions.
+	 *
+	 * We need this even if copy_process() does the same check. If two
+	 * or more tasks from parent namespace try to inject a child into a
+	 * dead namespace, one of free_pid() calls from the copy_process()
+	 * error path may try to wakeup the possibly freed ns->child_reaper.
 	 */
 	retval = -ENOMEM;
 	if (unlikely(!(ns->pid_allocated & PIDNS_ADDING)))

_

Patches currently in -mm which might be from [email protected] are

kernel-fork-validate-exit_signal-in-kernel_clone-fix.patch