-
Notifications
You must be signed in to change notification settings - Fork 690
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
Can't load CO-RE eBPF code that accesses enum values #1348
Comments
I was able to repo the issue and did some digging, found the following: When I dump the program before CO-RE relocation logic the program looks like:
But afterwards, it looks like this:
Which in my case lead to a The fixups are:
Tracing this, its this piece of code that is responsible Lines 43 to 48 in ff37506
|
Cool! thanks |
Describe the bug
When using
bpf_core_enum_value_exists
on an enum and within itbpf_core_enum_value
on the same enum value, when the value doesn't exist, the output go binary fails to load.When loading the compiled object file with libbpf (bpftool) it loads successfully.
The code is in the attached file, but the problem can be seen in:
where the kernel enum
cgroup_subsys_id
is queried for typecpuset_cgrp_id_lublub
(which doesn't really exist). The expected behaviour, which happens when loading the object withbpftool
, is that the program passes the verifier's checks because the code inside theif
shouldn't be evaluated.The second value in the enum in the attached code,
cpuset_cgrp_id
, indeed exists, so using it instead of the fictitious valuecpuset_cgrp_id_lublub
works with both cilium and libbpf.How to reproduce
The code:
enum-error.tar.gz
build with
make
and run with./main
.Loading with bpftool (succeeds):
bpftool prog load bpf_bpf.o /sys/fs/bpf/bpf_bpf rm /sys/fs/bpf/bpf_bpf # to remove
Version information
github.com/cilium/ebpf v0.12.3
go version go1.21.5 linux/amd64
Linux 5.15.0
The text was updated successfully, but these errors were encountered: