All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Ihor Solodrai <ihor.solodrai@linux.dev>,
	Alexei Starovoitov <ast@kernel.org>,
	 Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kumar Kartikeya Dwivedi	 <memxor@gmail.com>
Cc: Alan Maguire <alan.maguire@oracle.com>,
	Emil Tsalapatis	 <emil@etsalapatis.com>,
	Jiri Olsa <jolsa@kernel.org>, Song Liu <song@kernel.org>,
	 Tejun Heo <tj@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	bpf@vger.kernel.org,  linux-kernel@vger.kernel.org,
	sched-ext@lists.linux.dev
Subject: Re: [PATCH bpf-next v1 3/4] resolve_btfids: Reject kfunc families that libbpf can't disambiguate
Date: Wed, 18 Nov 2026 15:59:56 -0700	[thread overview]
Message-ID: <a838d40d84ccf3115faac3d3b7b4d91b923b03ff.camel@gmail.com> (raw)
In-Reply-To: <20261117192153.3384031-4-ihor.solodrai@linux.dev>

On Tue, 2026-11-17 at 12:21 -0700, Ihor Solodrai wrote:
> Kfuncs sharing an essential name, foo and foo___<flavor>, form a family.
> When resolving a kfunc foo, libbpf binds the kernel's foo if the
> prototypes are compatible, and otherwise the only family member whose
> prototype passes bpf_core_types_are_compat() against the declaration.
> That is only safe if no declaration can be compatible with two members
> at once.
> 
> bpf_core_types_are_compat() compares prototypes kind by kind, so it
> acts as an equivalence and a pairwise check is enough. Run it on every
> pair of family members after dedup, using libbpf's own function, and
> fail the build if any pair is compatible. A foo___<flavor> with the
> same deduplicated FUNC_PROTO as foo is an alias and is allowed: libbpf
> binds foo first, so the alias is never picked in its place. There is
> only one foo: btf_check_kfunc_name() refuses to register a module kfunc
> named like a function in vmlinux or in another module. Dedup compares
> parameter names too, so an alias has to copy the signature verbatim.
> 
> Recognize family members by their bpf_kfunc decl tags rather than by
> the BTF ID sets. The tags are what libbpf filters candidates on, and for
> a module they also cover the vmlinux kfuncs in base BTF, so module
> kfuncs get checked against vmlinux kfuncs of the same family.
> 
> The bpf_kfunc_flavor family in bpf_testmod passes: ___v1 differs in
> arity and ___v2 is an alias.
> 
> Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
> ---

Acked-by: Eduard Zingerman <eddyz87@gmail.com>

>  tools/bpf/resolve_btfids/btf_colors.c |  11 +++
>  tools/bpf/resolve_btfids/btf_colors.h |   3 +
>  tools/bpf/resolve_btfids/main.c       | 134 ++++++++++++++++++++++++++
>  3 files changed, 148 insertions(+)
> 
> diff --git a/tools/bpf/resolve_btfids/btf_colors.c b/tools/bpf/resolve_btfids/btf_colors.c
> index 5d307d70e7f2..91c10106319e 100644
> --- a/tools/bpf/resolve_btfids/btf_colors.c
> +++ b/tools/bpf/resolve_btfids/btf_colors.c
> @@ -13,6 +13,17 @@ void btf_sha256(const void *data, size_t len,
>  	libbpf_sha256(data, len, out);
>  }
>  
> +size_t btf_essential_name_len(const char *name)
> +{
> +	return bpf_core_essential_name_len(name);
> +}
> +
> +int btf_types_are_compat(const struct btf *btf1, __u32 id1,
> +			 const struct btf *btf2, __u32 id2)
> +{
> +	return bpf_core_types_are_compat(btf1, id1, btf2, id2);
> +}

Can main.c include bpf/relo_core.h instead of this symbol-laundering scheme?
Or just define two extern prototypes?

...

  reply	other threads:[~2026-11-18 22:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 19:21 [PATCH bpf-next v1 0/4] libbpf: Support kernel-side kfunc flavors Ihor Solodrai
2026-11-17 19:21 ` [PATCH bpf-next v1 1/4] libbpf: Fall back to kernel ___ flavors when resolving kfuncs Ihor Solodrai
2026-11-18 22:44   ` Eduard Zingerman
2026-11-17 19:21 ` [PATCH bpf-next v1 2/4] selftests/bpf: Test kfunc flavor resolution Ihor Solodrai
2026-11-17 19:21 ` [PATCH bpf-next v1 3/4] resolve_btfids: Reject kfunc families that libbpf can't disambiguate Ihor Solodrai
2026-11-18 22:59   ` Eduard Zingerman [this message]
2026-11-17 19:21 ` [PATCH bpf-next v1 4/4] docs/bpf: Describe how to change a kfunc's prototype Ihor Solodrai
2026-11-17 20:53 ` [PATCH bpf-next v1 0/4] libbpf: Support kernel-side kfunc flavors Tejun Heo
2026-11-18 21:12 ` Eduard Zingerman
2026-11-18 21:37   ` Ihor Solodrai
2026-11-18 22:11     ` Eduard Zingerman
2026-11-18 23:13       ` Ihor Solodrai
2026-11-19 17:50         ` Eduard Zingerman
2026-11-18 21:42   ` Eduard Zingerman
2026-11-18 21:48     ` Ihor Solodrai
2026-11-18 21:57       ` Eduard Zingerman
2026-11-20  3:32 ` 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=a838d40d84ccf3115faac3d3b7b4d91b923b03ff.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=memxor@gmail.com \
    --cc=sched-ext@lists.linux.dev \
    --cc=song@kernel.org \
    --cc=tj@kernel.org \
    --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 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.