Title: [249613] trunk/Source
Revision
249613
Author
[email protected]
Date
2019-09-07 08:01:31 -0700 (Sat, 07 Sep 2019)

Log Message

performJITMemcpy() source buffer should not be in the Gigacage.
https://bugs.webkit.org/show_bug.cgi?id=201577
<rdar://problem/55142606>

Reviewed by Michael Saboff.

Source/bmalloc:

1. Add the Gigacage start address and totalSize to the Config.
2. Add a contains() function that uses the start address and totalSize to check
   if a given pointer is in the Gigacage's address range.

* bmalloc/Gigacage.cpp:
(Gigacage::ensureGigacage):
(Gigacage::verifyGigacageIsEnabled):
* bmalloc/Gigacage.h:
(Gigacage::contains):

Source/_javascript_Core:

Add a RELEASE_ASSERT in performJITMemcpy() to ensure that the passed in source
buffer is not in the Gigacage.

* jit/ExecutableAllocator.h:
(JSC::performJITMemcpy):

Source/WTF:

* wtf/Gigacage.h:
(Gigacage::contains):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (249612 => 249613)


--- trunk/Source/_javascript_Core/ChangeLog	2019-09-07 14:53:21 UTC (rev 249612)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-09-07 15:01:31 UTC (rev 249613)
@@ -1,5 +1,19 @@
 2019-09-07  Mark Lam  <[email protected]>
 
+        performJITMemcpy() source buffer should not be in the Gigacage.
+        https://bugs.webkit.org/show_bug.cgi?id=201577
+        <rdar://problem/55142606>
+
+        Reviewed by Michael Saboff.
+
+        Add a RELEASE_ASSERT in performJITMemcpy() to ensure that the passed in source
+        buffer is not in the Gigacage.
+
+        * jit/ExecutableAllocator.h:
+        (JSC::performJITMemcpy):
+
+2019-09-07  Mark Lam  <[email protected]>
+
         The jsc shell should allow disabling of the Gigacage for testing purposes.
         https://bugs.webkit.org/show_bug.cgi?id=201579
 

Modified: trunk/Source/_javascript_Core/jit/ExecutableAllocator.h (249612 => 249613)


--- trunk/Source/_javascript_Core/jit/ExecutableAllocator.h	2019-09-07 14:53:21 UTC (rev 249612)
+++ trunk/Source/_javascript_Core/jit/ExecutableAllocator.h	2019-09-07 15:01:31 UTC (rev 249613)
@@ -31,6 +31,7 @@
 #include <stddef.h> // for ptrdiff_t
 #include <limits>
 #include <wtf/Assertions.h>
+#include <wtf/Gigacage.h>
 #include <wtf/Lock.h>
 #include <wtf/MetaAllocatorHandle.h>
 #include <wtf/MetaAllocator.h>
@@ -124,6 +125,7 @@
 
 static ALWAYS_INLINE void* performJITMemcpy(void *dst, const void *src, size_t n)
 {
+    RELEASE_ASSERT(!Gigacage::contains(src));
 #if CPU(ARM64)
     static constexpr size_t instructionSize = sizeof(unsigned);
     RELEASE_ASSERT(roundUpToMultipleOf<instructionSize>(dst) == dst);

Modified: trunk/Source/WTF/ChangeLog (249612 => 249613)


--- trunk/Source/WTF/ChangeLog	2019-09-07 14:53:21 UTC (rev 249612)
+++ trunk/Source/WTF/ChangeLog	2019-09-07 15:01:31 UTC (rev 249613)
@@ -1,3 +1,14 @@
+2019-09-07  Mark Lam  <[email protected]>
+
+        performJITMemcpy() source buffer should not be in the Gigacage.
+        https://bugs.webkit.org/show_bug.cgi?id=201577
+        <rdar://problem/55142606>
+
+        Reviewed by Michael Saboff.
+
+        * wtf/Gigacage.h:
+        (Gigacage::contains):
+
 2019-09-06  Mark Lam  <[email protected]>
 
         Harden protection of the Gigacage Config parameters.

Modified: trunk/Source/WTF/wtf/Gigacage.h (249612 => 249613)


--- trunk/Source/WTF/wtf/Gigacage.h	2019-09-07 14:53:21 UTC (rev 249612)
+++ trunk/Source/WTF/wtf/Gigacage.h	2019-09-07 15:01:31 UTC (rev 249613)
@@ -69,6 +69,7 @@
     return nullptr;
 }
 
+ALWAYS_INLINE bool contains(const void*) { return false; }
 ALWAYS_INLINE bool isEnabled(Kind) { return false; }
 ALWAYS_INLINE size_t mask(Kind) { return 0; }
 

Modified: trunk/Source/bmalloc/ChangeLog (249612 => 249613)


--- trunk/Source/bmalloc/ChangeLog	2019-09-07 14:53:21 UTC (rev 249612)
+++ trunk/Source/bmalloc/ChangeLog	2019-09-07 15:01:31 UTC (rev 249613)
@@ -1,3 +1,21 @@
+2019-09-07  Mark Lam  <[email protected]>
+
+        performJITMemcpy() source buffer should not be in the Gigacage.
+        https://bugs.webkit.org/show_bug.cgi?id=201577
+        <rdar://problem/55142606>
+
+        Reviewed by Michael Saboff.
+
+        1. Add the Gigacage start address and totalSize to the Config.
+        2. Add a contains() function that uses the start address and totalSize to check
+           if a given pointer is in the Gigacage's address range.
+
+        * bmalloc/Gigacage.cpp:
+        (Gigacage::ensureGigacage):
+        (Gigacage::verifyGigacageIsEnabled):
+        * bmalloc/Gigacage.h:
+        (Gigacage::contains):
+
 2019-09-06  Mark Lam  <[email protected]>
 
         Harden protection of the Gigacage Config parameters.

Modified: trunk/Source/bmalloc/bmalloc/Gigacage.cpp (249612 => 249613)


--- trunk/Source/bmalloc/bmalloc/Gigacage.cpp	2019-09-07 14:53:21 UTC (rev 249612)
+++ trunk/Source/bmalloc/bmalloc/Gigacage.cpp	2019-09-07 15:01:31 UTC (rev 249613)
@@ -77,7 +77,7 @@
 // in size. 2^32 * 8 = 32GB. This means if an access on a caged type happens to go out of
 // bounds, the access is guaranteed to land somewhere else in the cage or inside the runway.
 // If this were less than 32GB, those OOB accesses could reach outside of the cage.
-constexpr size_t gigacageRunway = 32llu * 1024 * 1024 * 1024;
+constexpr size_t gigacageRunway = 32llu * bmalloc::Sizes::GB;
 
 alignas(configSizeToProtect) Config g_gigacageConfig;
 
@@ -232,7 +232,9 @@
                     nextCage += runwaySize(kind);
                 }
             }
-            
+
+            g_gigacageConfig.start = base;
+            g_gigacageConfig.totalSize = totalSize;
             vmDeallocatePhysicalPages(base, totalSize);
             g_gigacageConfig.isEnabled = true;
             freezeGigacageConfig();
@@ -296,6 +298,8 @@
     bool isEnabled = g_gigacageConfig.isEnabled;
     for (size_t i = 0; i < NumberOfKinds; ++i)
         isEnabled = isEnabled && g_gigacageConfig.basePtrs[i];
+    isEnabled = isEnabled && g_gigacageConfig.start;
+    isEnabled = isEnabled && g_gigacageConfig.totalSize;
     return isEnabled;
 }
 

Modified: trunk/Source/bmalloc/bmalloc/Gigacage.h (249612 => 249613)


--- trunk/Source/bmalloc/bmalloc/Gigacage.h	2019-09-07 14:53:21 UTC (rev 249612)
+++ trunk/Source/bmalloc/bmalloc/Gigacage.h	2019-09-07 15:01:31 UTC (rev 249613)
@@ -128,6 +128,8 @@
             bool shouldBeEnabledHasBeenCalled;
             bool ensureGigacageHasBeenCalled;
 
+            void* start;
+            size_t totalSize;
             void* basePtrs[NumberOfKinds];
         };
         char ensureSize[configSizeToProtect];
@@ -230,6 +232,13 @@
     return caged(kind, ptr) == ptr;
 }
 
+BINLINE bool contains(const void* ptr)
+{
+    auto* start = reinterpret_cast<const uint8_t*>(g_gigacageConfig.start);
+    auto* p = reinterpret_cast<const uint8_t*>(ptr);
+    return static_cast<size_t>(p - start) < g_gigacageConfig.totalSize;
+}
+
 BEXPORT bool shouldBeEnabled();
 
 #else // GIGACAGE_ENABLED
@@ -242,6 +251,7 @@
 }
 BINLINE size_t size(Kind) { BCRASH(); return 0; }
 BINLINE void ensureGigacage() { }
+BINLINE bool contains(const void*) { return false; }
 BINLINE bool isEnabled() { return false; }
 BINLINE bool isCaged(Kind, const void*) { return true; }
 BINLINE bool isEnabled(Kind) { return false; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to