Skip to contentSkip to conversation

uglify while_each_pid_task() to make sure we don't count the execing pricess twice

PATCH New Oleg Nesterov 1 participant 1 message Dec 7, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 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.

include/linux/pid.h renamed from include/linux/pid.h~2_do_each_pid_task +6 -0
@@ -160,7 +160,13 @@ static inline pid_t pid_vnr(struct pid *
 			hlist_for_each_entry_rcu((task), pos___,	\
 				&pid->tasks[type], pids[type].node) {
 
+			/*
+			 * Both old and new leaders may be attached to
+			 * the same pid in the middle of de_thread().
+			 */
 #define while_each_pid_task(pid, type, task)				\
+				if (type == PIDTYPE_PID)		\
+					break;				\
 			}						\
 	} while (0)