-
Notifications
You must be signed in to change notification settings - Fork 697
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: CO-RE: types from (other) kmod BTF are not available #1511
Comments
I wouldn't consider this a bug. If you are using types from a kmod, but not attaching to a function within that kmod, how should it know where the types come from? There are too many kmods to go searching. IMHO specifying |
I am not saying that this is strictly a bug, I would say that this is more of an observation. But I believe that this could be handled better in I am thinking of adding a new field in I will check those further and I will create a PR with proposed any changes. |
I asked @tpapagian to create an issue because this is real-world proof that people want access to other kmod BTF in CO-RE, something we went around the block a few times when doing the initial implementation. Agree that this isn't strictly a bug, but the lib should make this easier somehow. |
cilium/ebpf
can detect if a symbol is part of a kmod and load it automatically. This is done here by checking the function name that the user wants to attach in/proc/kallsyms
.This does not work as expected when we want to relocate a symbol that is part of a kmod but the attach functions is not.
As an example, in my system,
overlay
is build as a module, and its BTF resides in/sys/kernel/btf/overlay
. The following program attaches toovl_inode_lower
, a function fromoverlay
kmod.cilium/ebpf
will check that and loadoverlay
's BTF. This will also be used to evaluatebpf_core_type_exists(struct ovl_entry)
, the verifier will remove the infinite loop, and the program will load as expected.On the other hand, the following program attaches to a function that is not part of any kmod. Thus
cilium/ebpf
will not loadoverlay
's BTF.bpf_core_type_exists(struct ovl_entry)
will evaluate to 0, the infinite loop will not be removed by the verifier and the program fails to load (even the kmod BTF exists).These are tested with these programs with cilium/ebpf v0.15.0 and the output is:
A way to overcome this limitation is to manually load the overlay BTF with a function similar to this one and provide its output to ProgramOptions.KernelTypes. This makes the second program to load as well.
The text was updated successfully, but these errors were encountered: