Skip to content

Prevent stripping of BTF data from kernel modules #13813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: 3.0-dev
Choose a base branch
from

Conversation

rlmenge
Copy link
Contributor

@rlmenge rlmenge commented May 16, 2025

Merge Checklist

All boxes should be checked before merging the PR (just tick any boxes which don't apply to this PR)

  • The toolchain has been rebuilt successfully (or no changes were made to it)
  • The toolchain/worker package manifests are up-to-date
  • Any updated packages successfully build (or no packages were changed)
  • Packages depending on static components modified in this PR (Golang, *-static subpackages, etc.) have had their Release tag incremented.
  • Package tests (%check section) have been verified with RUN_CHECK=y for existing SPEC files, or added to new SPEC files
  • All package sources are available
  • cgmanifest files are up-to-date and sorted (./cgmanifest.json, ./toolkit/scripts/toolchain/cgmanifest.json, .github/workflows/cgmanifest.json)
  • LICENSE-MAP files are up-to-date (./LICENSES-AND-NOTICES/SPECS/data/licenses.json, ./LICENSES-AND-NOTICES/SPECS/LICENSES-MAP.md, ./LICENSES-AND-NOTICES/SPECS/LICENSE-EXCEPTIONS.PHOTON)
  • All source files have up-to-date hashes in the *.signatures.json files
  • sudo make go-tidy-all and sudo make go-test-coverage pass
  • Documentation has been updated to match any changes to the build system
  • Ready to merge

Summary

This PR updates the kernel spec file to ensure that the BTF (BPF Type Format) section is preserved in all built kernel modules. Specifically, it introduces the following change:

%define _find_debuginfo_opts --keep-section '.BTF'

This directive prevents the find-debuginfo.sh script (invoked during RPM build and packaged in debugedit) from removing the .BTF ELF section when stripping debug information from kernel modules.

_find_debuginfo_opts is an RPM macro for additional options passed to find-debuginfo.sh. (link)
--keep-section is an argument to find-debuginfo.sh as defined in the script

.BTF data is expected as the kernel config sets CONFIG_DEBUG_INFO_BTF_MODULES (kconfig) and thus each kernel module should contain a .BTF section.

Without this change, module BTF data is not exposed in /sys/kernel/btf/, preventing eBPF tools from tracing module symbols and types.

$ ls /sys/kernel/btf/
vmlinux
Change Log
  • Prevent stripping of BTF data from kernel modules
Does this affect the toolchain?

YES

Associated issues
Test Methodology
*** Smoke Testing Kernel 6.6.90.1-2.azl3 (est. < 1 min) ***
OS Version: NAME="Microsoft Azure Linux"
VERSION="3.0.20250521"
ID=azurelinux
PASS: Kernel version matches the running kernel version.
PASS: eth0 interface is up.
PASS: iptables service is running.
Boot times:
Startup finished in 1.810s (kernel) + 1.460s (initrd) + 6.744s (userspace) = 10.014s 
graphical.target reached after 6.372s in userspace.
Kernel size:
-rw------- 1 root root 15052800 May 27 18:21 /boot/vmlinuz-6.6.90.1-2.azl3
34704	/lib/modules/6.6.90.1-2.azl3
kernel memory:
MemTotal:       65853168 kB
MemFree:        65411380 kB
MemAvailable:   65047792 kB
Total memory:
               total        used        free      shared  buff/cache   available
Mem:           64309         786       63878           0         130       63523
Swap:              0           0           0

ARM64

*** Smoke Testing Kernel 6.6.90.1-2.azl3 (est. < 1 min) ***
OS Version: NAME="Microsoft Azure Linux"
VERSION="3.0.20250521"
ID=azurelinux
PASS: Kernel version matches the running kernel version.
PASS: eth0 interface is up.
PASS: iptables service is running.
Boot times:
Startup finished in 968ms (kernel) + 1.159s (initrd) + 5.311s (userspace) = 7.440s 
graphical.target reached after 5.043s in userspace.
Kernel size:
-rw------- 1 root root 48720384 May 27 18:53 /boot/vmlinuz-6.6.90.1-2.azl3
56704	/lib/modules/6.6.90.1-2.azl3
kernel memory:
MemTotal:       65719176 kB
MemFree:        65205076 kB
MemAvailable:   64848428 kB
Total memory:
               total        used        free      shared  buff/cache   available
Mem:           64178         850       63676           0         142       63328
Swap:              0           0           0

@microsoft-github-policy-service microsoft-github-policy-service bot added Packaging specs-extended PR to fix SPECS-EXTENDED 3.0-dev PRs Destined for AzureLinux 3.0 labels May 16, 2025
@rlmenge rlmenge force-pushed the rlmenge/kernel/keep-btf branch from c53a170 to d2b26e2 Compare May 16, 2025 06:00
@rlmenge rlmenge force-pushed the rlmenge/kernel/keep-btf branch from d2b26e2 to 8c758ed Compare May 27, 2025 17:55
@rlmenge rlmenge marked this pull request as ready for review May 28, 2025 21:33
@rlmenge rlmenge requested review from a team as code owners May 28, 2025 21:33
@rlmenge rlmenge requested a review from Copilot May 28, 2025 21:34
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR prevents the stripping of BTF data from kernel modules during RPM builds by introducing the directive to keep the '.BTF' ELF section and bumps the release numbers across various kernel-related spec files to trigger rebuilds.

  • Adds "%define _find_debuginfo_opts --keep-section '.BTF'" to the appropriate kernel spec files
  • Updates release numbers for kernel, kernel-uki, kernel-headers, kernel-64k, and several signed modules to reflect the new build revision

Reviewed Changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated no comments.

Show a summary per file
File Description
SPECS/kernel/kernel.spec Adds the BTF directive and bumps Release to 2%{?dist}
SPECS/kernel/kernel-uki.spec Bumps Release to 2%{?dist}
SPECS/kernel-headers/kernel-headers.spec Bumps Release to 2%{?dist}
SPECS/kernel-64k/kernel-64k.spec Adds the BTF directive and bumps Release to 2%{?dist}
SPECS/isert/isert.spec Bumps last-known-kernel and Release to 2%{?dist}
SPECS/iser/iser.spec Bumps last-known-kernel and Release to 2%{?dist}
SPECS/fwctl/fwctl.spec Bumps last-known-kernel and Release to 2%{?dist}
SPECS-SIGNED/xpmem-modules-signed/xpmem-modules-signed.spec Bumps Release to 20%{?dist}
SPECS-SIGNED/srp-signed/srp-signed.spec Bumps Release to 20%{?dist}
SPECS-SIGNED/mlnx-ofa_kernel-modules-signed/mlnx-ofa_kernel-modules-signed.spec Bumps Release to 20%{?dist}
SPECS-SIGNED/mlnx-nfsrdma-signed/mlnx-nfsrdma-signed.spec Bumps Release to 20%{?dist}
SPECS-SIGNED/mft_kernel-signed/mft_kernel-signed.spec Bumps Release to 20%{?dist}
SPECS-SIGNED/knem-modules-signed/knem-modules-signed.spec Bumps Release to 20%{?dist}
SPECS-SIGNED/kernel-uki-signed/kernel-uki-signed.spec Bumps Release to 2%{?dist}
SPECS-SIGNED/kernel-signed/kernel-signed.spec Bumps Release to 2%{?dist}
SPECS-SIGNED/kernel-64k-signed/kernel-64k-signed.spec Bumps Release to 2%{?dist}
SPECS-SIGNED/isert-signed/isert-signed.spec Bumps Release to 20%{?dist}
SPECS-SIGNED/iser-signed/iser-signed.spec Bumps Release to 20%{?dist}
SPECS-SIGNED/fwctl-signed/fwctl-signed.spec Bumps Release to 20%{?dist}
SPECS-EXTENDED/kernel-ipe/kernel-ipe.spec Adds the BTF directive and bumps Release to 2%{?dist}

@rlmenge rlmenge force-pushed the rlmenge/kernel/keep-btf branch from 6037a2e to dd5fbcc Compare June 9, 2025 16:53
rlmenge added 5 commits June 9, 2025 17:28
Add `%define _find_debuginfo_opts --keep-section '.BTF'` to the kernel spec
to ensure that the BTF section is preserved in kernel modules. This allows
modules to retain BTF info required for eBPF and kernel introspection tools.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.0-dev PRs Destined for AzureLinux 3.0 Packaging specs-extended PR to fix SPECS-EXTENDED
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant