• Ulan Degenbaev's avatar
    [heap] Rework ASLR for base::Platform::VirtualMemory · 0640cbf3
    Ulan Degenbaev authored
    Currently every VirtualMemory allocation on 64-bit systems
    uses a random 46-bit address hint for ASLR.
    
    This leads to wired page leak on MacOS discovered by Erik Chen (see
    crbug.com/700928 and https://chromium-review.googlesource.com/c/557958/):
    "The Darwin kernel [as of macOS 10.12.5] does not clean up page directory
    entries [PDE] created from mmap or mach_vm_allocate, even after
    the region is destroyed. Using a virtual address space that is too large
    causes a leak of about 1 wired [can never be paged out] page per call to
    mmap(). The page is only reclaimed when the process is killed."
    
    This patch changes VirtualMemory to accept the hint parameter explicitly.
    
    On MacOS the hints are confined to 4GB contiguous region. Algorithm:
    - On startup, set heap.mmap_region_base_ to a random address.
    - For each mmap use heap.mmap_region_base_ + (random_offset % (4*GB)).
    
    BUG=chromium:700928
    
    Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
    Change-Id: I2ae6a024e02fbe63f940105d7920b57c19abacc6
    Reviewed-on: https://chromium-review.googlesource.com/558876
    Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
    Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#46656}
    0640cbf3
Name
Last commit
Last update
..
api Loading commit data...
asmjs Loading commit data...
base Loading commit data...
compiler Loading commit data...
compiler-dispatcher Loading commit data...
heap Loading commit data...
interpreter Loading commit data...
libplatform Loading commit data...
parser Loading commit data...
wasm Loading commit data...
zone Loading commit data...
BUILD.gn Loading commit data...
DEPS Loading commit data...
cancelable-tasks-unittest.cc Loading commit data...
char-predicates-unittest.cc Loading commit data...
counters-unittest.cc Loading commit data...
eh-frame-iterator-unittest.cc Loading commit data...
eh-frame-writer-unittest.cc Loading commit data...
locked-queue-unittest.cc Loading commit data...
object-unittest.cc Loading commit data...
register-configuration-unittest.cc Loading commit data...
run-all-unittests.cc Loading commit data...
source-position-table-unittest.cc Loading commit data...
test-helpers.cc Loading commit data...
test-helpers.h Loading commit data...
test-utils.cc Loading commit data...
test-utils.h Loading commit data...
unicode-unittest.cc Loading commit data...
unittests.gyp Loading commit data...
unittests.isolate Loading commit data...
unittests.status Loading commit data...
value-serializer-unittest.cc Loading commit data...