Re: [PATCH v3] kernel/exit: do panic earlier to get coredump if global init task exit
From: Oleg Nesterov
Date: Fri Dec 20 2019 - 14:38:19 EST
On 12/19, qiwuchen55@xxxxxxxxx wrote:
>
> @@ -517,10 +517,6 @@ static struct task_struct *find_child_reaper(struct task_struct *father,
> }
>
> write_unlock_irq(&tasklist_lock);
> - if (unlikely(pid_ns == &init_pid_ns)) {
> - panic("Attempted to kill init! exitcode=0x%08x\n",
> - father->signal->group_exit_code ?: father->exit_code);
> - }
>
> list_for_each_entry_safe(p, n, dead, ptrace_entry) {
> list_del_init(&p->ptrace_entry);
> @@ -766,6 +762,15 @@ void __noreturn do_exit(long code)
> acct_update_integrals(tsk);
> group_dead = atomic_dec_and_test(&tsk->signal->live);
> if (group_dead) {
> + /*
> + * If the last thread of global init exit, do panic
> + * immeddiately to get the coredump to find any clue
> + * for init task in userspace.
> + */
> + if (unlikely(is_global_init(tsk)))
> + panic("Attempted to kill init! exitcode=0x%08x\n",
> + tsk->signal->group_exit_code ?: (int)code);
> +
Acked-by: Oleg Nesterov <oleg@xxxxxxxxxx>