Skip to content
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

x86 musl platforms don't like mmap()/ptrace injection #548

Open
luckycat889 opened this issue Sep 17, 2024 · 0 comments
Open

x86 musl platforms don't like mmap()/ptrace injection #548

luckycat889 opened this issue Sep 17, 2024 · 0 comments

Comments

@luckycat889
Copy link

Hello,
I have been experimenting with uncommon platforms, and I run into a problem with x86 musl platforms at injection time. There is a neat trick performed during ptrace by directing execution to mmap(), however, on x86/musl the mmap never returns, or returns bad. If I force it to use the text segment swap, it works reliably. I'd love to find out why this happens, and I might experiment, but in the meantime I just log the issue here:
If I run the following patch, it all works

`diff --git a/src/linux/frida-helper-backend.vala b/src/linux/frida-helper-backend.vala
index 9da2152..cca135c 100644
--- a/src/linux/frida-helper-backend.vala
+++ b/src/linux/frida-helper-backend.vala
@@ -1083,7 +1083,7 @@ namespace Frida {
uint64 remote_munmap = 0;
ProcMapsEntry? remote_libc = ProcMapsEntry.find_by_path (pid, local_libc.path);
bool same_libc = remote_libc != null && remote_libc.identity == local_libc.identity;

  •                   if (same_libc) {
    
  •                   if (false) {
                              remote_mmap = remote_libc.base_address + mmap_offset;
                              remote_munmap = remote_libc.base_address + munmap_offset;
                      }
    

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant