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

Side by Side Diff: third_party/WebKit/Source/wtf/AddressSpaceRandomization.cpp

Issue 1383153002: Fix PartitionAlloc randomization on 32-bit systems (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: slack 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "wtf/AddressSpaceRandomization.h" 6 #include "wtf/AddressSpaceRandomization.h"
7 7
8 #include "wtf/PageAllocator.h" 8 #include "wtf/PageAllocator.h"
9 #include "wtf/SpinLock.h" 9 #include "wtf/SpinLock.h"
10 10
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 random += 0x10000000000UL; 101 random += 0x10000000000UL;
102 #else 102 #else
103 // Linux and OS X support the full 47-bit user space of x64 processors. 103 // Linux and OS X support the full 47-bit user space of x64 processors.
104 random &= 0x3fffffffffffUL; 104 random &= 0x3fffffffffffUL;
105 #endif 105 #endif
106 #elif CPU(ARM64) 106 #elif CPU(ARM64)
107 // ARM64 on Linux has 39-bit user space. 107 // ARM64 on Linux has 39-bit user space.
108 random &= 0x3fffffffffUL; 108 random &= 0x3fffffffffUL;
109 random += 0x1000000000UL; 109 random += 0x1000000000UL;
110 #else // !CPU(X86_64) && !CPU(ARM64) 110 #else // !CPU(X86_64) && !CPU(ARM64)
111 #if OS(WIN)
112 // On win32 host systems the randomization plus huge alignment causes
113 // excessive fragmentation. Plus most of these systems lack ASLR, so the
114 // randomization isn't buying anything. In that case we just skip it.
115 // TODO(jschuh): Just dump the randomization when HE-ASLR is present.
116 static BOOL isWow64 = -1;
117 if (isWow64 == -1 && !IsWow64Process(GetCurrentProcess(), &isWow64))
118 isWow64 = FALSE;
119 if (!isWow64)
120 return nullptr;
121 #endif // OS(WIN)
111 // This is a good range on Windows, Linux and Mac. 122 // This is a good range on Windows, Linux and Mac.
112 // Allocates in the 0.5-1.5GB region. 123 // Allocates in the 0.5-1.5GB region.
113 random &= 0x3fffffff; 124 random &= 0x3fffffff;
114 random += 0x20000000; 125 random += 0x20000000;
115 #endif // CPU(X86_64) 126 #endif // CPU(X86_64)
116 random &= kPageAllocationGranularityBaseMask; 127 random &= kPageAllocationGranularityBaseMask;
117 return reinterpret_cast<void*>(random); 128 return reinterpret_cast<void*>(random);
118 } 129 }
119 130
120 } 131 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/PageAllocator.cpp » ('j') | third_party/WebKit/Source/wtf/PageAllocator.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698