Re: [PATCH bpf-next v1 0/4] libbpf: Support kernel-side kfunc flavors

From: Eduard Zingerman

Date: Wed Nov 18 2026 - 16:42:39 EST


On Wed, 2026-11-18 at 14:12 -0700, Eduard Zingerman wrote:
> On Tue, 2026-11-17 at 12:21 -0700, Ihor Solodrai wrote:

...

> > resolve_btfids fails the build if two of bpf_foo and its flavors have
> > compatible prototypes, unless both have foo's exact prototype
> > (aliases), so the fallback finds at most one match.  This ensures at
>
> Why is an exception for kfuncs with identical prototypes necessary?

Ok, my helpful assistant points out the following use case:

On kernel side:

__bpf_kfunc bool foo(struct task_struct *p, u64 flags);
__bpf_kfunc bool foo___v2(struct task_struct *p, u64 flags);


On BPF side:


extern bool foo(struct task_struct *p, u64 flags) __ksym;
extern bool foo___v2___compat(struct task_struct *p, u64 flags) __ksym;

/* Resolves to the kernel's foo(). */
foo(p, 0);

/* libbpf strips ___compat; resolves to the kernel's foo___v2().
* workaround used before this series.
*/
foo___v2___compat(p, 0);

New mechanics adds an obligation on the kernel side to maintain that
foo and foo___v2___compat are semantically identical, despite being
physically different functions. (Does it?)

Would it be possible to use some kind of annotation, e.g.:
- __alias(foo___v2) (an ELF symbol alias), or
- __kfunc_alias(foo___v2)
(resolving to some sort of btf_decl_tag for resolve_btfids to act upon).
And avoid allowing functions with compatible prototypes w/o exceptions.

?