Skip to content

Commit

Permalink
linux: Avoid risky code swaps with memfd regions
Browse files Browse the repository at this point in the history
As they may not be writable, and unlike regular regions, ptrace() won't
help us in case of a missing writable bit.
  • Loading branch information
amor-riscure authored and oleavr committed Jan 23, 2025
1 parent e181785 commit ffdfc52
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/linux/frida-helper-backend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2290,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

0 comments on commit ffdfc52

Please sign in to comment.