Changeset 219273 in webkit


Ignore:
Timestamp:
Jul 7, 2017 5:03:27 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

Lower the max_protection for the separated heap
https://bugs.webkit.org/show_bug.cgi?id=174281

Patch by AJ Ringer <aringer@apple.com> on 2017-07-07
Reviewed by Oliver Hunt.

Switch to vm_protect so we can set maximum page protection.

  • jit/ExecutableAllocator.cpp:

(JSC::FixedVMPoolExecutableAllocator::initializeSeparatedWXHeaps):
(JSC::ExecutableAllocator::allocate):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r219268 r219273  
     12017-07-07  AJ Ringer  <aringer@apple.com>
     2
     3        Lower the max_protection for the separated heap
     4        https://bugs.webkit.org/show_bug.cgi?id=174281
     5
     6        Reviewed by Oliver Hunt.
     7
     8        Switch to vm_protect so we can set maximum page protection.
     9
     10        * jit/ExecutableAllocator.cpp:
     11        (JSC::FixedVMPoolExecutableAllocator::initializeSeparatedWXHeaps):
     12        (JSC::ExecutableAllocator::allocate):
     13
    1142017-07-07  Devin Rousso  <drousso@apple.com>
    215
  • trunk/Source/JavaScriptCore/jit/ExecutableAllocator.cpp

    r219055 r219273  
    213213#if USE(EXECUTE_ONLY_JIT_WRITE_FUNCTION)
    214214        // Prevent reading the write thunk code.
    215         result = mprotect(stubBase, stubSize, VM_PROT_EXECUTE_ONLY);
     215        result = vm_protect(mach_task_self(), reinterpret_cast<vm_address_t>(stubBase), stubSize, true, VM_PROT_EXECUTE);
    216216        RELEASE_ASSERT(!result);
    217217#endif
    218218
    219219        // Prevent writing into the executable JIT mapping.
    220         result = mprotect(jitBase, jitSize, VM_PROT_READ | VM_PROT_EXECUTE);
     220        result = vm_protect(mach_task_self(), reinterpret_cast<vm_address_t>(jitBase), jitSize, true, VM_PROT_READ | VM_PROT_EXECUTE);
    221221        RELEASE_ASSERT(!result);
    222222
    223223        // Prevent execution in the writable JIT mapping.
    224         result = mprotect((void*)writableAddr, jitSize, VM_PROT_READ | VM_PROT_WRITE);
     224        result = vm_protect(mach_task_self(), static_cast<vm_address_t>(writableAddr), jitSize, true, VM_PROT_READ | VM_PROT_WRITE);
    225225        RELEASE_ASSERT(!result);
    226226
     
    397397        dataLog("Allocating ", sizeInBytes, " bytes of executable memory with ", stats.bytesAllocated, " bytes allocated, ", stats.bytesReserved, " bytes reserved, and ", stats.bytesCommitted, " committed.\n");
    398398    }
    399    
     399
    400400    if (effort != JITCompilationCanFail && Options::reportMustSucceedExecutableAllocations()) {
    401401        dataLog("Allocating ", sizeInBytes, " bytes of executable memory with JITCompilationMustSucceed.\n");
    402402        WTFReportBacktrace();
    403403    }
    404    
     404
    405405    if (effort == JITCompilationCanFail
    406406        && doExecutableAllocationFuzzingIfEnabled() == PretendToFailExecutableAllocation)
    407407        return nullptr;
    408    
     408
    409409    if (effort == JITCompilationCanFail) {
    410410        // Don't allow allocations if we are down to reserve.
     
    419419        }
    420420    }
    421    
     421
    422422    RefPtr<ExecutableMemoryHandle> result = allocator->allocate(sizeInBytes, ownerUID);
    423423    if (!result) {
     
    452452}
    453453#endif
    454    
     454
    455455}
    456456
Note: See TracChangeset for help on using the changeset viewer.