public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix de_thread() vs do_coredump() deadlock
@ 2005-10-13 16:50 Oleg Nesterov
  2006-04-10  1:36 ` Roland McGrath
  0 siblings, 1 reply; 11+ messages in thread
From: Oleg Nesterov @ 2005-10-13 16:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Roland McGrath, Ingo Molnar, Michael Kerrisk, Linus Torvalds,
	Andrew Morton

de_thread() sends SIGKILL to all sub-threads and
waits them to die in 'D' state. It is possible that
one of the threads already dequeued coredump signal.
When de_thread() unlocks ->sighand->lock that thread
can enter do_coredump()->coredump_wait() and cause a
deadlock.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- 2.6.14-rc4/fs/exec.c~	2005-09-21 21:08:33.000000000 +0400
+++ 2.6.14-rc4/fs/exec.c	2005-10-14 00:19:19.000000000 +0400
@@ -1468,11 +1468,21 @@ int do_coredump(long signr, int exit_cod
 		current->fsuid = 0;	/* Dump root private */
 	}
 	mm->dumpable = 0;
-	init_completion(&mm->core_done);
+
+	retval = -EAGAIN;
 	spin_lock_irq(&current->sighand->siglock);
-	current->signal->flags = SIGNAL_GROUP_EXIT;
-	current->signal->group_exit_code = exit_code;
+	if (!(current->signal->flags & SIGNAL_GROUP_EXIT)) {
+		current->signal->flags = SIGNAL_GROUP_EXIT;
+		current->signal->group_exit_code = exit_code;
+		retval = 0;
+	}
 	spin_unlock_irq(&current->sighand->siglock);
+	if (retval) {
+		up_write(&mm->mmap_sem);
+		goto fail;
+	}
+
+	init_completion(&mm->core_done);
 	coredump_wait(mm);
 
 	/*

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

end of thread, other threads:[~2006-04-11  9:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-13 16:50 [PATCH] fix de_thread() vs do_coredump() deadlock Oleg Nesterov
2006-04-10  1:36 ` Roland McGrath
2006-04-10 17:43   ` Oleg Nesterov
2006-04-11  7:27     ` Roland McGrath
2006-04-11 11:47       ` Oleg Nesterov
2006-04-11  9:10         ` Roland McGrath
2006-04-11 12:03       ` Oleg Nesterov
2006-04-10 21:40   ` Oleg Nesterov
2006-04-11  8:01     ` Roland McGrath
2006-04-11 13:13       ` Oleg Nesterov
2006-04-11  9:49         ` Roland McGrath

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox