Re: [PATCH 2/2] kernel/bpf/verifier: Support module kfunc resolution via instruction offset

From: bot+bpf-ci

Date: Thu Apr 30 2026 - 02:28:14 EST


> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 03f9e16c2abe..7e6a95e6821d 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -2734,7 +2734,10 @@ int bpf_add_kfunc_call(struct bpf_verifier_env *env, u32 func_id, u16 offset)
> if (err)
> return err;
>
> - addr = kallsyms_lookup_name(kfunc.name);
> + if (offset)
> + addr = module_kallsyms_lookup_name(kfunc.name);
> + else
> + addr = kallsyms_lookup_name(kfunc.name);
> if (!addr) {
> verbose(env, "cannot find address for kernel function %s\n", kfunc.name);
> return -EINVAL;

When offset is non-zero, module_kallsyms_lookup_name(kfunc.name) searches
all loaded modules and returns the first match. How does this handle the
case where multiple modules register kfuncs with the same name?

In the original discussion thread from January 2026, Alexei Starovoitov
asked: "but what about kfunc in module A with the same name as kfunc in
module B?" You acknowledged this concern and indicated it was in your plan
to address. However, the current implementation appears to rely on module
load order when multiple modules have identically-named kfuncs.

Reference: https://lore.kernel.org/all/CAADnVQLVQW-Mb_d+zT+aSpPOZ042erPVcSHVBx9PMGET+a754Q@xxxxxxxxxxxxxx/

Is there a mechanism to ensure the correct module's kfunc is selected when
names collide across different modules?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/25150033548