linux/kernel/sched
Tejun Heo ea7c716a24 sched_ext: Refuse cross-task select_cpu_from_kfunc calls
select_cpu_from_kfunc() skipped pi_lock for @p when called from
ops.select_cpu() or another rq-locked SCX op, assuming the held lock
protects @p. scx_bpf_select_cpu_dfl() / __scx_bpf_select_cpu_and() accept an
arbitrary KF_RCU task_struct, so a caller in e.g. ops.select_cpu(p1) or
ops.enqueue(p1) can pass some other p2 - the held pi_lock / rq lock is p1's,
not p2's - and reading p2->cpus_ptr / nr_cpus_allowed races with
set_cpus_allowed_ptr() and migrate_disable_switch() on another CPU.

Abort the scheduler on cross-task calls in both branches: for
ops.select_cpu() use scx_kf_arg_task_ok() to verify @p is the wake-up
task recorded in current->scx.kf_tasks[] by SCX_CALL_OP_TASK_RET();
for other rq-locked SCX ops compare task_rq(p) against scx_locked_rq().

v2: Switch the in_select_cpu cross-task check from direct_dispatch_task
    comparison to scx_kf_arg_task_ok(). The former spuriously rejects when
    ops.select_cpu() calls scx_bpf_dsq_insert() first, then calls
    scx_bpf_select_cpu_*() on the same task. (Andrea Righi)

Fixes: 0022b32850 ("sched_ext: Decouple kfunc unlocked-context check from kf_mask")
Reported-by: Chris Mason <clm@meta.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Andrea Righi <arighi@nvidia.com>
2026-04-24 14:31:36 -10:00
..
autogroup.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
autogroup.h
build_policy.c sched_ext: Move internal type and accessor definitions to ext_internal.h 2025-09-03 11:33:28 -10:00
build_utility.c
clock.c sched/clock: Avoid false sharing for sched_clock_irqtime 2026-02-03 12:04:19 +01:00
completion.c
core_sched.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
core.c Runtime Verification updates for 7.1: 2026-04-15 17:15:18 -07:00
cpuacct.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
cpudeadline.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
cpudeadline.h sched/deadline: only set free_cpus for online runqueues 2025-10-16 11:13:49 +02:00
cpufreq_schedutil.c cpufreq: Pass the policy to cpufreq_driver->adjust_perf() 2026-04-02 11:30:24 -05:00
cpufreq.c
cpupri.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
cpupri.h
cputime.c - A nice cleanup to the paravirt code containing a unification of the paravirt 2026-02-10 19:01:45 -08:00
deadline.c Runtime Verification updates for 7.1: 2026-04-15 17:15:18 -07:00
debug.c Merge branch 'sched/urgent' into sched/core, to resolve conflicts 2026-04-02 15:04:09 +02:00
ext_idle.c sched_ext: Refuse cross-task select_cpu_from_kfunc calls 2026-04-24 14:31:36 -10:00
ext_idle.h sched_ext: Deny SCX kfuncs to non-SCX struct_ops programs 2026-04-20 07:57:29 -10:00
ext_internal.h sched_ext: Make bypass LB cpumasks per-scheduler 2026-04-24 14:31:36 -10:00
ext.c sched_ext: Align cgroup #ifdef guards with SUB_SCHED vs GROUP_SCHED 2026-04-24 14:31:36 -10:00
ext.h sched_ext: Add @kargs to scx_fork() 2026-03-06 07:58:02 -10:00
fair.c Scheduler changes for v7.1: 2026-04-14 13:33:36 -07:00
features.h Scheduler changes for v7.1: 2026-04-14 13:33:36 -07:00
idle.c sched: idle: Consolidate the handling of two special cases 2026-03-16 20:29:47 +01:00
isolation.c cgroup/cpuset: Call housekeeping_update() without holding cpus_read_lock 2026-02-23 10:46:49 -10:00
loadavg.c
Makefile sched: Enable context analysis for core.c and fair.c 2026-01-05 16:43:36 +01:00
membarrier.c rseq: Simplify the event notification 2025-11-04 08:30:09 +01:00
pelt.c treewide: Update email address 2026-01-11 06:09:11 -10:00
pelt.h sched/fair: Switch to task based throttle model 2025-09-03 10:03:14 +02:00
psi.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
rq-offsets.c sched: Make migrate_{en,dis}able() inline 2025-09-25 09:57:16 +02:00
rt.c sched/rt: Cleanup global RT bandwidth functions 2026-04-08 13:11:44 +02:00
sched-pelt.h
sched.h sched_ext: Changes for v7.1 2026-04-15 10:54:24 -07:00
smp.h
stats.c
stats.h delayacct: add timestamp of delay max 2026-01-31 16:16:06 -08:00
stop_task.c sched/core: Rework sched_class::wakeup_preempt() and rq_modified_*() 2025-12-17 10:53:25 +01:00
swait.c
syscalls.c Linux 7.0-rc4 2026-03-17 07:14:42 +01:00
topology.c sched/fair: Use sched_energy_enabled() 2026-04-03 14:23:41 +02:00
wait_bit.c
wait.c