summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fs/proc/base.c5
-rw-r--r--include/linux/sched/signal.h4
2 files changed, 6 insertions, 3 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 05452c3b9872..483a3edebdd1 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -3813,11 +3813,10 @@ static struct task_struct *first_tid(struct pid *pid, int tid, loff_t f_pos,
/* If we haven't found our starting place yet start
* with the leader and walk nr threads forward.
*/
- pos = task = task->group_leader;
- do {
+ for_each_thread(task, pos) {
if (!nr--)
goto found;
- } while_each_thread(task, pos);
+ };
fail:
pos = NULL;
goto out;
diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h
index 0deebe2ab07d..0014d3adaf84 100644
--- a/include/linux/sched/signal.h
+++ b/include/linux/sched/signal.h
@@ -648,6 +648,10 @@ extern void flush_itimer_signals(void);
extern bool current_is_single_threaded(void);
+/*
+ * Without tasklist/siglock it is only rcu-safe if g can't exit/exec,
+ * otherwise next_thread(t) will never reach g after list_del_rcu(g).
+ */
#define while_each_thread(g, t) \
while ((t = next_thread(t)) != g)