]> git.ipfire.org Git - thirdparty/linux.git/commit
sched/deadline: Fix potential race in dl_add_task_root_domain()
authorPingfan Liu <piliu@redhat.com>
Tue, 25 Nov 2025 03:26:30 +0000 (11:26 +0800)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 13 Jan 2026 10:37:51 +0000 (11:37 +0100)
commit64e6fa76610ec970cfa8296ed057907a4b384ca5
tree5b951a95be5b034e4eef97c1821c12efc1962487
parent479972efc2e7c9e0b3743ac538b042fcd4f315d7
sched/deadline: Fix potential race in dl_add_task_root_domain()

The access rule for local_cpu_mask_dl requires it to be called on the
local CPU with preemption disabled. However, dl_add_task_root_domain()
currently violates this rule.

Without preemption disabled, the following race can occur:

1. ThreadA calls dl_add_task_root_domain() on CPU 0
2. Gets pointer to CPU 0's local_cpu_mask_dl
3. ThreadA is preempted and migrated to CPU 1
4. ThreadA continues using CPU 0's local_cpu_mask_dl
5. Meanwhile, the scheduler on CPU 0 calls find_later_rq() which also
   uses local_cpu_mask_dl (with preemption properly disabled)
6. Both contexts now corrupt the same per-CPU buffer concurrently

Fix this by moving the local_cpu_mask_dl access to the preemption
disabled section.

Closes: https://lore.kernel.org/lkml/aSBjm3mN_uIy64nz@jlelli-thinkpadt14gen4.remote.csb
Fixes: 318e18ed22e8 ("sched/deadline: Walk up cpuset hierarchy to decide root domain when hot-unplug")
Reported-by: Juri Lelli <juri.lelli@redhat.com>
Signed-off-by: Pingfan Liu <piliu@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Juri Lelli <juri.lelli@redhat.com>
Acked-by: Waiman Long <longman@redhat.com>
Link: https://patch.msgid.link/20251125032630.8746-3-piliu@redhat.com
kernel/sched/deadline.c