mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
sched_ext: Fix scx_kick_pseqs corruption on concurrent scheduler loads
commit05e63305c8upstream. 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:14c1da3895("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
f1ad80fdf9
commit
18228a70a0
@@ -4632,15 +4632,15 @@ static int scx_enable(struct sched_ext_ops *ops, struct bpf_link *link)
|
|||||||
|
|
||||||
mutex_lock(&scx_enable_mutex);
|
mutex_lock(&scx_enable_mutex);
|
||||||
|
|
||||||
|
if (scx_enable_state() != SCX_DISABLED) {
|
||||||
|
ret = -EBUSY;
|
||||||
|
goto err_unlock;
|
||||||
|
}
|
||||||
|
|
||||||
ret = alloc_kick_pseqs();
|
ret = alloc_kick_pseqs();
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_unlock;
|
goto err_unlock;
|
||||||
|
|
||||||
if (scx_enable_state() != SCX_DISABLED) {
|
|
||||||
ret = -EBUSY;
|
|
||||||
goto err_free_pseqs;
|
|
||||||
}
|
|
||||||
|
|
||||||
sch = scx_alloc_and_add_sched(ops);
|
sch = scx_alloc_and_add_sched(ops);
|
||||||
if (IS_ERR(sch)) {
|
if (IS_ERR(sch)) {
|
||||||
ret = PTR_ERR(sch);
|
ret = PTR_ERR(sch);
|
||||||
|
|||||||
Reference in New Issue
Block a user