Skip to content

Commit 1c4042c

Browse files
committed
pidns: Consolidate initialzation of special init task state
Instead of setting child_reaper and SIGNAL_UNKILLABLE one way for the system init process, and another way for pid namespace init processes test pid->nr == 1 and use the same code for both. For the global init this results in SIGNAL_UNKILLABLE being set much earlier in the initialization process. This is a small cleanup and it paves the way for allowing unshare and enter of the pid namespace as that path like our global init also will not set CLONE_NEWPID. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
1 parent 57e8391 commit 1c4042c

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

‎init/main.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,6 @@ static int __ref kernel_init(void *unused)
810810
system_state = SYSTEM_RUNNING;
811811
numa_default_policy();
812812

813-
current->signal->flags |= SIGNAL_UNKILLABLE;
814813
flush_delayed_fput();
815814

816815
if (ramdisk_execute_command) {

‎kernel/fork.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,8 +1039,6 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
10391039
atomic_set(&sig->live, 1);
10401040
atomic_set(&sig->sigcnt, 1);
10411041
init_waitqueue_head(&sig->wait_chldexit);
1042-
if (clone_flags & CLONE_NEWPID)
1043-
sig->flags |= SIGNAL_UNKILLABLE;
10441042
sig->curr_target = tsk;
10451043
init_sigpending(&sig->shared_pending);
10461044
INIT_LIST_HEAD(&sig->posix_timers);
@@ -1441,8 +1439,10 @@ static struct task_struct *copy_process(unsigned long clone_flags,
14411439
ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
14421440

14431441
if (thread_group_leader(p)) {
1444-
if (is_child_reaper(pid))
1442+
if (is_child_reaper(pid)) {
14451443
ns_of_pid(pid)->child_reaper = p;
1444+
p->signal->flags |= SIGNAL_UNKILLABLE;
1445+
}
14461446

14471447
p->signal->leader_pid = pid;
14481448
p->signal->tty = tty_kref_get(current->signal->tty);

0 commit comments

Comments
 (0)