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

Fix code swap region permissions #1134

Merged
merged 2 commits into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/linux/frida-helper-backend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,17 @@ namespace Frida {
uint64 remote_mmap = 0;
uint64 remote_munmap = 0;
ProcMapsEntry? remote_libc = ProcMapsEntry.find_by_path (pid, local_libc.path);
#if ANDROID
bool same_libc = false;
if (remote_libc != null) {
bool same_device = remote_libc.identity.split (":")[0] == local_libc.identity.split (":")[0];
bool same_inode = remote_libc.identity.split (" ")[1] == local_libc.identity.split (" ")[1];
bool same_path = remote_libc.path == local_libc.path;
same_libc = same_device && same_inode && same_path;
}
#else
bool same_libc = remote_libc != null && remote_libc.identity == local_libc.identity;
#endif
if (same_libc) {
remote_mmap = remote_libc.base_address + mmap_offset;
remote_munmap = remote_libc.base_address + munmap_offset;
Expand Down Expand Up @@ -2280,6 +2290,9 @@ namespace Frida {
this.session = session;

Gum.Linux.enumerate_ranges ((Posix.pid_t) session.pid, READ | EXECUTE, d => {
unowned Gum.FileMapping? file = d.file;
if (file != null && file.path.has_prefix ("memfd:"))
return true;
if (d.range.size >= code.length) {
code_start = d.range.base_address + d.range.size - round_size_to_page_size (code.length);
code_end = code_start + code.length;
Expand Down