Skip to content

Commit 18228a7

Browse files
arighigregkh
authored andcommitted
sched_ext: Fix scx_kick_pseqs corruption on concurrent scheduler loads
commit 05e63305c85c88141500f0a2fb02afcfba9396e1 upstream. 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: 14c1da3895a11 ("sched_ext: Allocate scx_kick_cpus_pnt_seqs lazily using kvzalloc()") Signed-off-by: Andrea Righi <[email protected]> Signed-off-by: Tejun Heo <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f1ad80f commit 18228a7

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

kernel/sched/ext.c

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

46334633
mutex_lock(&scx_enable_mutex);
46344634

4635-
ret = alloc_kick_pseqs();
4636-
if (ret)
4637-
goto err_unlock;
4638-
46394635
if (scx_enable_state() != SCX_DISABLED) {
46404636
ret = -EBUSY;
4641-
goto err_free_pseqs;
4637+
goto err_unlock;
46424638
}
46434639

4640+
ret = alloc_kick_pseqs();
4641+
if (ret)
4642+
goto err_unlock;
4643+
46444644
sch = scx_alloc_and_add_sched(ops);
46454645
if (IS_ERR(sch)) {
46464646
ret = PTR_ERR(sch);

0 commit comments

Comments
 (0)