]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
sched_ext: Fix premature ops->priv publication in scx_alloc_and_add_sched()
authorTejun Heo <tj@kernel.org>
Thu, 9 Jul 2026 21:08:22 +0000 (11:08 -1000)
committerTejun Heo <tj@kernel.org>
Thu, 9 Jul 2026 21:08:22 +0000 (11:08 -1000)
commit49b3378a750cf85112e656d003145d4b5d0da232
tree27801d43b7ad4dcc3e69d12d7ed0dd1b36a99b09
parentdb4e9defd2e8620abee04cfe5809c0bcd6ecf06a
sched_ext: Fix premature ops->priv publication in scx_alloc_and_add_sched()

scx_alloc_and_add_sched() publishes @sch through ops->priv before allocating
the cgroup path. If that allocation fails, the unwind path clears ops->priv
and frees @sch immediately. scx_prog_sched() callers can dereference
ops->priv from RCU context the moment it is set, so freeing without a grace
period can use-after-free a concurrent kfunc caller.

Move the publication below the cgroup path allocation so that every failure
path after publication frees @sch through kobject_put(), whose release path
defers the freeing by a grace period.

Fixes: 105dcd005be2 ("sched_ext: Introduce scx_prog_sched()")
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
kernel/sched/ext/ext.c