-
Notifications
You must be signed in to change notification settings - Fork 0
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
Custom labels 2 #4
Conversation
This is necessary in some cases when we need the verifier to _not_ be able to predict the bounds of a variable, which can cause an explosion in the amount of state it needs to consider and prevent verification in under 1M instructions. See the comment for fuller details. This also requires setting the Clang target to `bpf` and passing the arm64/x86 defines manually (rather than relying on `-target` to set them), because otherwise the inline eBPF assembly doesn't work.
This commit is dead code until the user-mode code adds to cause it to be invoked. It expects to be passed a `GoCustomLabelsOffset` object in the `go_procs` map, which controls how it finds the custom labels map for a given PID.
If the `CollectCustomLabels` config flag is turned on, this parses Go binaries to determine their version number, then uses a hardcoded map of offsets by version to populate the `go_procs` map and instruct the unwinder to collect custom labels. In the future, we can automate updating this map, and also fall back to finding the labels via disassembly when a given version doesn't have them available. Those features are not yet present in this commit, however.
Which kernels does this verify on, and how many instructions is it? |
It's still failing on 4.19 and 5.4 which I am investigating now. |
This now verifies on all tested kernels except 4.19.x. Total instructions: 28892 |
So the issue is that 4.19 has a 4k instruction count limit right? I think it's fine to ignore 4.19. |
// We need to write this in assembly because the verifier doesn't understand | ||
// that val_len has already been bounds-checked above, apparently | ||
// because clang has spilled it to the stack rather than | ||
// keeping it in a register. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious if you tried putting the "register" keyword on val_len?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't try, but I looked into it and apparently modern compilers simply ignore the register keyword: https://stackoverflow.com/questions/10675072/is-the-register-keyword-still-used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Attempt 2 at custom labels PR.
This is broken up into individual PRs which should hopefully be independently digestible