[PATCH 0/2] sched_ext: two more context-safety fixes found in the NMI kfunc audit
From: Wanwu Li
Date: Wed Sep 02 2026 - 23:34:11 EST
Continuing the audit that the sashiko bot kicked off on the NMI-reject
series, I went through every kfunc exposed to BPF_PROG_TYPE_TRACING
(the any / idle / cid context-filter sets). Two more context-safety
issues came out of it; this pair addresses both.
- Patch 1 fixes the scx_locked_rq() class (three "any"-category kfuncs
read scx_locked_rq() and take an unsafe fast path on a non-NULL
return from NMI). scx_locked_rq() gains an in_nmi() test at the
source that returns NULL from NMI, so the three callers fall onto
their unlocked paths. This supersedes guarding them individually.
- Patch 2 fixes an IRQ re-entrancy race on the per-CPU
per_cpu_unvisited nodemask scratch in the idle path. The search
scratch is protected only by preempt_disable(), which doesn't mask
IRQs; switch to irqsave instead. The NMI case is left as-is (a
misuse with no legitimate use and no crash risk).
Wanwu Li (2):
sched_ext: Make scx_locked_rq() return NULL from NMI
sched_ext: Protect the idle-search scratch nodemask with irqsave
kernel/sched/ext/idle.c | 14 ++++++++++++--
kernel/sched/ext/internal.h | 9 +++++++++
2 files changed, 21 insertions(+), 2 deletions(-)
--
2.25.1