Skip to content

Commit 9a415cc

Browse files
committed
sched_ext: Avoid UAF in scx_root_enable_workfn() init failure path
In scx_root_enable_workfn(), put_task_struct(p) is called before scx_error() dereferences p->comm and p->pid. If the iterator's reference is the last drop, the task is freed synchronously and the deref becomes a UAF. Move put_task_struct() past scx_error(). Reported-by: Sashiko <sashiko-bot@kernel.org> Closes: https://lore.kernel.org/all/20260511214031.AF5E9C2BCB0@smtp.kernel.org/ Fixes: f0e1a06 ("sched_ext: Implement BPF extensible scheduler class") Cc: stable@vger.kernel.org # v6.12+ Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 86ecb1c commit 9a415cc

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

kernel/sched/ext.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6973,10 +6973,10 @@ static void scx_root_enable_workfn(struct kthread_work *work)
69736973
if (scx_get_task_state(p) != SCX_TASK_DEAD)
69746974
scx_set_task_state(p, SCX_TASK_NONE);
69756975
task_rq_unlock(rq, p, &rf);
6976-
put_task_struct(p);
69776976
scx_task_iter_stop(&sti);
69786977
scx_error(sch, "ops.init_task() failed (%d) for %s[%d]",
69796978
ret, p->comm, p->pid);
6979+
put_task_struct(p);
69806980
goto err_disable_unlock_all;
69816981
}
69826982

0 commit comments

Comments
 (0)