Re: [PATCH bpf-next 0/2] sched_ext: Mark scx_bpf_cpu_rq() nullable

From: Christian Loehle

Date: Fri Jun 19 2026 - 11:39:16 EST


On 6/19/26 15:45, Nuoqi Gui wrote:
> scx_bpf_cpu_rq() can return NULL for invalid CPU input or when no SCX
> scheduler is active, but its kfunc registration does not advertise the
> nullable return to the verifier.
>
> Add KF_RET_NULL to scx_bpf_cpu_rq(), matching the nullable metadata already
> present on neighboring SCX accessors, and add a sched_ext selftest that rejects
> an unchecked direct runqueue field read.
>

See 5c48d88fe004 ("sched_ext: deprecation warn for scx_bpf_cpu_rq()")
I guess I can send a patch to remove the function, it's been a while.

> This fixes a regression introduced by 6203ef73fa5c ("sched/ext: Add BPF
> function to fetch rq").

How so?

>
> Signed-off-by: Nuoqi Gui <gnq25@xxxxxxxxxxxxxxxxxxxxx>
> ---
> Nuoqi Gui (2):
> sched_ext: Mark scx_bpf_cpu_rq() as nullable
> selftests/sched_ext: Cover scx_bpf_cpu_rq() null return
>
> kernel/sched/ext.c | 2 +-
> tools/testing/selftests/sched_ext/Makefile | 1 +
> .../selftests/sched_ext/cpu_rq_ret_null.bpf.c | 27 +++++++++++++++
> .../testing/selftests/sched_ext/cpu_rq_ret_null.c | 38 ++++++++++++++++++++++
> 4 files changed, 67 insertions(+), 1 deletion(-)
> ---
> base-commit: e4287bf34f97a88c7d9322f5bde828724c073a6b
> change-id: 20260617-f01-14-scx-cpu-rq-ret-null-2e79535acd57
>
> Best regards,
> --
> Nuoqi Gui <gnq25@xxxxxxxxxxxxxxxxxxxxx>
>
>