aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/exit.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/exit.c')
-rw-r--r--kernel/exit.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index 3b8dfffd9329..8b64c0371ae9 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -592,17 +592,6 @@ static void exit_mm(struct task_struct * tsk)
592 mmput(mm); 592 mmput(mm);
593} 593}
594 594
595static inline void
596choose_new_parent(struct task_struct *p, struct task_struct *reaper)
597{
598 /*
599 * Make sure we're not reparenting to ourselves and that
600 * the parent is not a zombie.
601 */
602 BUG_ON(p == reaper || reaper->exit_state);
603 p->real_parent = reaper;
604}
605
606static void 595static void
607reparent_thread(struct task_struct *p, struct task_struct *father, int traced) 596reparent_thread(struct task_struct *p, struct task_struct *father, int traced)
608{ 597{
@@ -710,7 +699,7 @@ forget_original_parent(struct task_struct *father, struct list_head *to_release)
710 699
711 if (father == p->real_parent) { 700 if (father == p->real_parent) {
712 /* reparent with a reaper, real father it's us */ 701 /* reparent with a reaper, real father it's us */
713 choose_new_parent(p, reaper); 702 p->real_parent = reaper;
714 reparent_thread(p, father, 0); 703 reparent_thread(p, father, 0);
715 } else { 704 } else {
716 /* reparent ptraced task to its real parent */ 705 /* reparent ptraced task to its real parent */
@@ -731,7 +720,7 @@ forget_original_parent(struct task_struct *father, struct list_head *to_release)
731 } 720 }
732 list_for_each_safe(_p, _n, &father->ptrace_children) { 721 list_for_each_safe(_p, _n, &father->ptrace_children) {
733 p = list_entry(_p, struct task_struct, ptrace_list); 722 p = list_entry(_p, struct task_struct, ptrace_list);
734 choose_new_parent(p, reaper); 723 p->real_parent = reaper;
735 reparent_thread(p, father, 1); 724 reparent_thread(p, father, 1);
736 } 725 }
737} 726}
@@ -882,6 +871,14 @@ static void check_stack_usage(void)
882static inline void check_stack_usage(void) {} 871static inline void check_stack_usage(void) {}
883#endif 872#endif
884 873
874static inline void exit_child_reaper(struct task_struct *tsk)
875{
876 if (likely(tsk->group_leader != child_reaper(tsk)))
877 return;
878
879 panic("Attempted to kill init!");
880}
881
885fastcall NORET_TYPE void do_exit(long code) 882fastcall NORET_TYPE void do_exit(long code)
886{ 883{
887 struct task_struct *tsk = current; 884 struct task_struct *tsk = current;
@@ -895,13 +892,6 @@ fastcall NORET_TYPE void do_exit(long code)
895 panic("Aiee, killing interrupt handler!"); 892 panic("Aiee, killing interrupt handler!");
896 if (unlikely(!tsk->pid)) 893 if (unlikely(!tsk->pid))
897 panic("Attempted to kill the idle task!"); 894 panic("Attempted to kill the idle task!");
898 if (unlikely(tsk == child_reaper(tsk))) {
899 if (tsk->nsproxy->pid_ns != &init_pid_ns)
900 tsk->nsproxy->pid_ns->child_reaper = init_pid_ns.child_reaper;
901 else
902 panic("Attempted to kill init!");
903 }
904
905 895
906 if (unlikely(current->ptrace & PT_TRACE_EXIT)) { 896 if (unlikely(current->ptrace & PT_TRACE_EXIT)) {
907 current->ptrace_message = code; 897 current->ptrace_message = code;
@@ -951,6 +941,7 @@ fastcall NORET_TYPE void do_exit(long code)
951 } 941 }
952 group_dead = atomic_dec_and_test(&tsk->signal->live); 942 group_dead = atomic_dec_and_test(&tsk->signal->live);
953 if (group_dead) { 943 if (group_dead) {
944 exit_child_reaper(tsk);
954 hrtimer_cancel(&tsk->signal->real_timer); 945 hrtimer_cancel(&tsk->signal->real_timer);
955 exit_itimers(tsk->signal); 946 exit_itimers(tsk->signal);
956 } 947 }