Re: [PATCH v2] sched_ext: Reject NMI calls to lock-taking kfuncs
From: Tejun Heo
Date: Wed Sep 02 2026 - 02:51:49 EST
Hello,
On Wed, Sep 02, 2026 at 10:31:24AM +0800, Wanwu Li wrote:
> - if (sch)
> - destroy_dsq(sch, dsq_id);
> + if (!sch)
> + return;
unlikely(!sch) like the other kfuncs.
> @@ -9756,6 +9755,9 @@ __bpf_kfunc struct task_struct *bpf_iter_scx_dsq_next(struct bpf_iter_scx_dsq *i
> if (!kit->dsq)
> return NULL;
>
> + if (!scx_kf_allowed_ctx(kit->dsq->sched))
> + return NULL;
new(), next() and destroy() always run in the same context, so reject in
bpf_iter_scx_dsq_new() and drop the checks from next() and destroy(). With
kit->dsq left NULL, both are no-ops.
> +static __always_inline bool __scx_kf_allowed_ctx(struct scx_sched *sch,
> + const char *who)
No need to wrap.
Thanks.
--
tejun