Re: [RFC PATCH bpf-next 2/8] sched_ext: Add filter for scx_kfunc_ids_select_cpu

From: Juntong Deng
Date: Thu Feb 06 2025 - 19:02:22 EST


On 2025/2/6 23:39, Andrea Righi wrote:
On Wed, Feb 05, 2025 at 07:30:14PM +0000, Juntong Deng wrote:
...
+static int scx_kfunc_ids_other_rqlocked_filter(const struct bpf_prog *prog, u32 kfunc_id)
+{
+ u32 moff = prog->aux->attach_st_ops_member_off;
+
+ if (moff == offsetof(struct sched_ext_ops, runnable) ||
+ moff == offsetof(struct sched_ext_ops, dequeue) ||
+ moff == offsetof(struct sched_ext_ops, stopping) ||
+ moff == offsetof(struct sched_ext_ops, quiescent) ||
+ moff == offsetof(struct sched_ext_ops, yield) ||
+ moff == offsetof(struct sched_ext_ops, cpu_acquire) ||
+ moff == offsetof(struct sched_ext_ops, running) ||
+ moff == offsetof(struct sched_ext_ops, core_sched_before) ||
+ moff == offsetof(struct sched_ext_ops, set_cpumask) ||
+ moff == offsetof(struct sched_ext_ops, update_idle) ||
+ moff == offsetof(struct sched_ext_ops, tick) ||
+ moff == offsetof(struct sched_ext_ops, enable) ||
+ moff == offsetof(struct sched_ext_ops, set_weight) ||
+ moff == offsetof(struct sched_ext_ops, disable) ||
+ moff == offsetof(struct sched_ext_ops, exit_task) ||
+ moff == offsetof(struct sched_ext_ops, dump_task) ||
+ moff == offsetof(struct sched_ext_ops, dump_cpu))
+ return 0;
+
+ return -EACCES;

Actually, do we need this filter at all?

I think the other filters in your patch set should be sufficient to
establish the correct permissions for all kfuncs, as none of them need to
be called from any rq-locked operations. Or am I missing something?


Thanks for your reply.

I think I misunderstood SCX_KF_REST.

I incorrectly thought that all but SCX_KF_UNLOCKED belonged to
SCX_KF_REST (including SCX_KF_CPU_RELEASE, SCX_KF_DISPATCH, etc.).

I will remove scx_kfunc_ids_other_rqlocked_filter in the next version.

If you find any other mistakes, please let me know.

-Andrea