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
..
2026-04-13 19:03:11 -07:00
2026-04-08 19:38:52 -07:00
2026-04-15 09:20:49 -07:00
2026-03-20 14:18:56 +01:00
2026-04-04 20:41:25 +02:00
2026-04-13 20:10:58 -07:00
2026-04-05 13:53:04 -07:00
2026-04-15 09:20:49 -07:00
2026-04-16 08:01:16 -07:00
2026-04-15 14:15:25 -07:00
2026-04-08 07:51:26 +02:00
2026-03-26 15:22:41 +01:00
2026-03-24 13:50:30 +01:00
2026-04-15 14:37:32 -07:00
2026-05-10 10:08:16 -10:00
2026-04-11 11:53:54 +01:00
2026-04-05 13:53:07 -07:00
2026-04-15 08:32:10 -07:00
2026-04-09 21:40:22 +02:00
2026-03-27 15:32:04 +00:00
2026-04-13 14:56:54 -07:00
2026-04-03 16:53:50 -04:00
2026-04-07 08:22:24 -06:00
2026-04-01 20:03:07 -04:00
2026-04-09 13:28:05 -04:00
2026-04-13 15:51:31 -07:00
2026-04-10 21:22:32 -07:00
2026-04-12 12:37:04 -07:00
2026-04-06 18:37:52 -07:00
2026-04-08 18:09:56 -07:00
2026-04-12 11:33:23 -07:00
2026-03-19 11:38:24 -06:00
2026-03-29 09:56:06 -07:00
2026-03-26 15:03:32 +01:00
2026-04-04 08:10:37 -06:00
2026-04-15 10:54:24 -07:00
2026-05-04 09:06:03 -10:00
2026-04-11 07:58:33 +02:00
2026-04-14 10:53:44 -07:00
2026-03-31 14:41:56 -07:00
2026-03-24 15:08:05 +01:00
2026-04-15 08:37:45 -07:00
2026-03-23 13:33:51 -04:00
2026-04-04 18:40:58 -06:00
2026-04-04 20:55:56 +02:00
2026-03-22 11:17:59 +09:00
2026-04-07 15:32:20 +02:00
2026-04-05 13:53:28 -07:00
2026-04-05 13:53:19 -07:00
2026-04-10 11:25:34 -05:00
2026-03-27 22:19:17 +01:00
2026-03-22 23:13:33 +01:00
2026-04-08 15:27:47 +02:00
2026-03-25 08:01:21 +01:00
2026-04-01 20:54:16 +02:00
2026-04-03 16:48:01 -07:00
2026-04-06 20:21:37 -06:00
2026-03-31 19:15:21 +02:00
2026-03-18 09:06:49 +01:00
2026-04-14 16:48:56 -07:00
2026-03-23 17:59:54 -07:00
2026-03-31 23:42:52 +00:00
2026-04-14 18:36:10 -07:00
2026-03-23 13:33:51 -04:00
2026-04-05 13:53:07 -07:00
2026-04-05 13:53:07 -07:00
2026-04-07 17:38:07 +02:00
2026-04-15 12:59:16 -07:00
2026-03-26 22:00:59 +01:00
2026-04-06 20:21:37 -06:00
2026-04-06 20:21:37 -06:00
2026-04-08 14:23:29 -07:00
2026-04-12 16:46:29 +08:00
2026-03-19 08:18:36 +01:00
2026-04-05 13:53:45 -07:00
2026-04-05 13:53:25 -07:00
2026-04-15 12:59:16 -07:00
2026-03-22 11:17:59 +09:00
2026-04-05 13:53:44 -07:00
2026-03-29 11:21:23 -07:00
2026-04-07 15:36:02 +02:00
2026-04-08 08:55:15 +02:00
2026-04-12 15:20:46 -07:00
2026-04-13 15:09:49 +02:00
2026-03-29 11:21:23 -07:00
2026-04-01 16:03:05 +02:00
2026-04-13 16:22:30 -07:00
2026-04-15 12:59:16 -07:00
2026-04-09 13:18:27 +01:00
2026-03-27 10:18:39 -05:00
2026-04-14 23:03:02 -07:00
2026-03-21 08:02:36 +01:00
2026-04-05 13:53:28 -07:00
2026-04-13 10:10:28 -07:00
2026-04-05 13:53:04 -07:00
2026-04-09 14:36:52 +02:00
2026-04-09 14:36:52 +02:00
2026-04-05 13:53:40 -07:00
2026-04-03 19:39:52 +02:00
2026-04-05 13:53:46 -07:00
2026-04-01 10:19:41 +02:00
2026-04-03 16:53:50 -04:00
2026-04-13 15:42:19 -07:00
2026-04-03 16:53:50 -04:00
2026-04-05 13:52:55 -07:00
2026-03-18 09:59:57 +00:00
2026-04-09 17:14:36 +02:00
2026-04-05 13:53:04 -07:00
2026-04-05 13:53:00 -07:00
2026-04-05 13:53:32 -07:00
2026-04-05 13:53:33 -07:00
2026-04-05 13:53:01 -07:00
2026-03-26 16:13:48 +01:00
2026-04-02 18:03:03 -07:00
2026-04-05 13:53:36 -07:00
2026-04-05 13:53:45 -07:00
2026-04-05 13:53:45 -07:00
2026-04-05 13:53:41 -07:00
2026-04-08 13:18:57 -07:00
2026-04-15 12:59:16 -07:00
2026-04-15 12:59:16 -07:00
2026-03-24 21:42:37 +00:00
2026-03-31 23:42:18 +00:00
2026-03-31 23:42:52 +00:00
2026-03-18 21:43:19 +00:00
2026-03-27 17:01:36 +01:00
2026-04-13 14:56:28 -07:00
2026-04-14 18:36:10 -07:00
2026-03-29 11:21:24 -07:00
2026-03-26 15:18:45 +01:00
2026-03-27 10:56:05 -05:00
2026-04-13 15:51:31 -07:00
2026-03-27 07:35:05 -07:00
2026-03-22 11:17:59 +09:00
2026-04-05 13:53:12 -07:00
2026-04-05 13:53:17 -07:00
2026-04-05 13:53:19 -07:00
2026-03-20 14:18:56 +01:00
2026-04-05 13:53:10 -07:00
2026-04-10 17:27:39 -05:00
2026-04-04 16:14:37 +05:30
2026-04-06 16:55:16 +02:00
2026-04-15 14:41:21 -07:00
2026-04-05 13:53:35 -07:00
2026-04-12 11:33:23 -07:00
2026-03-22 23:13:33 +01:00
2026-04-01 13:33:35 +02:00
2026-03-30 13:57:49 +02:00
2026-03-17 16:18:48 -07:00
2026-03-27 18:52:43 +09:00
2026-03-30 12:02:12 +02:00
2026-03-27 17:14:31 -07:00
2026-03-25 13:15:36 +01:00
2026-03-24 21:12:03 -07:00
2026-04-07 12:24:49 -07:00
2026-03-31 14:41:56 -07:00
2026-04-10 11:46:15 +01:00
2026-04-20 20:10:50 -10:00
2026-04-20 20:10:50 -10:00
2026-03-21 08:02:36 +01:00
2026-03-31 16:47:17 +02:00
2026-04-14 13:33:36 -07:00
2026-04-13 15:42:19 -07:00
2026-03-31 07:04:00 -06:00
2026-03-31 09:48:42 +02:00
2026-04-12 10:54:31 -07:00
2026-03-25 20:11:29 +01:00
2026-03-30 15:48:13 -04:00
2026-03-25 09:00:05 -07:00
2026-03-30 15:48:13 -04:00
2026-03-27 20:57:38 -07:00
2026-04-05 13:53:06 -07:00
2026-03-23 12:41:58 +01:00
2026-04-13 19:03:11 -07:00
2026-03-19 08:18:36 +01:00
2026-04-08 12:30:31 +02:00
2026-04-01 17:13:35 +02:00
2026-03-31 16:01:13 -07:00
2026-04-05 13:53:08 -07:00
2026-04-13 08:39:51 -07:00
2026-04-05 13:53:44 -07:00
2026-04-02 09:43:26 +02:00
2026-04-05 13:53:41 -07:00
2026-04-04 00:47:50 +02:00
2026-03-30 16:43:24 -06:00
2026-03-24 11:12:08 +01:00
2026-04-05 13:52:58 -07:00
2026-04-05 13:53:04 -07:00
2026-04-04 00:45:14 +02:00
2026-04-01 10:24:18 -10:00
2026-04-05 13:53:07 -07:00