register_btf_kfunc_id_set() returns -EINVAL when a kfunc in the set has no valid FUNC/FUNC_PROTO pair in the BTF of the registering object, but nothing is logged: the caller (typically a module init function) propagates the error, insmod fails with -EINVAL and dmesg stays silent. The only hint is a warning from resolve_btfids at build time, which is easy to miss. This happened with bpf_testmod built by pahole 1.30: that version does not encode __int128, so the three i128 test kfuncs had no BTF func entries, their ids in the set stayed 0 and loading the module failed with -22, with nothing printed to dmesg. Log the offending kfunc id, the object that owns the BTF and the error code when the sanity check fails. Signed-off-by: Wang Yibo --- kernel/bpf/btf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 538129ed2..af07206f9 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -10128,8 +10128,12 @@ static int __register_btf_kfunc_id_set(enum btf_kfunc_hook hook, for (i = 0; i < kset->set->cnt; i++) { ret = btf_check_kfunc_protos(btf, btf_relocate_id(btf, kset->set->pairs[i].id), kset->set->pairs[i].flags); - if (ret) + if (ret) { + pr_err("register_btf_kfunc_id_set: kfunc id %u in BTF of %s failed sanity check, ret %d\n", + kset->set->pairs[i].id, + kset->owner ? kset->owner->name : "vmlinux", ret); goto err_out; + } } ret = btf_populate_kfunc_set(btf, hook, kset); -- 2.51.0