clinuxlinux-kernelebpflibbpf

eBPF program fails with "libbpf: failed to find valid kernel BTF" after upgrading to kernel 6.8.0-48-generic


I'm learning how to use eBPF in Linux environments via the libbpf library. I have a simple eBPF program that compiles and runs successfully on kernel version 5.15.0-125-generic, but after upgrading my kernel to 6.8.0-48-generic, the program fails to run with the following error messages:

libbpf: failed to find valid kernel BTF
libbpf: Error loading vmlinux BTF: -3
libbpf: failed to load object 'execve.bpf.o'
Failed to load eBPF object

Environment:

Project Details:

I'm working on a small eBPF project that tracks execve() system calls. The code is available on my GitHub repository:

https://github.com/KnightChaser/hello-eBPF/tree/main/application/00_execve_tracking

The project consists of:

Steps Taken:

  1. Generated vmlinux.h:

    sudo apt update
    sudo apt install linux-headers-$(uname -r) clang llvm libbpf-dev gcc-multilib make
    bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h
    
  2. Built the program:

    make
    
  3. Ran the program:

    sudo ./execve_user
    

    This results in the error messages mentioned above.

Troubleshooting Attempts:

Additional Information:

Question:

Why is my eBPF program failing with libbpf: failed to find valid kernel BTF after upgrading to kernel 6.8.0-48-generic, and how can I resolve this issue?

Any insights into why libbpf is unable to find valid kernel BTF on the new kernel and what steps I can take to fix this problem would be greatly appreciated.


What I've Tried So Far:

Any help or guidance on how to resolve this issue would be greatly appreciated!

(Note: Currently, this issue is ongoing on the GitHub issue in https://github.com/libbpf/libbpf/issues/863, which I wrote yesterday. Since the libbpf repository GitHub is not so active, I upload my question after refining sentences again to StackOverflow, where related developers might be reachable.)


Solution

  • The problem was occurred due to an old version of libbpf, which some features go incomaptible with upgraded kernel(kernel 6.x.x.). Since upgrading the libbpf package to 1.5.0 and reconfigure library configurations for my Linux machine, I could see that such problems don't arise again.

    You can find more details in https://github.com/libbpf/libbpf/issues/863.