mirror-linux/include
Tejun Heo c941d7391f sched_ext: Close root-enable vs sched_ext_dead() race with SCX_TASK_INIT_BEGIN
scx_root_enable_workfn() drops the iter rq lock for ops.init_task() and a
TASK_DEAD @p can fall through sched_ext_dead() in that window. The race hits
when sched_ext_dead() observes SCX_TASK_INIT (the intermediate state before
@p->scx.sched is published) and dereferences NULL via SCX_HAS_OP(NULL,
exit_task), or observes SCX_TASK_NONE during the unlocked init window and
skips cleanup so exit_task() never runs.

Add SCX_TASK_INIT_BEGIN. The enable path writes NONE -> INIT_BEGIN under the
iter rq lock, then takes the rq lock again after init to walk INIT_BEGIN ->
INIT -> READY. sched_ext_dead() that wins the rq-lock race observes
INIT_BEGIN and sets DEAD without calling into ops; the post-init recheck
unwinds via scx_sub_init_cancel_task().

scx_fork() runs single-threaded against sched_ext_dead() (the task is not on
scx_tasks until scx_post_fork() adds it) so its INIT_BEGIN -> INIT walk
needs no rq-lock pairing; it rolls back to NONE on ops.init_task() failure.

The validation matrix grows the INIT_BEGIN row and the INIT_BEGIN -> DEAD
edge; INIT now requires INIT_BEGIN as the predecessor. scx_sub_disable()'s
migration writes INIT_BEGIN as a synthetic predecessor to satisfy the
tightened verification.

The sub-sched paths still race with sched_ext_dead() during the unlocked
init window. This will be fixed by the next patch.

Reported-by: zhidao su <suzhidao@xiaomi.com>
Link: https://lore.kernel.org/all/20260429133155.3825247-1-suzhidao@xiaomi.com/
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
2026-05-10 10:08:16 -10:00
..
acpi Power management updates for 7.1-rc1 2026-04-13 19:47:52 -07:00
asm-generic mm.git review status for linus..mm-stable 2026-04-15 12:59:16 -07:00
clocksource
crypto This update includes the following changes: 2026-04-15 15:22:26 -07:00
cxl
drm
dt-bindings pmdomain core: 2026-04-15 14:22:42 -07:00
hyperv
keys
kunit
kvm
linux sched_ext: Close root-enable vs sched_ext_dead() race with SCX_TASK_INIT_BEGIN 2026-05-10 10:08:16 -10:00
math-emu
media
memory
misc
net mm.git review status for linus..mm-stable 2026-04-15 12:59:16 -07:00
pcmcia
ras
rdma
rv
scsi
soc
sound ASoC: Updates for v7.1 2026-04-13 18:09:48 +02:00
target
trace Runtime Verification updates for 7.1: 2026-04-15 17:15:18 -07:00
uapi VFIO updates for v7.1-rc1 2026-04-16 08:01:16 -07:00
ufs
vdso
video
xen xen/grant-table: guard gnttab_suspend/resume with CONFIG_HIBERNATE_CALLBACKS 2026-04-10 11:07:21 +02:00
Kbuild