[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z8IrGagRhkHlUejz@slm.duckdns.org>
Date: Fri, 28 Feb 2025 11:31:05 -1000
From: Tejun Heo <tj@...nel.org>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc: Juntong Deng <juntong.deng@...look.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
John Fastabend <john.fastabend@...il.com>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>, Eddy Z <eddyz87@...il.com>,
Song Liu <song@...nel.org>, Yonghong Song <yonghong.song@...ux.dev>,
KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...ichev.me>,
Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
Kumar Kartikeya Dwivedi <memxor@...il.com>,
David Vernet <void@...ifault.com>, Andrea Righi <arighi@...dia.com>,
Changwoo Min <changwoo@...lia.com>, bpf <bpf@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH sched_ext/for-6.15 v3 3/5] sched_ext: Add
scx_kfunc_ids_ops_context_sensitive for unified filtering of
context-sensitive SCX kfuncs
Hello,
On Thu, Feb 27, 2025 at 06:34:37PM -0800, Alexei Starovoitov wrote:
> > Hmm... would that mean a non-sched_ext bpf prog would be able to call e.g.
> > scx_bpf_dsq_insert()?
>
> Not as far as I can tell.
> scx_kfunc_ids_unlocked[] doesn't include scx_bpf_dsq_insert.
> It's part of scx_kfunc_ids_enqueue_dispatch[].
>
> So this bit in patch 3 enables it:
> + if ((flags & SCX_OPS_KF_ENQUEUE) &&
> + btf_id_set8_contains(&scx_kfunc_ids_enqueue_dispatch, kfunc_id))
>
> and in patch 2:
> + [SCX_OP_IDX(enqueue)] = SCX_OPS_KF_ENQUEUE,
>
> So scx_bpf_dsq_insert() kfunc can only be called out
> of enqueue() sched-ext hook.
>
> So the restriction is still the same. afaict.
Hmm... maybe I'm missing something:
static int scx_kfunc_ids_ops_context_sensitive_filter(const struct bpf_prog *prog, u32 kfunc_id)
{
u32 moff, flags;
// allow non-context sensitive kfuncs
if (!btf_id_set8_contains(&scx_kfunc_ids_ops_context_sensitive, kfunc_id))
return 0;
// allow unlocked to be called form all SYSCALL progs
if (prog->type == BPF_PROG_TYPE_SYSCALL &&
btf_id_set8_contains(&scx_kfunc_ids_unlocked, kfunc_id))
return 0;
// *** HERE, allow if the prog is not SCX ***
if (prog->type == BPF_PROG_TYPE_STRUCT_OPS &&
prog->aux->st_ops != &bpf_sched_ext_ops)
return 0;
/* prog->type == BPF_PROG_TYPE_STRUCT_OPS && prog->aux->st_ops == &bpf_sched_ext_ops*/
// other context sensitive allow's
So, I think it'd say yes if a non-SCX BPF prog tries to call a context
sensitive SCX kfunc.
Thanks.
--
tejun
Powered by blists - more mailing lists