stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] exit: move exit_task_namespaces() after exit_task_work()
@ 2017-12-14 20:17 Cong Wang
  2017-12-14 21:08 ` Al Viro
  2017-12-15  6:56 ` Eric W. Biederman
  0 siblings, 2 replies; 9+ messages in thread
From: Cong Wang @ 2017-12-14 20:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Cong Wang, Ingo Molnar, Al Viro, Andrew Morton, Linus Torvalds,
	stable

syzbot reported we have a use-after-free when mqueue_evict_inode()
is called on __cleanup_mnt() path, where the ipc ns is already
freed by the previous exit_task_namespaces(). We can just move
it after after exit_task_work() to avoid this use-after-free.

Reported-by: syzbot <syzkaller@googlegroups.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: stable@vger.kernel.org
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
 kernel/exit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index 6b4298a41167..909e43c45158 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -861,8 +861,8 @@ void __noreturn do_exit(long code)
 	exit_fs(tsk);
 	if (group_dead)
 		disassociate_ctty(1);
-	exit_task_namespaces(tsk);
 	exit_task_work(tsk);
+	exit_task_namespaces(tsk);
 	exit_thread(tsk);
 
 	/*
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-12-16 22:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-14 20:17 [PATCH] exit: move exit_task_namespaces() after exit_task_work() Cong Wang
2017-12-14 21:08 ` Al Viro
2017-12-15 23:59   ` Cong Wang
2017-12-16 22:04     ` Giuseppe Scrivano
2017-12-15  6:56 ` Eric W. Biederman
2017-12-15  7:35   ` Dmitry Vyukov
2017-12-15  8:00     ` Dmitry Vyukov
2017-12-16  0:00       ` Cong Wang
2017-12-16  7:40         ` Dmitry Vyukov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).