]> err.no Git - linux-2.6/commitdiff
[PATCH] de_thread: fix lockless do_each_thread
authorOleg Nesterov <oleg@tv-sign.ru>
Mon, 26 Jun 2006 07:26:04 +0000 (00:26 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 26 Jun 2006 16:58:26 +0000 (09:58 -0700)
We should keep the value of old_leader->tasks.next in de_thread, otherwise
we can't do for_each_process/do_each_thread without tasklist_lock held.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/exec.c

index 8c5196087f319c3d3e809c08291856b1f38cfe1c..fffea1eef8dcd2311ed27033f249ef86d7535a9f 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -707,7 +707,7 @@ static int de_thread(struct task_struct *tsk)
                attach_pid(current, PIDTYPE_PID,  current->pid);
                attach_pid(current, PIDTYPE_PGID, current->signal->pgrp);
                attach_pid(current, PIDTYPE_SID,  current->signal->session);
-               list_add_tail_rcu(&current->tasks, &init_task.tasks);
+               list_replace_rcu(&leader->tasks, &current->tasks);
 
                current->group_leader = current;
                leader->group_leader = current;
@@ -715,7 +715,6 @@ static int de_thread(struct task_struct *tsk)
                /* Reduce leader to a thread */
                detach_pid(leader, PIDTYPE_PGID);
                detach_pid(leader, PIDTYPE_SID);
-               list_del_init(&leader->tasks);
 
                current->exit_signal = SIGCHLD;