• 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
..
benchmarks Loading commit data...
cctest Loading commit data...
common Loading commit data...
debugger Loading commit data...
fuzzer Loading commit data...
inspector Loading commit data...
intl Loading commit data...
js-perf-test Loading commit data...
memory Loading commit data...
message Loading commit data...
mjsunit Loading commit data...
mkgrokdump Loading commit data...
mozilla Loading commit data...
preparser Loading commit data...
promises-aplus Loading commit data...
test262 Loading commit data...
unittests Loading commit data...
wasm-spec-tests Loading commit data...
webkit Loading commit data...
BUILD.gn Loading commit data...
bot_default.gyp Loading commit data...
bot_default.isolate Loading commit data...
default.gyp Loading commit data...
default.isolate Loading commit data...
optimize_for_size.gyp Loading commit data...
optimize_for_size.isolate Loading commit data...
perf.gyp Loading commit data...
perf.isolate Loading commit data...