Repository navigation
Fix code swap region permissions - #1134
Merged
Merged
Conversation
Due to how APEXes are bind-mounted.
As they may not be writable, and unlike regular regions, ptrace() won't help us in case of a missing writable bit.
Member
|
Thanks a lot! 🙌
|
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
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.
I/O error began appearing after installing the latest ART update (version 351110190) on my Pixel 6 Android 12. The bootstrapper code was written into a non-writable region, causing the
ptracepokedata call to fail with an I/O error. My understanding of Frida internals is limited, so the breakdown below might be incomplete or off-targetAt the start of the injection flow a comparison occurs between the remote and local libc here. Libc is delivered as part of the runtime APEX; since apexd can mount the APEX packages multiple times—each with a separate loop device—both system_server and Frida obtain their APEX mount through separate activation or bind-mount operations. This results in different loop devices (with distinct minor numbers), making the identity comparison (based on dev major+minor and inode) between local and remote libc fail.
As a consequence, the injection flow falls back to the code swap route here, where Frida tries to load the bootstrapper into an RX-mapped region. Prior to ART version 351110190, this route worked because Frida correctly matched the boot image segment loaded as RWX. After the update, the runtime behavior changed: the RWX region no longer exists, and the enumeration now selects the memfd:jit-zygote-cache region, which is not writable. Consequently, the
ptracecall here fails with an I/O error.This PR refines both the libc comparison and the permissions matching for the code swap region.
Debugged on: