Index: third_party/WebKit/Source/wtf/AddressSpaceRandomization.cpp |
diff --git a/third_party/WebKit/Source/wtf/AddressSpaceRandomization.cpp b/third_party/WebKit/Source/wtf/AddressSpaceRandomization.cpp |
index 2a363a33e306649fdf2dfc68a43e537f20a8d937..d0344457802bd75f7e2971ec877044f4b5b84432 100644 |
--- a/third_party/WebKit/Source/wtf/AddressSpaceRandomization.cpp |
+++ b/third_party/WebKit/Source/wtf/AddressSpaceRandomization.cpp |
@@ -86,6 +86,9 @@ static struct ranctx s_ranctx; |
// space too badly. |
void* getRandomPageBase() |
{ |
+#if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) |
Alexander Potapenko
2015/10/13 16:02:42
You also need "if !defined(MEMORY_TOOL_REPLACES_AL
jschuh
2015/10/13 17:44:13
I dropped this approach and just added a custom ra
|
+ return nullptr; |
+#else |
uintptr_t random; |
random = static_cast<uintptr_t>(ranval(&s_ranctx)); |
#if CPU(X86_64) |
@@ -108,6 +111,17 @@ void* getRandomPageBase() |
random &= 0x3fffffffffUL; |
random += 0x1000000000UL; |
#else // !CPU(X86_64) && !CPU(ARM64) |
+#if OS(WIN) |
+ // On win32 host systems the randomization plus huge alignment causes |
+ // excessive fragmentation. Plus most of these systems lack ASLR, so the |
+ // randomization isn't buying anything. In that case we just skip it. |
+ // TODO(jschuh): Just dump the randomization when HE-ASLR is present. |
+ static BOOL isWow64 = -1; |
+ if (isWow64 == -1 && !IsWow64Process(GetCurrentProcess(), &isWow64)) |
+ isWow64 = FALSE; |
+ if (!isWow64) |
+ return nullptr; |
+#endif // OS(WIN) |
// This is a good range on Windows, Linux and Mac. |
// Allocates in the 0.5-1.5GB region. |
random &= 0x3fffffff; |
@@ -115,6 +129,7 @@ void* getRandomPageBase() |
#endif // CPU(X86_64) |
random &= kPageAllocationGranularityBaseMask; |
return reinterpret_cast<void*>(random); |
+#endif // !MEMORY_TOOL_REPLACES_ALLOCATOR |
} |
} |