Skip to content

Commit 05e6330

Browse files
arighihtejun
authored andcommitted
sched_ext: Fix scx_kick_pseqs corruption on concurrent scheduler loads
If we load a BPF scheduler while another scheduler is already running, alloc_kick_pseqs() would be called again, overwriting the previously allocated arrays. Fix by moving the alloc_kick_pseqs() call after the scx_enable_state() check, ensuring that the arrays are only allocated when a scheduler can actually be loaded. Fixes: 14c1da3 ("sched_ext: Allocate scx_kick_cpus_pnt_seqs lazily using kvzalloc()") Signed-off-by: Andrea Righi <arighi@nvidia.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 14c1da3 commit 05e6330

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

kernel/sched/ext.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4577,15 +4577,15 @@ static int scx_enable(struct sched_ext_ops *ops, struct bpf_link *link)
45774577

45784578
mutex_lock(&scx_enable_mutex);
45794579

4580-
ret = alloc_kick_pseqs();
4581-
if (ret)
4582-
goto err_unlock;
4583-
45844580
if (scx_enable_state() != SCX_DISABLED) {
45854581
ret = -EBUSY;
4586-
goto err_free_pseqs;
4582+
goto err_unlock;
45874583
}
45884584

4585+
ret = alloc_kick_pseqs();
4586+
if (ret)
4587+
goto err_unlock;
4588+
45894589
sch = scx_alloc_and_add_sched(ops);
45904590
if (IS_ERR(sch)) {
45914591
ret = PTR_ERR(sch);

0 commit comments

Comments
 (0)