summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2026-10-11 16:16:51 +0200
committerChristian Brauner <brauner@kernel.org>2026-10-12 10:39:51 +0200
commit41e24dc80739b07d592566ceeaf0bb5e3620cc5c (patch)
treebe3d15625e0a7c9d05b8db0a5be43360b558ea0e /include/linux
parented14a591175bb5f56c2936b082cffb9e4b935e6d (diff)
downloadlinux-41e24dc80739b07d592566ceeaf0bb5e3620cc5c.tar.gz
linux-41e24dc80739b07d592566ceeaf0bb5e3620cc5c.zip
pid: document that do_each_pid_task() needs tasklist_lock
do_each_pid_task() looks "obviously rcu-safe". This confuses people and we already have 2 buggy users: send_sigio() and send_sigurg(). The reasons why it is not are not obvious at all, add the comment. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Link: https://patch.msgid.link/asuaU8H_5MbO3-cW@redhat.com Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/pid.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/pid.h b/include/linux/pid.h
index ddaef0bbc8ba..f5476d7140a3 100644
--- a/include/linux/pid.h
+++ b/include/linux/pid.h
@@ -187,6 +187,15 @@ static inline pid_t pid_nr(struct pid *pid)
pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
pid_t pid_vnr(struct pid *pid);
+/*
+ * Needs tasklist_lock if type > PIDTYPE_TGID. A lockless reader can:
+ *
+ * - race with a change_pid() that moves the task to another hlist,
+ * and continue to scan the wrong list.
+ *
+ * - race with a copy_process() that adds a new task to the start of hlist,
+ * and miss the new child.
+ */
#define do_each_pid_task(pid, type, task) \
do { \
if ((pid) != NULL) \