Commit a15c5c96 authored by jschuh's avatar jschuh Committed by Commit bot

Disable VirtualAlloc randomization on 32-bit Windows hosts

ASLR is much weaker in a 2GB address space. Plus the vast
majority of 32-bit Windows hosts are XP, which don't have
ASLR anyway. So, avoid the fragmentation and skip it in
this case.

BUG=chromium:394591
LOG=Y
R=jochen@chromium.org

Review URL: https://codereview.chromium.org/1385023002

Cr-Commit-Position: refs/heads/master@{#31127}
parent 3d1d7f36
......@@ -751,9 +751,19 @@ void* OS::GetRandomMmapAddr() {
static void* RandomizedVirtualAlloc(size_t size, int action, int protection) {
LPVOID base = NULL;
static BOOL use_aslr = -1;
#ifdef V8_HOST_ARCH_32_BIT
// Don't bother randomizing on 32-bit hosts, because they lack the room and
// don't have viable ASLR anyway.
if (use_aslr == -1 && !IsWow64Process(GetCurrentProcess(), &use_aslr))
use_aslr = FALSE;
#else
use_aslr = TRUE;
#endif
if (protection == PAGE_EXECUTE_READWRITE || protection == PAGE_NOACCESS) {
// For exectutable pages try and randomize the allocation address
if (use_aslr &&
(protection == PAGE_EXECUTE_READWRITE || protection == PAGE_NOACCESS)) {
// For executable pages try and randomize the allocation address
for (size_t attempts = 0; base == NULL && attempts < 3; ++attempts) {
base = VirtualAlloc(OS::GetRandomMmapAddr(), size, action, protection);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment