Skip to content

Commit c446fda

Browse files
fomichevAlexei Starovoitov
authored andcommitted
bpf: fix register_btf_kfunc_id_set for !CONFIG_DEBUG_INFO_BTF
Commit dee872e ("bpf: Populate kfunc BTF ID sets in struct btf") breaks loading of some modules when CONFIG_DEBUG_INFO_BTF is not set. register_btf_kfunc_id_set returns -ENOENT to the callers when there is no module btf. Let's return 0 (success) instead to let those modules work in !CONFIG_DEBUG_INFO_BTF cases. Acked-by: Kumar Kartikeya Dwivedi <[email protected]> Fixes: dee872e ("bpf: Populate kfunc BTF ID sets in struct btf") Signed-off-by: Stanislav Fomichev <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent fc1ca95 commit c446fda

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

kernel/bpf/btf.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6740,8 +6740,19 @@ int register_btf_kfunc_id_set(enum bpf_prog_type prog_type,
67406740
int ret;
67416741

67426742
btf = btf_get_module_btf(kset->owner);
6743-
if (IS_ERR_OR_NULL(btf))
6744-
return btf ? PTR_ERR(btf) : -ENOENT;
6743+
if (!btf) {
6744+
if (!kset->owner && IS_ENABLED(CONFIG_DEBUG_INFO_BTF)) {
6745+
pr_err("missing vmlinux BTF, cannot register kfuncs\n");
6746+
return -ENOENT;
6747+
}
6748+
if (kset->owner && IS_ENABLED(CONFIG_DEBUG_INFO_BTF_MODULES)) {
6749+
pr_err("missing module BTF, cannot register kfuncs\n");
6750+
return -ENOENT;
6751+
}
6752+
return 0;
6753+
}
6754+
if (IS_ERR(btf))
6755+
return PTR_ERR(btf);
67456756

67466757
hook = bpf_prog_type_to_kfunc_hook(prog_type);
67476758
ret = btf_populate_kfunc_set(btf, hook, kset);

0 commit comments

Comments
 (0)