aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2014-04-07 18:38:29 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-07 19:36:03 -0400
commitc39df5fa37b0623589508c95515b4aa1531c524e (patch)
treea6556cb0f29bed429e17c8f6c6c41f95b4f96d72 /kernel
parent5d2d42de185b77b4bc60b5ac77386c4099d71bf3 (diff)
exit: call disassociate_ctty() before exit_task_namespaces()
Commit 8aac62706ada ("move exit_task_namespaces() outside of exit_notify()") breaks pppd and the exiting service crashes the kernel: BUG: unable to handle kernel NULL pointer dereference at 0000000000000028 IP: ppp_register_channel+0x13/0x20 [ppp_generic] Call Trace: ppp_asynctty_open+0x12b/0x170 [ppp_async] tty_ldisc_open.isra.2+0x27/0x60 tty_ldisc_hangup+0x1e3/0x220 __tty_hangup+0x2c4/0x440 disassociate_ctty+0x61/0x270 do_exit+0x7f2/0xa50 ppp_register_channel() needs ->net_ns and current->nsproxy == NULL. Move disassociate_ctty() before exit_task_namespaces(), it doesn't make sense to delay it after perf_event_exit_task() or cgroup_exit(). This also allows to use task_work_add() inside the (nontrivial) code paths in disassociate_ctty(). Investigated by Peter Hurley. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Reported-by: Sree Harsha Totakura <sreeharsha@totakura.in> Cc: Peter Hurley <peter@hurleysoftware.com> Cc: Sree Harsha Totakura <sreeharsha@totakura.in> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Jeff Dike <jdike@addtoit.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Andrey Vagin <avagin@openvz.org> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: <stable@vger.kernel.org> [v3.10+] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/exit.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index 6480d1c85d7a..11f9e39a7368 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -784,6 +784,8 @@ void do_exit(long code)
784 exit_shm(tsk); 784 exit_shm(tsk);
785 exit_files(tsk); 785 exit_files(tsk);
786 exit_fs(tsk); 786 exit_fs(tsk);
787 if (group_dead)
788 disassociate_ctty(1);
787 exit_task_namespaces(tsk); 789 exit_task_namespaces(tsk);
788 exit_task_work(tsk); 790 exit_task_work(tsk);
789 check_stack_usage(); 791 check_stack_usage();
@@ -799,13 +801,9 @@ void do_exit(long code)
799 801
800 cgroup_exit(tsk); 802 cgroup_exit(tsk);
801 803
802 if (group_dead)
803 disassociate_ctty(1);
804
805 module_put(task_thread_info(tsk)->exec_domain->module); 804 module_put(task_thread_info(tsk)->exec_domain->module);
806 805
807 proc_exit_connector(tsk); 806 proc_exit_connector(tsk);
808
809 /* 807 /*
810 * FIXME: do that only when needed, using sched_exit tracepoint 808 * FIXME: do that only when needed, using sched_exit tracepoint
811 */ 809 */