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

Unified Diff: third_party/tcmalloc/chromium/src/windows/port.cc

Issue 8570023: Add a guard page in front of metadata allocations. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | « third_party/tcmalloc/chromium/src/system-alloc.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/tcmalloc/chromium/src/windows/port.cc
===================================================================
--- third_party/tcmalloc/chromium/src/windows/port.cc (revision 110522)
+++ third_party/tcmalloc/chromium/src/windows/port.cc (working copy)
@@ -258,6 +258,31 @@
return result;
}
+size_t TCMalloc_SystemAddGuard(void* start, size_t size) {
+ static size_t pagesize = 0;
+ if (pagesize == 0) {
+ SYSTEM_INFO system_info;
+ GetSystemInfo(&system_info);
+ pagesize = system_info.dwPageSize;
+ }
+
+ // We know that TCMalloc_SystemAlloc will give us a correct page alignment
+ // regardless, so we can just assert to detect erroneous callers.
+ assert(reinterpret_cast<size_t>(start) % pagesize == 0);
+
+ // Add a guard page to catch metadata corruption. We're using the
+ // PAGE_GUARD flag rather than NO_ACCESS because we want the unique
+ // exception in crash reports.
+ DWORD permissions = 0;
+ if (size > pagesize &&
+ VirtualProtect(start, pagesize, PAGE_READONLY | PAGE_GUARD,
+ &permissions)) {
+ return pagesize;
+ }
+
+ return 0;
+}
+
void TCMalloc_SystemRelease(void* start, size_t length) {
if (VirtualFree(start, length, MEM_DECOMMIT))
return;
« no previous file with comments | « third_party/tcmalloc/chromium/src/system-alloc.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698