From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Jiri Olsa <jolsa@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>, bpf <bpf@vger.kernel.org>,
Martin KaFai Lau <kafai@fb.com>,
Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>,
Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
Viktor Malik <vmalik@redhat.com>,
"Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Subject: Re: [PATCH bpf-next 3/7] bpf: Add support for kprobe multi session cookie
Date: Mon, 22 Apr 2024 10:48:25 -0700 [thread overview]
Message-ID: <CAADnVQLAgVgf__rxd+C_RO1+ELEKOcLP5eN3V9QGWkpBvUT59g@mail.gmail.com> (raw)
In-Reply-To: <20240422121241.1307168-4-jolsa@kernel.org>
On Mon, Apr 22, 2024 at 5:13 AM Jiri Olsa <jolsa@kernel.org> wrote:
>
> Adding support for cookie within the session of kprobe multi
> entry and return program.
>
> The session cookie is u64 value and can be retrieved be new
> kfunc bpf_session_cookie, which returns pointer to the cookie
> value. The bpf program can use the pointer to store (on entry)
> and load (on return) the value.
>
> The cookie value is implemented via fprobe feature that allows
> to share values between entry and return ftrace fprobe callbacks.
>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
> kernel/bpf/verifier.c | 7 +++++++
> kernel/trace/bpf_trace.c | 19 ++++++++++++++++---
> 2 files changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 68cfd6fc6ad4..baaca451aebc 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -10987,6 +10987,7 @@ enum special_kfunc_type {
> KF_bpf_percpu_obj_drop_impl,
> KF_bpf_throw,
> KF_bpf_iter_css_task_new,
> + KF_bpf_session_cookie,
> };
>
> BTF_SET_START(special_kfunc_set)
> @@ -11013,6 +11014,7 @@ BTF_ID(func, bpf_throw)
> #ifdef CONFIG_CGROUPS
> BTF_ID(func, bpf_iter_css_task_new)
> #endif
> +BTF_ID(func, bpf_session_cookie)
> BTF_SET_END(special_kfunc_set)
>
> BTF_ID_LIST(special_kfunc_list)
> @@ -11043,6 +11045,7 @@ BTF_ID(func, bpf_iter_css_task_new)
> #else
> BTF_ID_UNUSED
> #endif
> +BTF_ID(func, bpf_session_cookie)
>
> static bool is_kfunc_ret_null(struct bpf_kfunc_call_arg_meta *meta)
> {
> @@ -12409,6 +12412,10 @@ static int check_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
> * because packet slices are not refcounted (see
> * dynptr_type_refcounted)
> */
> + } else if (meta.func_id == special_kfunc_list[KF_bpf_session_cookie]) {
> + mark_reg_known_zero(env, regs, BPF_REG_0);
> + regs[BPF_REG_0].type = PTR_TO_MEM;
> + regs[BPF_REG_0].mem_size = sizeof(u64);
Are you sure you need this?
} else if (!__btf_type_is_struct(ptr_type)) {
block should have handled it automatically.
> +__bpf_kfunc __u64 *bpf_session_cookie(void)
> +{
...
next prev parent reply other threads:[~2024-04-22 17:48 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-22 12:12 [PATCH bpf-next 0/7] bpf: Introduce kprobe_multi session attach Jiri Olsa
2024-04-22 12:12 ` [PATCH bpf-next 1/7] bpf: Add support for kprobe multi " Jiri Olsa
2024-04-24 0:26 ` Andrii Nakryiko
2024-04-24 11:46 ` Jiri Olsa
2024-04-22 12:12 ` [PATCH bpf-next 2/7] bpf: Add support for kprobe multi session context Jiri Olsa
2024-04-24 0:26 ` Andrii Nakryiko
2024-04-24 11:45 ` Jiri Olsa
2024-04-22 12:12 ` [PATCH bpf-next 3/7] bpf: Add support for kprobe multi session cookie Jiri Olsa
2024-04-22 17:48 ` Alexei Starovoitov [this message]
2024-04-22 20:55 ` Jiri Olsa
2024-04-24 0:26 ` Andrii Nakryiko
2024-04-24 11:45 ` Jiri Olsa
2024-04-22 12:12 ` [PATCH bpf-next 4/7] libbpf: Add support for kprobe multi session attach Jiri Olsa
2024-04-24 0:26 ` Andrii Nakryiko
2024-04-24 11:45 ` Jiri Olsa
2024-04-22 12:12 ` [PATCH bpf-next 5/7] libbpf: Add kprobe session attach type name to attach_type_name Jiri Olsa
2024-04-24 0:27 ` Andrii Nakryiko
2024-04-24 11:44 ` Jiri Olsa
2024-04-22 12:12 ` [PATCH bpf-next 6/7] selftests/bpf: Add kprobe multi session test Jiri Olsa
2024-04-24 0:27 ` Andrii Nakryiko
2024-04-24 11:44 ` Jiri Olsa
2024-04-30 8:10 ` Jiri Olsa
2024-04-22 12:12 ` [PATCH bpf-next 7/7] selftests/bpf: Add kprobe multi wrapper cookie test Jiri Olsa
2024-04-24 0:27 ` Andrii Nakryiko
2024-04-24 11:44 ` Jiri Olsa
2024-04-24 0:27 ` [PATCH bpf-next 0/7] bpf: Introduce kprobe_multi session attach Andrii Nakryiko
2024-04-24 5:12 ` John Fastabend
2024-04-24 11:43 ` Jiri Olsa
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=CAADnVQLAgVgf__rxd+C_RO1+ELEKOcLP5eN3V9QGWkpBvUT59g@mail.gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=mhiramat@kernel.org \
--cc=sdf@google.com \
--cc=songliubraving@fb.com \
--cc=vmalik@redhat.com \
--cc=yhs@fb.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;
as well as URLs for NNTP newsgroup(s).