mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/5] exec: kill unsafe BUG_ON(sig->count) checks
@ 2007-08-18 17:39 Oleg Nesterov
  2007-08-18 22:33 ` Paul E. McKenney
  2007-08-18 23:27 ` Roland McGrath
  0 siblings, 2 replies; 3+ messages in thread
From: Oleg Nesterov @ 2007-08-18 17:39 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Paul E. McKenney, Roland McGrath, linux-kernel

de_thread:

	if (atomic_read(&oldsighand->count) <= 1)
		BUG_ON(atomic_read(&sig->count) != 1);

This is not safe without the rmb() in between. The results of two correctly
ordered __exit_signal()->atomic_dec_and_test()'s could be seen out of order
on our CPU.

The same is true for the "thread_group_empty()" case, __unhash_process()'s
changes could be seen before atomic_dec_and_test(&sig->count).

On some platforms (including i386) atomic_read() doesn't provide even the
compiler barrier, in that case these checks are simply racy.

Remove these BUG_ON()'s. Alternatively, we can do something like

	BUG_ON( ({ smp_rmb(); atomic_read(&sig->count) != 1; }) );

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

--- t/fs/exec.c~1_BUG_ON	2007-08-18 17:36:58.000000000 +0400
+++ t/fs/exec.c	2007-08-18 18:19:41.000000000 +0400
@@ -784,7 +784,6 @@ static int de_thread(struct task_struct 
 	 * and we can just re-use it all.
 	 */
 	if (atomic_read(&oldsighand->count) <= 1) {
-		BUG_ON(atomic_read(&sig->count) != 1);
 		signalfd_detach(tsk);
 		exit_itimers(sig);
 		return 0;
@@ -929,8 +928,6 @@ no_thread_group:
 	if (leader)
 		release_task(leader);
 
-	BUG_ON(atomic_read(&sig->count) != 1);
-
 	if (atomic_read(&oldsighand->count) == 1) {
 		/*
 		 * Now that we nuked the rest of the thread group,


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

end of thread, other threads:[~2007-08-18 23:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-18 17:39 [PATCH 1/5] exec: kill unsafe BUG_ON(sig->count) checks Oleg Nesterov
2007-08-18 22:33 ` Paul E. McKenney
2007-08-18 23:27 ` Roland McGrath

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

all inboxes | Powered by JetHome®