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

Unified Diff: src/base/platform/platform-win32.cc

Issue 1385023002: Disable VirtualAlloc randomization on 32-bit Windows hosts (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/base/platform/platform-win32.cc
diff --git a/src/base/platform/platform-win32.cc b/src/base/platform/platform-win32.cc
index a73dc523c41278e79db28b93580152872cb54a8c..fa70f87f46def92f216e40821687514fd0f9f64d 100644
--- a/src/base/platform/platform-win32.cc
+++ b/src/base/platform/platform-win32.cc
@@ -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);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698