aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/pid.h11
-rw-r--r--init/main.c9
-rw-r--r--kernel/fork.c2
3 files changed, 12 insertions, 10 deletions
diff --git a/include/linux/pid.h b/include/linux/pid.h
index 49f1c2f66e9..efceda0a51b 100644
--- a/include/linux/pid.h
+++ b/include/linux/pid.h
@@ -141,6 +141,17 @@ static inline struct pid_namespace *ns_of_pid(struct pid *pid)
141} 141}
142 142
143/* 143/*
144 * is_child_reaper returns true if the pid is the init process
145 * of the current namespace. As this one could be checked before
146 * pid_ns->child_reaper is assigned in copy_process, we check
147 * with the pid number.
148 */
149static inline bool is_child_reaper(struct pid *pid)
150{
151 return pid->numbers[pid->level].nr == 1;
152}
153
154/*
144 * the helpers to get the pid's id seen from different namespaces 155 * the helpers to get the pid's id seen from different namespaces
145 * 156 *
146 * pid_nr() : global id, i.e. the id seen from the init namespace; 157 * pid_nr() : global id, i.e. the id seen from the init namespace;
diff --git a/init/main.c b/init/main.c
index 3627bb37225..4a9479ef454 100644
--- a/init/main.c
+++ b/init/main.c
@@ -787,15 +787,6 @@ static int __init kernel_init(void * unused)
787 * init can run on any cpu. 787 * init can run on any cpu.
788 */ 788 */
789 set_cpus_allowed_ptr(current, cpu_all_mask); 789 set_cpus_allowed_ptr(current, cpu_all_mask);
790 /*
791 * Tell the world that we're going to be the grim
792 * reaper of innocent orphaned children.
793 *
794 * We don't want people to have to make incorrect
795 * assumptions about where in the task array this
796 * can be found.
797 */
798 init_pid_ns.child_reaper = current;
799 790
800 cad_pid = task_pid(current); 791 cad_pid = task_pid(current);
801 792
diff --git a/kernel/fork.c b/kernel/fork.c
index f2b494d7c55..17aed4378ed 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1296,7 +1296,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1296 tracehook_finish_clone(p, clone_flags, trace); 1296 tracehook_finish_clone(p, clone_flags, trace);
1297 1297
1298 if (thread_group_leader(p)) { 1298 if (thread_group_leader(p)) {
1299 if (clone_flags & CLONE_NEWPID) 1299 if (is_child_reaper(pid))
1300 p->nsproxy->pid_ns->child_reaper = p; 1300 p->nsproxy->pid_ns->child_reaper = p;
1301 1301
1302 p->signal->leader_pid = pid; 1302 p->signal->leader_pid = pid;