-
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
Tracing programs cannot be attached to non-unique kernel symbols #894
Comments
Can both 28303 and 62945 be attached to? Why is |
I assume one should be weak, but doesn't look like we can rely on this being set correctly. Even if it's fixed on master, older kernel/pahole versions will have it wrong. |
findTargetInKernel()
must be able to resolve multiple candidates
As it turns out, trying to attach Tracing programs to kernel symbols with overlapping names is currently subtly broken in Linux up until at least 6.1. Here's what I found:
In this kernel:
When loading a program from section
When the kernel receives the program, it:
Finally, when attaching the program, the kernel takes the Func.Name of the given btf_id and looks up any kernel symbol using This means:
As such, we'll keep rejecting program loads for ambiguous attach targets. PR coming to make the error a bit more helpful. |
See cilium#894 for more context. Explicitly refuse loading programs with multiple AttachTo candidates. BTF needs to carry more information to allow disambiguating between them. The kernel API likely needs to be extended to allow specifying which candidate to pick. Signed-off-by: Timo Beckers <[email protected]>
See cilium#894 for more context. Explicitly refuse loading programs with multiple AttachTo candidates. BTF needs to carry more information to allow disambiguating between them. The kernel API likely needs to be extended to allow specifying which candidate to pick. Signed-off-by: Timo Beckers <[email protected]>
See #894 for more context. Explicitly refuse loading programs with multiple AttachTo candidates. BTF needs to carry more information to allow disambiguating between them. The kernel API likely needs to be extended to allow specifying which candidate to pick. Signed-off-by: Timo Beckers <[email protected]>
Describe the bug
While hacking on #890, I decided to try and attach a fentry prog to all of my machine's symbols. Many of them fail with:
attach Tracing/TraceFEntry: find target for fentry update_persistent_clock64 in vmlinux: type update_persistent_clock64: multiple candidates for *btf.Func
update_persistent_clock64
is a weak vmlinux symbol that has an arch-specific implementation:https://elixir.bootlin.com/linux/v6.1.1/source/kernel/time/ntp.c#L568
https://elixir.bootlin.com/linux/v6.1.1/source/arch/x86/kernel/rtc.c#L103
The argument in the weak symbol is named
now64
, the arch-specific one is callednow
.Expected behavior
The library should either go with the first candidate, or additionally verify binary compatibility between all candidates' function signatures.
Or, we might be stuck between a rock and a hard place if the kernel expects the function's specific BTF id to be given. Perhaps we may need to try loading a prog pointing at each candidate until one is accepted.
Looks similar to #723 and #466.
The text was updated successfully, but these errors were encountered: