decl_tag_kfuncs was implemented in pahole v1.27 (dwarves commit 72e88f29c6f7 [1]). However, ebb79e96f1ea ("kbuild: bpf: Tell pahole to DECL_TAG kfuncs") appended it to the list of --btf_features flags already gated on pahole >= 1.26, making it silently inactive on any pahole v1.26 build. Without decl_tag_kfuncs, pahole does not emit DECL_TAG BTF entries for __bpf_kfunc-annotated functions. resolve_btfids then skips process_kfunc_with_implicit_args(), so KF_IMPLICIT_ARGS kfuncs keep their full prototype (including the implicit aux parameter) in vmlinux BTF. BPF programs loading such kfuncs as weak ksyms fail with: libbpf: extern (func ksym) 'scx_bpf_create_dsq': func_proto [N] incompatible with vmlinux [M] Fix by splitting decl_tag_kfuncs into its own >= 127 line in Makefile.btf. Add a PAHOLE_HAS_DECL_TAG_KFUNCS Kconfig symbol so build rules can gate on this feature explicitly. Update Documentation/process/changes.rst to reflect the corrected minimum pahole version for KF_IMPLICIT_ARGS support. [1] https://github.com/acmel/dwarves/commit/72e88f29c6f7e14201756e65bd66157427a61aaf Fixes: ebb79e96f1ea ("kbuild: bpf: Tell pahole to DECL_TAG kfuncs") Reported-by: Ihor Solodrai Closes: https://lore.kernel.org/bpf/e0ca748d-3204-4160-b37d-0f76cbac8c6c@linux.dev/ Signed-off-by: zhidao su --- Documentation/process/changes.rst | 4 ++-- lib/Kconfig.debug | 10 ++++++++++ scripts/Makefile.btf | 6 +++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Documentation/process/changes.rst b/Documentation/process/changes.rst index 02068d72a101..bfe98e38c9c0 100644 --- a/Documentation/process/changes.rst +++ b/Documentation/process/changes.rst @@ -38,7 +38,7 @@ bash 4.2 bash --version binutils 2.30 ld -v flex 2.5.35 flex --version bison 2.0 bison --version -pahole 1.26 pahole --version +pahole 1.27 pahole --version util-linux 2.10o mount --version kmod 13 depmod -V e2fsprogs 1.41.4 e2fsck -V @@ -145,7 +145,7 @@ Since Linux 5.2, if CONFIG_DEBUG_INFO_BTF is selected, the build system generates BTF (BPF Type Format) from DWARF in vmlinux, a bit later from kernel modules as well. This requires pahole v1.22 or later. -Since Linux 7.0, kfuncs annotated with KF_IMPLICIT_ARGS require pahole v1.26 +Since Linux 7.0, kfuncs annotated with KF_IMPLICIT_ARGS require pahole v1.27 or later. Without it, such kfuncs will have incorrect BTF prototypes in vmlinux, causing BPF programs to fail to load with a "func_proto incompatible with vmlinux" error. Many sched_ext kfuncs are affected. diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 93f356d2b3d9..38ef8b6ce98d 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -425,6 +425,16 @@ config PAHOLE_HAS_LANG_EXCLUDE otherwise it would emit malformed kernel and module binaries when using DEBUG_INFO_BTF_MODULES. +config PAHOLE_HAS_DECL_TAG_KFUNCS + def_bool PAHOLE_VERSION >= 127 + help + Support for the decl_tag_kfuncs BTF feature, which is required for + kfuncs annotated with KF_IMPLICIT_ARGS to receive correct BTF + prototypes. Without it, such kfuncs retain their full prototype + (including the implicit aux parameter) in vmlinux BTF, causing BPF + programs to fail to load with a "func_proto incompatible" error. + Implemented in pahole v1.27 (commit 72e88f29c). + config DEBUG_INFO_BTF_MODULES bool "Generate BTF type information for kernel modules" default y diff --git a/scripts/Makefile.btf b/scripts/Makefile.btf index 562a04b40e06..c804643c5040 100644 --- a/scripts/Makefile.btf +++ b/scripts/Makefile.btf @@ -14,7 +14,11 @@ pahole-flags-$(call test-ge, $(pahole-ver), 125) += --skip_encoding_btf_inconsis else # Switch to using --btf_features for v1.26 and later. -pahole-flags-$(call test-ge, $(pahole-ver), 126) = -j$(JOBS) --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func,decl_tag_kfuncs +pahole-flags-$(call test-ge, $(pahole-ver), 126) = -j$(JOBS) --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func + +# decl_tag_kfuncs was implemented in pahole v1.27 (commit 72e88f29c). +# It was incorrectly gated on >= 126 by ebb79e96f1ea. +pahole-flags-$(call test-ge, $(pahole-ver), 127) += --btf_features=decl_tag_kfuncs pahole-flags-$(call test-ge, $(pahole-ver), 130) += --btf_features=attributes -- 2.43.0