Skip to content
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

add platform prefix to kprobe symbol if missing #387

Open
monrax opened this issue Feb 27, 2025 · 1 comment
Open

add platform prefix to kprobe symbol if missing #387

monrax opened this issue Feb 27, 2025 · 1 comment
Milestone

Comments

@monrax
Copy link

monrax commented Feb 27, 2025

Cilium has a nice feature in their link package where:

If attaching to symbol fails, automatically retries with the running platform's syscall prefix (e.g. _x64) to support attaching to syscalls in a portable fashion.

It catches any file not found errors and then it uses internal.PlatformPrefix (from the internal package) to prepend the right prefix to the function symbol to then try again: https://github.com/cilium/ebpf/blob/v0.16.0/link/kprobe.go#L171C1-L176C3

I'm opening this issue here since I was using bpfman on k8s and my Kprobeprogram couldn't be loaded successfully (I couldn't figure out the error messages, until I realized the error was the symbol I was trying to attach the kprobe to was missing the __x64_ prefix -- which I wasn't really paying to much attention to since I was using link.Kprobe). However, I'm not sure if this should go in the bfpman repo instead.

I don't know much Rust myself, but I might be able to put something together for this small convenience function (although, if there's a place where we can do this in Go I can probably help better!)

@github-project-automation github-project-automation bot moved this to 🆕 New in bpfman Feb 27, 2025
@Billy99 Billy99 added this to the Q1-2025 milestone Mar 6, 2025
@Billy99
Copy link
Contributor

Billy99 commented Mar 6, 2025

There was an AYA feature that did this:
https://github.com/aya-rs/aya/blob/73a34e1571a606124c7e89ecf71ff001508643dc/aya/src/util.rs#L326
It was backed out because there was some arch specifics that needed for kprobes. Needs more discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants