-
Notifications
You must be signed in to change notification settings - Fork 699
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
btf: libbpf doesn't update instructions when deduplicating types #739
Comments
lmb
added a commit
to ti-mo/ebpf
that referenced
this issue
Jul 19, 2022
Trying to load the ELF gives the following error: elf_reader_test.go:665: Error during loading: program trace_netif_receive_skb: apply CO-RE relocations: apply fixup target_type_id=67->16253: invalid immediate 73, expected 67 (fixup: target_type_id=67->16253) After some cursory digging this doesn't seem to be a bug in the library but maybe one in either pahole or clang. See cilium#739
lmb
added a commit
to ti-mo/ebpf
that referenced
this issue
Jul 20, 2022
Trying to load the ELF gives the following error: elf_reader_test.go:665: Error during loading: program trace_netif_receive_skb: apply CO-RE relocations: apply fixup target_type_id=67->16253: invalid immediate 73, expected 67 (fixup: target_type_id=67->16253) After some cursory digging this doesn't seem to be a bug in the library but maybe one in either pahole or clang. See cilium#739
ti-mo
pushed a commit
that referenced
this issue
Jul 20, 2022
Trying to load the ELF gives the following error: elf_reader_test.go:665: Error during loading: program trace_netif_receive_skb: apply CO-RE relocations: apply fixup target_type_id=67->16253: invalid immediate 73, expected 67 (fixup: target_type_id=67->16253) After some cursory digging this doesn't seem to be a bug in the library but maybe one in either pahole or clang. See #739
I think this is the same issue as https://lore.kernel.org/bpf/CAN+4W8i=7Wv2VwvWZGhX_mc8E7EST10X_Z5XGBmq=WckusG_fw@mail.gmail.com/ clang generates BTF with duplicates in it, libbpf deduplicates the BTF but doesn't update the instruction immediate. |
lmb
changed the title
btf: pahole or clang maybe generates invalid CO-RE relocations
btf: libbpf doesn't update instructions when deduplicating types
Jan 19, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
target_type_id=67->16253
means we expect to find type id67
inInstruction.Constant
. Instead we findinvalid immediate 73
.We can dump the BTF to figure out what types this refers to:
We think the instruction should reference a
struct bpf_insn
but the compiler encodedstruct btf_enum
. After adding some advanced printf debugging:From the last line we know that applying the fixup at offset 302 fails. The BTF relocation
(from wire)
encodes target type 67 for that offset, which bpftool agrees isstruct bpf_insn
. As soon as we write it into metadata we can see that the instruction at offset 302 disagrees, the immediate is 73. We can verify that the73
comes from the ELF, not from a bug in the library:At this point it looks like the encoded instructions and the encoded CO-RE relocations disagree. Maybe this is related to which tool we're using to do the linking? An interesting experiment would be if @ti-mo rebuilt the 5.15 selftests on his machine, and then run the unit test against that. If that changes the outcome its a tooling issue, if not it might be a bug in 5.17.
Another thing to try is running the same example via libbpf and looking at the output it generates for this particular test case.
Diff for my quick hack:
Originally posted by @lmb in #668 (comment)
The text was updated successfully, but these errors were encountered: