You are not logged in.

#1 2024-07-24 08:30:24

altoid
Member
From: Germany
Registered: 2019-09-19
Posts: 4

[Solved] Can't compile kernel due to missing BTF section.

Hello,

I am trying to compile my own kernel, following these steps:

https://wiki.archlinux.org/title/Kernel … ild_system

but even then, I can not compile the kernel.

First of all, "make prepare" is missing from the PKGBUILD, which I manually appended after make menuconfig.

In menuconfig, I simply set the timer frequency to 1000HZ, enabled full dynamic preemption, as well as all of the few security related options merged from grsecurity/PaX:

Fully randomize structure layout.
Initialize structures on the stack to zero.
Enable heap memory zeroing on allocation by default.
Enable heap memory zeroing on free by default.
Poison kernel stack before returning from syscalls.
Enable register zeroing on function exit.
Check integrity of linked list manipulation.

And under GCC plugins:

Generate some entropy during boot and runtime.

This always results in the following compilation error:

libbpf: failed to find '.BTF' ELF section in vmlinux
FAILED: load BTF from vmlinux: No data available

This is while using the kernel config pulled in from the repository, only setting my CPU family (Core 2 / newer Xeon) and the config changes mentioned above.

Is there anything I am missing?

I am compiling with latest pahole and base-devel, running the latest linux kernel (although in integrity lockdown mode) and made sure pacman had no updates to complain about.

This seems to have affected many other people, from a quick Google search, but they insist it is now fixed with the latest pahole version.

Any idea why this still happens?

Thank you,
altoid

Last edited by altoid (2024-07-28 09:34:09)

Offline

#2 2024-07-28 01:54:46

altoid
Member
From: Germany
Registered: 2019-09-19
Posts: 4

Re: [Solved] Can't compile kernel due to missing BTF section.

Quick update:

I was able to compile and boot a minimal kernel using

make localmodconfig

and this time gcc also generated BTF sections for all modules, this is after updating gcc to the latest git version.

I did not have the time to enable the hardening options, but I will see if that breaks anything.

If not, I will just continue using

make localmodconfig

and use menuconfig to enable the few extra modules that a mkinitcpio hook complained about.

Thanks.

Offline

#3 2024-07-28 08:44:27

altoid
Member
From: Germany
Registered: 2019-09-19
Posts: 4

Re: [Solved] Can't compile kernel due to missing BTF section.

Okay, I figured out the culprit:

DEBUG_INFO_BTF

can't be enabled if you enable structure randomization, thus leading up to this error.

Since I don't really need any of the BTF / BPF stuff anyway, I will just disable it completely:

CONFIG_BPF=n
CONFIG_BPF_SYSCALL=n
CONFIG_BPF_JIT=n
CONFIG_BPF_JIT_ALWAYS_ON=n
CONFIG_BPF_JIT_DEFAULT_ON=n
CONFIG_PAHOLE_HAS_BTF_TAG=n
CONFIG_DEBUG_INFO_BTF=n
CONFIG_DEBUG_INFO_BTF_MODULES=n

Hope this helps someone compiling their own kernel with the RANDSTRUCT plugin enabled.

Last edited by altoid (2024-07-28 09:33:53)

Offline

Board footer

Powered by FluxBB