From: Tejun Heo <tj@kernel.org>
To: Juntong Deng <juntong.deng@outlook.com>
Cc: ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com,
andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com,
song@kernel.org, yonghong.song@linux.dev, kpsingh@kernel.org,
sdf@fomichev.me, haoluo@google.com, jolsa@kernel.org,
memxor@gmail.com, void@manifault.com, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH bpf-next 6/7] sched_ext: Make SCX use BPF capabilities
Date: Fri, 17 Jan 2025 06:58:33 -1000 [thread overview]
Message-ID: <Z4qMOUq1KXTX-5cD@slm.duckdns.org> (raw)
In-Reply-To: <AM6PR03MB50802A825536C00D2B53333C991A2@AM6PR03MB5080.eurprd03.prod.outlook.com>
Hello,
On Thu, Jan 16, 2025 at 07:41:11PM +0000, Juntong Deng wrote:
...
> +static int bpf_scx_bpf_capabilities_adjust(unsigned long *bpf_capabilities,
> + u32 context_info, bool enter)
> +{
> + if (enter) {
> + switch (context_info) {
> + case offsetof(struct sched_ext_ops, select_cpu):
> + ENABLE_BPF_CAPABILITY(bpf_capabilities, BPF_CAP_SCX_KF_SELECT_CPU);
> + ENABLE_BPF_CAPABILITY(bpf_capabilities, BPF_CAP_SCX_KF_ENQUEUE);
> + break;
...
> + }
> + } else {
> + switch (context_info) {
> + case offsetof(struct sched_ext_ops, select_cpu):
> + DISABLE_BPF_CAPABILITY(bpf_capabilities, BPF_CAP_SCX_KF_SELECT_CPU);
> + DISABLE_BPF_CAPABILITY(bpf_capabilities, BPF_CAP_SCX_KF_ENQUEUE);
> + break;
...
> + }
> + return 0;
> +}
From sched_ext's POV, this, or whatever works is fine but I have some basic
comments:
- The caps are u32. If all kfuncs use this facility for access control, it's
plausible or even likely that 32 is not going to be enough. I suppose it
can be turned into u64 and then a proper bitmap later? Maybe good idea to
start out with a proper bitmap in the first place?
- There are benefits to centralizing all the caps in a single place but it
can also be kinda cumbersome.
- Even with global defs, the cap adjustments are procedural, not
declarative. If it needs to be procedural anyway, I wonder whether the
global defs are necessary in the first place. What prevents implementing
it the other way around - pass in the calling context and provide helpers
and macros to respond yay or nay procedurally.
Thanks.
--
tejun
next prev parent reply other threads:[~2025-01-17 16:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-16 19:35 [RFC PATCH bpf-next 0/7] bpf: BPF internal fine-grained permission management (BPF internal capabilities) Juntong Deng
2025-01-16 19:41 ` [RFC PATCH bpf-next 1/7] bpf: Add capability field to BTF_ID_FLAGS Juntong Deng
2025-01-16 19:41 ` [RFC PATCH bpf-next 2/7] bpf: Add enum bpf_capability Juntong Deng
2025-01-16 22:56 ` Song Liu
2025-01-17 19:37 ` Juntong Deng
2025-01-17 21:40 ` Song Liu
2025-01-20 21:49 ` Juntong Deng
2025-01-21 17:41 ` Song Liu
2025-01-16 19:41 ` [RFC PATCH bpf-next 3/7] bpf: Add capabilities version of kfuncs registration Juntong Deng
2025-01-16 19:41 ` [RFC PATCH bpf-next 4/7] bpf: Make the verifier support BPF capabilities Juntong Deng
2025-01-16 19:41 ` [RFC PATCH bpf-next 5/7] bpf: Add default BPF capabilities initialization for program types Juntong Deng
2025-01-16 19:41 ` [RFC PATCH bpf-next 6/7] sched_ext: Make SCX use BPF capabilities Juntong Deng
2025-01-17 16:58 ` Tejun Heo [this message]
2025-01-17 20:09 ` Juntong Deng
2025-01-24 4:52 ` Alexei Starovoitov
2025-01-24 22:44 ` Juntong Deng
2025-01-30 0:32 ` Alexei Starovoitov
2025-01-16 19:41 ` [RFC PATCH bpf-next 7/7] sched_ext: Add proof-of-concept test case Juntong Deng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z4qMOUq1KXTX-5cD@slm.duckdns.org \
--to=tj@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=juntong.deng@outlook.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=void@manifault.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox