Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(606)

Unified Diff: third_party/WebKit/Source/wtf/AddressSpaceRandomization.cpp

Issue 1401483002: Fix PartitionAlloc randomization on 32-bit systems (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: carve out tsan's range in getRandomPageBase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/PageAllocator.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..bad31582da697fe35db3a317a479e44fc7f25ae5 100644
--- a/third_party/WebKit/Source/wtf/AddressSpaceRandomization.cpp
+++ b/third_party/WebKit/Source/wtf/AddressSpaceRandomization.cpp
@@ -99,6 +99,10 @@ void* getRandomPageBase()
// TODO(cevans): I think Win 8.1 has 47-bits like Linux.
random &= 0x3ffffffffffUL;
random += 0x10000000000UL;
+#elif defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
+ // This range is copied from the TSan source, but works for all tools.
Alexander Potapenko 2015/10/13 18:00:46 Should be fine. The acceptable ranges for ASan on
jschuh 2015/10/13 18:35:57 Okay, sounds like this has enough room to play in.
+ random &= 0x007fffffffffUL;
+ random += 0x7e8000000000UL;
#else
// Linux and OS X support the full 47-bit user space of x64 processors.
random &= 0x3fffffffffffUL;
@@ -108,6 +112,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;
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/PageAllocator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698