-
-
Notifications
You must be signed in to change notification settings - Fork 201
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
Massage libunwind around Frida hooks #515
Merged
Merged
Conversation
This file contains 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
mrmacete
force-pushed
the
feature/unwind-sitter
branch
2 times, most recently
from
April 8, 2024 13:45
ebce292
to
ce38fd8
Compare
mrmacete
force-pushed
the
feature/unwind-sitter
branch
from
April 11, 2024 11:56
1d661a5
to
dc7882e
Compare
oleavr
force-pushed
the
feature/unwind-sitter
branch
from
May 13, 2024 13:20
dc7882e
to
9faf9bd
Compare
Thanks! 🙌 Amazing work!! 🔥 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The problem this change intends to solve is that, currently, with code like this:
if there's any Frida hook (either via
Interceptor
or viaNativeCallback
swizzling likeObjC.implement
) anywhere in the call stack between the raise and the catch of the exception, libunwind fails to find the exception handler, leading to uncaught exceptions which wouldn't happen without instrumentation.When libunwind fails to unwind it usually means it can't resolve the unwind info, and it can happen for 2 different reasons:
_dyld_find_unwind_sections()
) but if the Frida agent is injected then dyld doesn't know about it and libunwind gives up on the first instruction pointer to any Frida agent's code in the stack (like normally happens for swizzling-like hooks)onLeave()
which belongs to a runtime-generated code thunk therefore missing its mapping to unwind infoThe solution proposed here addresses the two above problems directly, via the new
UnwindSitter
component:_dyld_find_unwind_sections
to provide the right unwind info for the "invader"UnwindCursor::setInfoBasedOnIPRegister()
to callgum_invocation_stack_translate()
on the return address to restore the original one on the stack at unwind-timeAll this can be disabled via the
"unwind-sitter:off"
frida-agent option.