From: Ihor Solodrai <ihor.solodrai@linux.dev>
To: Jiri Olsa <olsajiri@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Eduard Zingerman <eddyz87@gmail.com>,
bpf@vger.kernel.org, kernel-team@meta.com
Subject: Re: [PATCH bpf-next v3 1/2] bpf: Support struct btf_struct_meta via KF_IMPLICIT_ARGS
Date: Thu, 19 Mar 2026 13:37:28 -0700 [thread overview]
Message-ID: <470ba10a-096c-4f54-81e0-b896a4d72e25@linux.dev> (raw)
In-Reply-To: <abvrQATstf5nuOpK@krava>
On 3/19/26 5:25 AM, Jiri Olsa wrote:
> On Wed, Mar 18, 2026 at 04:42:09PM -0700, Ihor Solodrai wrote:
>
> SNIP
>
>>
>> +/*
>> + * A kfunc with KF_IMPLICIT_ARGS has two prototypes in BTF:
>> + * - the _impl prototype with full arg list (this is meta->func_proto)
>> + * - the BPF API prototype w/o implicit args (func->type in BTF)
>> + * To determine whether an argument is implicit, we compare its position
>> + * against the number of arguments of both prototypes.
>> + */
>> +static bool is_kfunc_arg_implicit(const struct bpf_kfunc_call_arg_meta *meta, u32 arg_idx)
>> +{
>> + const struct btf_type *func, *func_proto;
>> + u32 argn, full_argn;
>> +
>> + if (!(meta->kfunc_flags & KF_IMPLICIT_ARGS))
>> + return false;
>> +
>> + full_argn = btf_type_vlen(meta->func_proto);
>> +
>> + func = btf_type_by_id(meta->btf, meta->func_id);
>> + func_proto = btf_type_by_id(meta->btf, func->type);
>> + argn = btf_type_vlen(func_proto);
>> +
>> + return argn <= arg_idx && arg_idx < full_argn;
>
> hi,
Hi Jiri, thank you for taking a look.
> I understand above is faster, but should we rather check for exact
> types with something like:
>
> __is_kfunc_ptr_arg_type(btf, arg, KF_ARG_PROG_AUX_ID ||
> __is_kfunc_ptr_arg_type(btf, arg, KF_ARG_BTF_STRUCT_META
This is an open question, see my discussion with Andrii [1].
IMO we don't have to enforce the argument type in
is_kfunc_arg_implicit(). The only way I can see this check causing
problems is by an invalid kfunc declaration, or a relevant bug in
resolve_btfids causing bad/wrong BTF. My understanding is that
verifier can trust kernel's BTF as long as it's valid BTF.
But let me know if I'm missing something here.
[1] https://lore.kernel.org/bpf/3d069965-2992-421f-bb94-827bcb177f17@linux.dev/
>
> jirka
next prev parent reply other threads:[~2026-03-19 20:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-18 23:42 [PATCH bpf-next v3 1/2] bpf: Support struct btf_struct_meta via KF_IMPLICIT_ARGS Ihor Solodrai
2026-03-18 23:42 ` [PATCH bpf-next v3 2/2] selftests/bpf: Update kfuncs using btf_struct_meta to new variants Ihor Solodrai
2026-03-19 12:30 ` Jiri Olsa
2026-03-19 20:43 ` Ihor Solodrai
2026-03-20 11:06 ` Jiri Olsa
2026-03-20 14:50 ` Mykyta Yatsenko
2026-03-19 12:25 ` [PATCH bpf-next v3 1/2] bpf: Support struct btf_struct_meta via KF_IMPLICIT_ARGS Jiri Olsa
2026-03-19 20:37 ` Ihor Solodrai [this message]
2026-03-20 15:49 ` Mykyta Yatsenko
2026-03-27 0:16 ` Ihor Solodrai
2026-03-27 19:19 ` Mykyta Yatsenko
2026-03-21 20:27 ` Alexei Starovoitov
2026-03-23 19:58 ` Ihor Solodrai
2026-03-24 17:22 ` Alexei Starovoitov
2026-03-26 19:13 ` Ihor Solodrai
2026-03-27 20:48 ` Alexei Starovoitov
2026-03-27 20:55 ` Ihor Solodrai
2026-03-27 21:00 ` Alexei Starovoitov
2026-03-27 21:08 ` Ihor Solodrai
2026-03-27 21:47 ` Alexei Starovoitov
2026-03-27 22:06 ` Ihor Solodrai
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=470ba10a-096c-4f54-81e0-b896a4d72e25@linux.dev \
--to=ihor.solodrai@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=kernel-team@meta.com \
--cc=olsajiri@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.