Skip to content

Commit 46f382d

Browse files
Oleg NesterovLinus Torvalds
authored andcommitted
uglify while_each_pid_task() to make sure we don't count the execing pricess twice
There is a window when de_thread() switches the leader and drops tasklist_lock. In that window do_each_pid_task(PIDTYPE_PID) finds both new and old leaders. The problem is pretty much theoretical and probably can be ignored. Currently the only users of do_each_pid_task(PIDTYPE_PID) are send_sigio/send_sigurg, so they can send the signal to the same process twice. Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Davide Libenzi <davidel@xmailserver.org> Cc: Pavel Emelyanov <xemul@openvz.org> Cc: Roland McGrath <roland@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent d36174b commit 46f382d

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎include/linux/pid.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,13 @@ pid_t pid_vnr(struct pid *pid);
152152
hlist_for_each_entry_rcu((task), pos___, \
153153
&pid->tasks[type], pids[type].node) {
154154

155+
/*
156+
* Both old and new leaders may be attached to
157+
* the same pid in the middle of de_thread().
158+
*/
155159
#define while_each_pid_task(pid, type, task) \
160+
if (type == PIDTYPE_PID) \
161+
break; \
156162
} \
157163
} while (0)
158164

0 commit comments

Comments
 (0)