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

Unified Diff: third_party/WebKit/Source/platform/heap/HeapPage.h

Issue 2716383003: Better distribute the randomness of the Oilpan metadata canary. (Closed)
Patch Set: Rebase. Created 3 years, 10 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: third_party/WebKit/Source/platform/heap/HeapPage.h
diff --git a/third_party/WebKit/Source/platform/heap/HeapPage.h b/third_party/WebKit/Source/platform/heap/HeapPage.h
index cc591923147822a8aec5ac715d63ba502d26d009..5a9a56c1aa5436055d3ec04b4008e746ee10e532 100644
--- a/third_party/WebKit/Source/platform/heap/HeapPage.h
+++ b/third_party/WebKit/Source/platform/heap/HeapPage.h
@@ -873,16 +873,32 @@ inline HeapObjectHeader* HeapObjectHeader::fromPayload(const void* payload) {
}
#if CPU(64BIT)
+ALWAYS_INLINE uint32_t RotateLeft16(uint32_t x) {
+#if COMPILER(MSVC)
+ return _lrotr(x, 16);
+#else
+ // http://blog.regehr.org/archives/1063
+ return (x << 16) | (x >> (-16 & 31));
+#endif
+}
+
inline uint32_t HeapObjectHeader::getMagic() const {
- const uintptr_t random1 =
- ~(reinterpret_cast<uintptr_t>(
- base::trace_event::MemoryAllocatorDump::kNameSize) >>
- 16);
+// Ignore C4319: It is OK to 0-extend into the high-order bits of the uintptr_t
+// on 64-bit, in this case.
+#if COMPILER(MSVC)
+#pragma warning(push)
+#pragma warning(disable : 4319)
+#endif
+
+ const uintptr_t random1 = ~(RotateLeft16(reinterpret_cast<uintptr_t>(
+ base::trace_event::MemoryAllocatorDump::kNameSize)));
#if OS(WIN)
- const uintptr_t random2 = ~(reinterpret_cast<uintptr_t>(::ReadFile) << 16);
+ const uintptr_t random2 =
+ ~(RotateLeft16(reinterpret_cast<uintptr_t>(::ReadFile)));
#elif OS(POSIX)
- const uintptr_t random2 = ~(reinterpret_cast<uintptr_t>(::read) << 16);
+ const uintptr_t random2 =
+ ~(RotateLeft16(reinterpret_cast<uintptr_t>(::read)));
#else
#error OS not supported
#endif
@@ -902,9 +918,13 @@ inline uint32_t HeapObjectHeader::getMagic() const {
#error architecture not supported
#endif
+#if COMPILER(MSVC)
+#pragma warning(pop)
+#endif
+
return random;
}
-#endif
+#endif // CPU(64BIT)
NO_SANITIZE_ADDRESS inline bool HeapObjectHeader::isWrapperHeaderMarked()
const {
« 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