mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
kthread: Annotate lockless to_kthread() flags access
do_exit() calls synchronize_group_exit(), which modifies task->flags under sighand->siglock: tsk->flags |= PF_POSTCOREDUMP; The sanity check in to_kthread() reads the same flags word without holding that lock: WARN_ON(!(k->flags & PF_KTHREAD)); PF_KTHREAD is set once when the task becomes a kthread and is never cleared for the lifetime of the task. Since PF_KTHREAD is immutable, the check does not depend on synchronization with updates to other bits in task->flags. Use READ_ONCE() to annotate the intentional lockless access. Signed-off-by: Kunwu Chan <kunwu.chan@gmail.com> Link: https://patch.msgid.link/20260920070750.2871923-1-kunwu.chan@gmail.com Reviewed-by: Bradley Morgan <brads@mainlining.org> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This commit is contained in:
parent
8421a62085
commit
fd00a46e36
|
|
@ -81,7 +81,7 @@ enum KTHREAD_BITS {
|
|||
|
||||
static inline struct kthread *to_kthread(struct task_struct *k)
|
||||
{
|
||||
WARN_ON(!(k->flags & PF_KTHREAD));
|
||||
WARN_ON(!(READ_ONCE(k->flags) & PF_KTHREAD));
|
||||
return k->worker_private;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user