From: Martin KaFai Lau <martin.lau@linux.dev>
To: Chuyi Zhou <zhouchuyi@bytedance.com>
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
martin.lau@kernel.org, tj@kernel.org,
linux-kernel@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 2/6] bpf: Introduce css_task open-coded iterator kfuncs
Date: Tue, 12 Sep 2023 12:57:47 -0700 [thread overview]
Message-ID: <8b272d63-5dd7-13bd-7691-d061895fdbe1@linux.dev> (raw)
In-Reply-To: <20230912070149.969939-3-zhouchuyi@bytedance.com>
On 9/12/23 12:01 AM, Chuyi Zhou wrote:
> +__bpf_kfunc int bpf_iter_css_task_new(struct bpf_iter_css_task *it,
> + struct cgroup_subsys_state *css, unsigned int flags)
> +{
> + struct bpf_iter_css_task_kern *kit = (void *)it;
> +
> + BUILD_BUG_ON(sizeof(struct bpf_iter_css_task_kern) != sizeof(struct bpf_iter_css_task));
> + BUILD_BUG_ON(__alignof__(struct bpf_iter_css_task_kern) !=
> + __alignof__(struct bpf_iter_css_task));
> +
> + switch (flags) {
> + case CSS_TASK_ITER_PROCS | CSS_TASK_ITER_THREADED:
> + case CSS_TASK_ITER_PROCS:
> + case 0:
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + kit->css_it = kzalloc(sizeof(struct css_task_iter), GFP_KERNEL);
> + if (!kit->css_it)
> + return -ENOMEM;
> + css_task_iter_start(css, flags, kit->css_it);
> + return 0;
> +}
> +
> +static bool check_css_task_iter_allowlist(struct bpf_verifier_env *env)
> +{
> + enum bpf_prog_type prog_type = resolve_prog_type(env->prog);
> +
> + switch (prog_type) {
> + case BPF_PROG_TYPE_LSM:
This will allow the non-sleepable lsm prog to call bpf_iter_css_task_new. The
above kzalloc(GFP_KERNEL) in bpf_iter_css_task_new should trigger a lockdep
error in the lsm selftest in patch 6.
> + return true;
> + case BPF_TRACE_ITER:
> + return env->prog->aux->sleepable;
> + default:
> + return false;
> + }
> +}
next prev parent reply other threads:[~2023-09-12 19:57 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-12 7:01 [PATCH bpf-next v2 0/6] Add Open-coded process and css iters Chuyi Zhou
2023-09-12 7:01 ` [PATCH bpf-next v2 1/6] cgroup: Prepare for using css_task_iter_*() in BPF Chuyi Zhou
2023-09-18 20:42 ` Tejun Heo
2023-09-12 7:01 ` [PATCH bpf-next v2 2/6] bpf: Introduce css_task open-coded iterator kfuncs Chuyi Zhou
2023-09-12 17:13 ` Alexei Starovoitov
2023-09-13 14:02 ` Chuyi Zhou
2023-09-12 19:57 ` Martin KaFai Lau [this message]
2023-09-13 4:56 ` Chuyi Zhou
2023-09-14 23:26 ` Andrii Nakryiko
2023-09-12 7:01 ` [PATCH bpf-next v2 3/6] bpf: Introduce process open coded " Chuyi Zhou
2023-09-14 23:26 ` Andrii Nakryiko
2023-09-15 4:48 ` Chuyi Zhou
2023-09-15 15:03 ` Chuyi Zhou
2023-09-15 20:37 ` Andrii Nakryiko
2023-09-16 14:03 ` Chuyi Zhou
2023-09-19 23:30 ` Andrii Nakryiko
2023-09-20 12:20 ` Chuyi Zhou
2023-09-12 7:01 ` [PATCH bpf-next v2 4/6] bpf: Introduce css_descendant open-coded " Chuyi Zhou
2023-09-13 7:25 ` kernel test robot
2023-09-13 9:02 ` kernel test robot
2023-09-13 9:13 ` kernel test robot
2023-09-14 23:26 ` Andrii Nakryiko
2023-09-15 11:57 ` Chuyi Zhou
2023-09-15 20:25 ` Andrii Nakryiko
2023-09-12 7:01 ` [PATCH bpf-next v2 5/6] bpf: teach the verifier to enforce css_iter and process_iter in RCU CS Chuyi Zhou
2023-09-13 13:53 ` Chuyi Zhou
2023-09-14 8:56 ` Chuyi Zhou
2023-09-14 23:26 ` Andrii Nakryiko
2023-09-15 5:46 ` [External] " Chuyi Zhou
2023-09-15 20:23 ` Andrii Nakryiko
2023-09-14 23:26 ` Andrii Nakryiko
2023-09-12 7:01 ` [PATCH bpf-next v2 6/6] selftests/bpf: Add tests for open-coded task and css iter Chuyi Zhou
2023-09-12 7:11 ` [PATCH bpf-next v2 0/6] Add Open-coded process and css iters Chuyi Zhou
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=8b272d63-5dd7-13bd-7691-d061895fdbe1@linux.dev \
--to=martin.lau@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@kernel.org \
--cc=tj@kernel.org \
--cc=zhouchuyi@bytedance.com \
/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