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

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: return null base address for memory tools 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..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
}
}
« 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