-
Notifications
You must be signed in to change notification settings - Fork 694
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,info: Fix bad instruction offset when parsing infos from kernel #1169
Conversation
So how come this wasn't caught by tests? We don't have any non-zero offsets? |
Yea, both of the test that could have caught this have very small programs where this doesn't surface:
Do we want a regression test for this? |
That would be great! |
32db323
to
b906189
Compare
I changed the |
@dylandreimerink super, thanks! I've pushed a fixup:
Let me know what you think! |
Yes, all seem sensible! If we can get CI to agree that is. Shall I squash both commits? |
When BTF ext info is encoded in ELF the instruction offsets are in bytes, but when you pass them to the kernel they must be instruction indices. Therefore we divide the offset by the instruction size in the parsing logic for ELF. This was missed during the initial implementation of reading back BTF ext info from the kernel. This would cause an error when loading back ext info which was not a multiple of the instruction size or a bad instruction offset if it was. Fix this by making LoadLineInfos and LoadFuncInfos work on the kernel format which contains instruction offsets while the ELF parser uses bytes instead. Signed-off-by: Dylan Reimerink <dylan.reimerink@isovalent.com> Co-developed-by: Lorenz Bauer <lmb@isovalent.com>
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.
Thanks, already done. Also adjusted the commit msg.
When BTF ext info is encoded in ELF the instruction offsets are in bytes, but when you pass them to the kernel they must be instruction indecies. Therefor we devide the offset by the instruction size in the parsing logic for ELF.
This was missed during the initial implementation of reading back BTF ext info from the kernel. This would cause an error when loading back ext info which was not a multiple of the instruction size or a bad instruction offset if it was.
This PR adds an argument to the parsing logic to specify where the ext info is being read from. It also adds
LoadKernelLineInfos
andLoadKernelFuncInfos
to load the ext info from the kernel, using the correct direction enum internaly. These are now used by theinfo
package.Fixes: #1168