From: Greg Kroah-Hartman Date: Sun, 16 Mar 2025 15:28:36 +0000 (+0100) Subject: 6.12-stable patches X-Git-Tag: v6.6.84~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b33435bcbf7a0b880707d76a1e42e0cacc3f89bf;p=thirdparty%2Fkernel%2Fstable-queue.git 6.12-stable patches added patches: sched_ext-validate-prev_cpu-in-scx_bpf_select_cpu_dfl.patch --- diff --git a/queue-6.12/sched_ext-validate-prev_cpu-in-scx_bpf_select_cpu_dfl.patch b/queue-6.12/sched_ext-validate-prev_cpu-in-scx_bpf_select_cpu_dfl.patch new file mode 100644 index 0000000000..ec158dced8 --- /dev/null +++ b/queue-6.12/sched_ext-validate-prev_cpu-in-scx_bpf_select_cpu_dfl.patch @@ -0,0 +1,37 @@ +From 9360dfe4cbd62ff1eb8217b815964931523b75b3 Mon Sep 17 00:00:00 2001 +From: Andrea Righi +Date: Mon, 3 Mar 2025 18:51:59 +0100 +Subject: sched_ext: Validate prev_cpu in scx_bpf_select_cpu_dfl() + +From: Andrea Righi + +commit 9360dfe4cbd62ff1eb8217b815964931523b75b3 upstream. + +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 +Signed-off-by: Tejun Heo +Signed-off-by: Greg Kroah-Hartman +--- + kernel/sched/ext.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/kernel/sched/ext.c ++++ b/kernel/sched/ext.c +@@ -6052,6 +6052,9 @@ __bpf_kfunc_start_defs(); + __bpf_kfunc s32 scx_bpf_select_cpu_dfl(struct task_struct *p, s32 prev_cpu, + u64 wake_flags, bool *is_idle) + { ++ if (!ops_cpu_valid(prev_cpu, NULL)) ++ goto prev_cpu; ++ + if (!static_branch_likely(&scx_builtin_idle_enabled)) { + scx_ops_error("built-in idle tracking is disabled"); + goto prev_cpu; diff --git a/queue-6.12/series b/queue-6.12/series index 6449e02f44..bc2a1abe9c 100644 --- a/queue-6.12/series +++ b/queue-6.12/series @@ -151,3 +151,4 @@ kvm-arm64-remove-vhe-host-restore-of-cpacr_el1.smen.patch kvm-arm64-refactor-exit-handlers.patch kvm-arm64-mark-some-header-functions-as-inline.patch kvm-arm64-eagerly-switch-zcr_el-1-2.patch +sched_ext-validate-prev_cpu-in-scx_bpf_select_cpu_dfl.patch