From ffdfc528a764f20bebc691169d6d2ef5019130b6 Mon Sep 17 00:00:00 2001 From: Mohamed Amine Amor <149579187+amor-riscure@users.noreply.github.com> Date: Tue, 21 Jan 2025 21:59:46 +0100 Subject: [PATCH] linux: Avoid risky code swaps with memfd regions As they may not be writable, and unlike regular regions, ptrace() won't help us in case of a missing writable bit. --- src/linux/frida-helper-backend.vala | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/linux/frida-helper-backend.vala b/src/linux/frida-helper-backend.vala index 8e5b88a45..9839fbffb 100644 --- a/src/linux/frida-helper-backend.vala +++ b/src/linux/frida-helper-backend.vala @@ -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;