Changeset 249613 in webkit


Ignore:
Timestamp:
Sep 7, 2019 8:01:31 AM (5 years ago)
Author:
mark.lam@apple.com
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/JavaScriptCore:

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):

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r249612 r249613  
     12019-09-07  Mark Lam  <mark.lam@apple.com>
     2
     3        performJITMemcpy() source buffer should not be in the Gigacage.
     4        https://bugs.webkit.org/show_bug.cgi?id=201577
     5        <rdar://problem/55142606>
     6
     7        Reviewed by Michael Saboff.
     8
     9        Add a RELEASE_ASSERT in performJITMemcpy() to ensure that the passed in source
     10        buffer is not in the Gigacage.
     11
     12        * jit/ExecutableAllocator.h:
     13        (JSC::performJITMemcpy):
     14
    1152019-09-07  Mark Lam  <mark.lam@apple.com>
    216
  • trunk/Source/JavaScriptCore/jit/ExecutableAllocator.h

    r249449 r249613  
    3232#include <limits>
    3333#include <wtf/Assertions.h>
     34#include <wtf/Gigacage.h>
    3435#include <wtf/Lock.h>
    3536#include <wtf/MetaAllocatorHandle.h>
     
    125126static ALWAYS_INLINE void* performJITMemcpy(void *dst, const void *src, size_t n)
    126127{
     128    RELEASE_ASSERT(!Gigacage::contains(src));
    127129#if CPU(ARM64)
    128130    static constexpr size_t instructionSize = sizeof(unsigned);
  • trunk/Source/WTF/ChangeLog

    r249608 r249613  
     12019-09-07  Mark Lam  <mark.lam@apple.com>
     2
     3        performJITMemcpy() source buffer should not be in the Gigacage.
     4        https://bugs.webkit.org/show_bug.cgi?id=201577
     5        <rdar://problem/55142606>
     6
     7        Reviewed by Michael Saboff.
     8
     9        * wtf/Gigacage.h:
     10        (Gigacage::contains):
     11
    1122019-09-06  Mark Lam  <mark.lam@apple.com>
    213
  • trunk/Source/WTF/wtf/Gigacage.h

    r249608 r249613  
    7070}
    7171
     72ALWAYS_INLINE bool contains(const void*) { return false; }
    7273ALWAYS_INLINE bool isEnabled(Kind) { return false; }
    7374ALWAYS_INLINE size_t mask(Kind) { return 0; }
  • trunk/Source/bmalloc/ChangeLog

    r249608 r249613  
     12019-09-07  Mark Lam  <mark.lam@apple.com>
     2
     3        performJITMemcpy() source buffer should not be in the Gigacage.
     4        https://bugs.webkit.org/show_bug.cgi?id=201577
     5        <rdar://problem/55142606>
     6
     7        Reviewed by Michael Saboff.
     8
     9        1. Add the Gigacage start address and totalSize to the Config.
     10        2. Add a contains() function that uses the start address and totalSize to check
     11           if a given pointer is in the Gigacage's address range.
     12
     13        * bmalloc/Gigacage.cpp:
     14        (Gigacage::ensureGigacage):
     15        (Gigacage::verifyGigacageIsEnabled):
     16        * bmalloc/Gigacage.h:
     17        (Gigacage::contains):
     18
    1192019-09-06  Mark Lam  <mark.lam@apple.com>
    220
  • trunk/Source/bmalloc/bmalloc/Gigacage.cpp

    r249608 r249613  
    7878// bounds, the access is guaranteed to land somewhere else in the cage or inside the runway.
    7979// If this were less than 32GB, those OOB accesses could reach outside of the cage.
    80 constexpr size_t gigacageRunway = 32llu * 1024 * 1024 * 1024;
     80constexpr size_t gigacageRunway = 32llu * bmalloc::Sizes::GB;
    8181
    8282alignas(configSizeToProtect) Config g_gigacageConfig;
     
    233233                }
    234234            }
    235            
     235
     236            g_gigacageConfig.start = base;
     237            g_gigacageConfig.totalSize = totalSize;
    236238            vmDeallocatePhysicalPages(base, totalSize);
    237239            g_gigacageConfig.isEnabled = true;
     
    297299    for (size_t i = 0; i < NumberOfKinds; ++i)
    298300        isEnabled = isEnabled && g_gigacageConfig.basePtrs[i];
     301    isEnabled = isEnabled && g_gigacageConfig.start;
     302    isEnabled = isEnabled && g_gigacageConfig.totalSize;
    299303    return isEnabled;
    300304}
  • trunk/Source/bmalloc/bmalloc/Gigacage.h

    r249608 r249613  
    129129            bool ensureGigacageHasBeenCalled;
    130130
     131            void* start;
     132            size_t totalSize;
    131133            void* basePtrs[NumberOfKinds];
    132134        };
     
    231233}
    232234
     235BINLINE bool contains(const void* ptr)
     236{
     237    auto* start = reinterpret_cast<const uint8_t*>(g_gigacageConfig.start);
     238    auto* p = reinterpret_cast<const uint8_t*>(ptr);
     239    return static_cast<size_t>(p - start) < g_gigacageConfig.totalSize;
     240}
     241
    233242BEXPORT bool shouldBeEnabled();
    234243
     
    243252BINLINE size_t size(Kind) { BCRASH(); return 0; }
    244253BINLINE void ensureGigacage() { }
     254BINLINE bool contains(const void*) { return false; }
    245255BINLINE bool isEnabled() { return false; }
    246256BINLINE bool isCaged(Kind, const void*) { return true; }
Note: See TracChangeset for help on using the changeset viewer.