[PATCH] fix spinlock deadlock in ptrace-reaping of detached thread

From: Roland McGrath (roland@redhat.com)
Date: Wed Aug 06 2003 - 02:39:06 EST


When a dead detached thread has been temporarily zombified because it's
ptraced and its tracer tries to reap it, it deadlocks on SMP. Here's a fix.

Thanks,
Roland

--- linux-2.5/kernel/exit.c 6 Aug 2003 05:30:45 -0000 1.109
+++ linux-2.5/kernel/exit.c 6 Aug 2003 06:04:02 -0000
@@ -898,13 +898,19 @@ static int wait_task_zombie(task_t *p, u
                         __ptrace_unlink(p);
                         p->state = TASK_ZOMBIE;
                         /* If this is a detached thread, this is where it goes away. */
- if (p->exit_signal == -1)
+ if (p->exit_signal == -1) {
+ /* release_task takes the lock itself. */
+ write_unlock_irq(&tasklist_lock);
                                 release_task (p);
- else
+ }
+ else {
                                 do_notify_parent(p, p->exit_signal);
+ write_unlock_irq(&tasklist_lock);
+ }
                         p = NULL;
                 }
- write_unlock_irq(&tasklist_lock);
+ else
+ write_unlock_irq(&tasklist_lock);
         }
         if (p != NULL)
                 release_task(p);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Aug 07 2003 - 22:00:32 EST