help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] mem: macos on arm64 does not allow write (and read) on executabl


From: Holger Hans Peter Freyther
Subject: [PATCH] mem: macos on arm64 does not allow write (and read) on executable pages
Date: Sun, 17 Mar 2024 09:26:40 +0800

On macos with apple silicon mmap with PROT_EXEC|PROT_WRITE will fail.
This caused the heap code to fail. We do not expect to execute any of
these pages. So let's remove this bit.

The jit code will require some more changes to support RW^X on hardened
systems.

The change is enough to make basics of gst run on macos/arm64.
---
 libgst/ChangeLog          | 4 ++++
 libgst/sysdep/posix/mem.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/libgst/ChangeLog b/libgst/ChangeLog
index 1ce4c68f..64821314 100644
--- a/libgst/ChangeLog
+++ b/libgst/ChangeLog
@@ -1,3 +1,7 @@
+2024-03-17  Holger Hans Peter Freyther  <holger@freyther.de>
+
+       * sysdep/posix/mem.c (anon_mmap_commit): Enable W^X for our allocated 
memory.
+
 2024-03-16  Holger Hans Peter Freyther  <holger@freyther.de>
 
        * genbc-impl.y: Map yynerrs, yychar to local state. Map yylval to the 
shared state.
diff --git a/libgst/sysdep/posix/mem.c b/libgst/sysdep/posix/mem.c
index 5dc8f1cf..97ebfe69 100644
--- a/libgst/sysdep/posix/mem.c
+++ b/libgst/sysdep/posix/mem.c
@@ -225,7 +225,7 @@ PTR
 anon_mmap_commit (PTR base, size_t size)
 {
   PTR result = mmap (base, size,
-                    PROT_READ | PROT_WRITE | PROT_EXEC,
+                    PROT_READ | PROT_WRITE,
                     MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0);
 
   return UNCOMMON (result == MAP_FAILED) ? NULL : result;
-- 
2.44.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]