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

Unified Diff: third_party/tcmalloc/chromium/src/system-alloc.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.h ('k') | third_party/tcmalloc/chromium/src/windows/port.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/tcmalloc/chromium/src/system-alloc.cc
===================================================================
--- third_party/tcmalloc/chromium/src/system-alloc.cc (revision 110522)
+++ third_party/tcmalloc/chromium/src/system-alloc.cc (working copy)
@@ -103,8 +103,7 @@
static SpinLock spinlock(SpinLock::LINKER_INITIALIZED);
-#if defined(HAVE_MMAP) || defined(MADV_DONTNEED)
-// Page size is initialized on demand (only needed for mmap-based allocators)
+#ifdef HAVE_GETPAGESIZE
static size_t pagesize = 0;
#endif
@@ -484,6 +483,21 @@
return result;
}
+size_t TCMalloc_SystemAddGuard(void* start, size_t size) {
+#ifdef HAVE_GETPAGESIZE
+ if (pagesize == 0)
+ pagesize = getpagesize();
+
+ if (size < pagesize || (reinterpret_cast<size_t>(start) % pagesize) != 0)
+ return 0;
+
+ if (!mprotect(start, pagesize, PROT_NONE))
+ return pagesize;
+#endif
+
+ return 0;
+}
+
void TCMalloc_SystemRelease(void* start, size_t length) {
#ifdef MADV_DONTNEED
if (FLAGS_malloc_devmem_start) {
« no previous file with comments | « third_party/tcmalloc/chromium/src/system-alloc.h ('k') | third_party/tcmalloc/chromium/src/windows/port.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698