Title: [295382] trunk/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp
Revision
295382
Author
commit-qu...@webkit.org
Date
2022-06-08 09:31:21 -0700 (Wed, 08 Jun 2022)

Log Message

REGRESSION(247105@main): Set protections on MAP_ALIGNED platforms too
https://bugs.webkit.org/show_bug.cgi?id=241386

Patch by Leonardo Taccari <l...@netbsd.org> on 2022-06-08
Reviewed by Yusuke Suzuki.

Since the introduction of tryReserveUncommittedAligned() on platforms
that have MAP_ALIGNED via 247105@main, reserved pages via that
function never had the protections adjusted and will likely ends
up in SIGSEGV.

* Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp:
(WTF::OSAllocator::tryReserveUncommittedAligned):

Canonical link: https://commits.webkit.org/251390@main

Modified Paths

Diff

Modified: trunk/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp (295381 => 295382)


--- trunk/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp	2022-06-08 15:50:17 UTC (rev 295381)
+++ trunk/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp	2022-06-08 16:31:21 UTC (rev 295382)
@@ -183,11 +183,15 @@
 #define MAP_NORESERVE 0
 #endif
     UNUSED_PARAM(usage);
-    UNUSED_PARAM(writable);
-    UNUSED_PARAM(executable);
     UNUSED_PARAM(jitCageEnabled);
     UNUSED_PARAM(includesGuardPages);
-    void* result = mmap(0, bytes, PROT_NONE, MAP_NORESERVE | MAP_PRIVATE | MAP_ANON | MAP_ALIGNED(getLSBSet(alignment)), -1, 0);
+    int protection = PROT_READ;
+    if (writable)
+        protection |= PROT_WRITE;
+    if (executable)
+        protection |= PROT_EXEC;
+
+    void* result = mmap(0, bytes, protection, MAP_NORESERVE | MAP_PRIVATE | MAP_ANON | MAP_ALIGNED(getLSBSet(alignment)), -1, 0);
     if (result == MAP_FAILED)
         return nullptr;
     if (result)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to