Re: [PATCH v3] kbuild: rpm-pkg: Preserve .BTF section in kernel modules during debuginfo stripping

Yafang Shao <[email protected]>
Newsgroups dev.linux.lists.sashiko-reviews,org.kernel.vger.bpf,org.kernel.vger.linux-kbuild
Message-ID <CALOAHbB0w+eK6Bxd+Lsb51Z5QVtnNv=4Srbb7KWcm6zAxgkTwA@mail.gmail.com>
On Sun, Jul 26, 2026 at 11:03 AM <[email protected]> wrote:
>
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] The patch preserves the `.BTF` section during debuginfo stripping but fails to also preserve the `.BTF.base` section, causing module BTF validation to fail.
> --
>
> --- Patch [1]: [PATCH v3] kbuild: rpm-pkg: Preserve .BTF section in kernel modules during debuginfo stripping ---
> commit cd09ed46074d0224c00066939452278fca769e51
> Author: Yafang Shao <[email protected]>
> kbuild: rpm-pkg: Preserve .BTF section in kernel modules during debuginfo stripping
>
> This commit updates the RPM build scripts to pass --keep-section .BTF to
> find-debuginfo.sh. This prevents eu-strip from dropping the .BTF section
> from kernel modules during debuginfo extraction.
>
> > diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
> > index c732415662ef2..1032f337a71cd 100644
> > --- a/scripts/package/kernel.spec
> > +++ b/scripts/package/kernel.spec
>
> [ ... ]
>
> > @@ -67,7 +67,17 @@ This package provides debug information for the kernel image and modules from th
> >  %undefine _unique_debug_srcs
> >  %undefine _debugsource_packages
> >  %undefine _debuginfo_subpackages
> > +
> > +# Preserve .BTF section in kernel modules during debuginfo stripping
> > +# find-debuginfo.sh (from debugedit) uses eu-strip which removes
> > +# non-allocated ELF sections like .BTF by default.
> > +%global with_keep_section %(%{__find_debuginfo} --help 2>&1 | grep -c keep-section)
> > +%if %{with_keep_section}
> > +%global _find_debuginfo_opts -r --keep-section .BTF
>
> [Severity: High]
> Does this also need to preserve the .BTF.base section?
>
> When modules are built with BTF distillation (which is standard on recent
> kernels), both .BTF and .BTF.base sections are generated. If .BTF.base is
> stripped, btf_parse_module() in kernel/bpf/btf.c falls back to using the
> vmlinux_btf.
>
> This fallback causes type ID mismatches during btf_check_all_metas() because
> the module's .BTF was built with distilled IDs, ultimately resulting in the
> module's BTF being rejected entirely.
>
> Could we add --keep-section .BTF.base here as well to ensure distilled BTF
> validation succeeds?

You're right. .BTF.base should also be preserved. I'll update it.

-- 
Regards
Yafang
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.