-
Notifications
You must be signed in to change notification settings - Fork 426
fix(python): fix stub decoding routine #412
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
b8f926a
python stub decoding improvements
korniltsev 6a8e9fc
lint
korniltsev e4f1c2a
Merge branch 'main' into python-fix
korniltsev aa5ef11
more tests, debug dump code on failure
korniltsev b0d9b46
lint
korniltsev d1bf67c
rewrite in go
korniltsev 3eff3a8
lint
korniltsev 93e569e
legal
korniltsev 3c066cc
Merge branch 'main' into python-fix
korniltsev b4e7b57
remove debug printings
korniltsev f42edc8
decodeStub: return error, include hexdump of the code into the error
korniltsev 893a170
merge tests into decode_tet.go
korniltsev 2bd6bdd
extract regs state into a new amd package
korniltsev d0c1b8c
extract endbr64 to amd package
korniltsev 9406305
fmt
korniltsev 507bfd5
get rid of platform specific decode files
korniltsev f568cda
lint
korniltsev 576fdf4
handle index-scale insns
korniltsev 06daab6
rm printf
korniltsev 6def09d
add coredump tests
korniltsev 36bb7a0
update modulestore to include meaningfull errors
korniltsev 303cd1a
lint
korniltsev ab12dbd
Apply suggestions from code review
korniltsev 796a617
revert modulestore changes
korniltsev 4372fc3
add endbr64 comment
korniltsev 6573aef
add extra test for lea edit (32bit)
korniltsev 7a1593b
review fixes
korniltsev 6c6f8ca
add r8l-r15l regs
korniltsev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
For what its worth we've gotten pretty good mileage out of go's builtin disassembler: https://github.com/parca-dev/opentelemetry-ebpf-profiler/blob/main/interpreter/luajit/extractor_x86.go
Its shortcomings don't really manifest for simple cases.
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.
The long history is that we needed Zydis originally for the stack delta extraction filtering, and the go disassembler did not recognize all opcodes. We wanted to keep only single disassembler so Zydis was used for all other purposes as well. I think the go built in disassembler has improved since, and the stub disassembly is more constrained, this could probably an option. Especially since we use the go builtin disassembler for all arm64 side.
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.
The go x86 disassembler is definitely still broken for anything meaty but I found for simple tasks like this it works well. Personally I find avoiding cgo when possible is worth it and if I was gonna undertake any new decoder tasks I'd probably take a hard look at https://github.com/zyantific/zydis-go.
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've drafted a go version.
It's a bit slower but I think it's worth having less unsafe code in the program running as privileged root parsing untrusted user data.
I think rewriting in go should be a separate issue though. I will submit a separate change if we merge #412
Did a quick look into zydis-go and If I understand correctly - it embeds some precompiled native binaries and I'm not excited to use this for the same reasons described above to not use memory unsafe languages and lack of transparency.
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.
Although I'm happy to apply it here in this PR as well. Both go and C versions looks like almost complete rewrite (touches all the lines )
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.
@christos68k @florianl @athre0z Do you see any blockers for not using the built-in Go disassembler for amd64?
Currently we have Zydis used in
interpreter/php,interpreter/python, andtpbase(for kernel/fsbase and libc/pthread).The commit referenced would fix php. I'm available to rewrite the three others which are simpler. This would allow cross-running amd64 tests on arm64 builds, and remove the 12M
.cdrop from this repository.I believe the Go code will be more maintainable and safer. The original reason for including Zydis was the stack delta extraction code inspecting
callreturn locations to determine which stack deltas to keep and thus had requirements the Go disassembler was not able to handle. But this code is long gone, and I'd like to simplify our codebase now.Does any anyone object this? If no, I would prefer to review the Go version for this fix.
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.
SGTM