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.
This commit is contained in:
Mohamed Amine Amor authored and Ole André Vadla Ravnås committed 2025-01-23 19:13:59 +01:00
1 parent b6577afe81
commit 72a96226ce
1 file changed
+3
+3
View File
@@ -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;