Changeset 92635 in webkit


Ignore:
Timestamp:
Aug 8, 2011 2:28:53 PM (13 years ago)
Author:
oliver@apple.com
Message:

Using mprotect to create guard pages breaks our use of madvise to release executable memory
https://bugs.webkit.org/show_bug.cgi?id=65870

Reviewed by Gavin Barraclough.

Use mmap rather than mprotect to clear guard page permissions.

  • wtf/OSAllocatorPosix.cpp:

(WTF::OSAllocator::reserveAndCommit):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r92618 r92635  
     12011-08-08  Oliver Hunt  <oliver@apple.com>
     2
     3        Using mprotect to create guard pages breaks our use of madvise to release executable memory
     4        https://bugs.webkit.org/show_bug.cgi?id=65870
     5
     6        Reviewed by Gavin Barraclough.
     7
     8        Use mmap rather than mprotect to clear guard page permissions.
     9
     10        * wtf/OSAllocatorPosix.cpp:
     11        (WTF::OSAllocator::reserveAndCommit):
     12
    1132011-08-08  Oliver Hunt  <oliver@apple.com>
    214
  • trunk/Source/JavaScriptCore/wtf/OSAllocatorPosix.cpp

    r87308 r92635  
    105105    }
    106106    if (result && includesGuardPages) {
    107         mprotect(result, pageSize(), PROT_NONE);
    108         mprotect(static_cast<char*>(result) + bytes - pageSize(), pageSize(), PROT_NONE);
     107        // We use mmap to remap the guardpages rather than using mprotect as
     108        // mprotect results in multiple references to the code region.  This
     109        // breaks the madvise based mechanism we use to return physical memory
     110        // to the OS.
     111        mmap(result, pageSize(), PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, fd, 0);
     112        mmap(static_cast<char*>(result) + bytes - pageSize(), pageSize(), PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, fd, 0);
    109113    }
    110114    return result;
Note: See TracChangeset for help on using the changeset viewer.