]> www.infradead.org Git - users/jedix/linux-maple.git/commit
sched_ext: Validate prev_cpu in scx_bpf_select_cpu_dfl()
authorAndrea Righi <arighi@nvidia.com>
Mon, 3 Mar 2025 17:51:59 +0000 (18:51 +0100)
committerTejun Heo <tj@kernel.org>
Mon, 3 Mar 2025 17:55:48 +0000 (07:55 -1000)
commit9360dfe4cbd62ff1eb8217b815964931523b75b3
tree02d5452f2b0b802bc740957174f43c9d2914e90c
parent8fef0a3b17bb258130a4fcbcb5addf94b25e9ec5
sched_ext: Validate prev_cpu in scx_bpf_select_cpu_dfl()

If a BPF scheduler provides an invalid CPU (outside the nr_cpu_ids
range) as prev_cpu to scx_bpf_select_cpu_dfl() it can cause a kernel
crash.

To prevent this, validate prev_cpu in scx_bpf_select_cpu_dfl() and
trigger an scx error if an invalid CPU is specified.

Fixes: f0e1a0643a59b ("sched_ext: Implement BPF extensible scheduler class")
Cc: stable@vger.kernel.org # v6.12+
Signed-off-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/sched/ext.c