summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorBabanpreet Singh <bbnpreetsingh@gmail.com>2026-10-02 01:21:41 +0000
committerChristian Brauner <brauner@kernel.org>2026-10-12 11:13:01 +0200
commit12e19bba68ba4ef222033ff9a3b63df07b7fad38 (patch)
treeeba52444903795eb1360ec3c8df065f244d75f93 /include/linux
parent2ec5a070946165c66b4ee1190016d5a8e44dc055 (diff)
downloadlinux-12e19bba68ba4ef222033ff9a3b63df07b7fad38.tar.gz
linux-12e19bba68ba4ef222033ff9a3b63df07b7fad38.zip
pid: use READ_ONCE() in pid_alive()
KCSAN reports pid_alive() reading task->thread_pid while it gets cleared under tasklist_lock. The check only cares about NULL, so READ_ONCE() and WRITE_ONCE() are enough. Reported-by: syzbot+c382ee653fd70f5cf1bb@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=c382ee653fd70f5cf1bb Signed-off-by: Babanpreet Singh <bbnpreetsingh@gmail.com> Link: https://patch.msgid.link/20261002012141.7-1-bbnpreetsingh@gmail.com Acked-by: Oleg Nesterov <oleg@redhat.com> Reviewed-by: Bradley Morgan <brads@mainlining.org> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/pid.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/linux/pid.h b/include/linux/pid.h
index f5476d7140a3..a0458c713e4e 100644
--- a/include/linux/pid.h
+++ b/include/linux/pid.h
@@ -273,7 +273,7 @@ static inline pid_t task_tgid_nr(struct task_struct *tsk)
*/
static inline int pid_alive(const struct task_struct *p)
{
- return p->thread_pid != NULL;
+ return READ_ONCE(p->thread_pid) != NULL;
}
static inline pid_t task_pgrp_nr_ns(struct task_struct *tsk, struct pid_namespace *ns)