Title: [144971] trunk/Source/WTF
Revision
144971
Author
[email protected]
Date
2013-03-06 13:16:45 -0800 (Wed, 06 Mar 2013)

Log Message

Make fastmalloc use guardpages
https://bugs.webkit.org/show_bug.cgi?id=111353

Reviewed by Anders Carlsson.

Add PROT_NONE pages at the beginning and end of every
mmap call made by fastmalloc.

* wtf/TCSystemAlloc.cpp:
(TryMmap):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (144970 => 144971)


--- trunk/Source/WTF/ChangeLog	2013-03-06 21:12:04 UTC (rev 144970)
+++ trunk/Source/WTF/ChangeLog	2013-03-06 21:16:45 UTC (rev 144971)
@@ -1,3 +1,16 @@
+2013-03-04  Oliver Hunt  <[email protected]>
+
+        Make fastmalloc use guardpages
+        https://bugs.webkit.org/show_bug.cgi?id=111353
+
+        Reviewed by Anders Carlsson.
+
+        Add PROT_NONE pages at the beginning and end of every
+        mmap call made by fastmalloc.
+
+        * wtf/TCSystemAlloc.cpp:
+        (TryMmap):
+
 2013-03-06  PaweÅ‚ Forysiuk  <[email protected]>
 
         Typo in inline function in ByteOrder.h

Modified: trunk/Source/WTF/wtf/TCSystemAlloc.cpp (144970 => 144971)


--- trunk/Source/WTF/wtf/TCSystemAlloc.cpp	2013-03-06 21:12:04 UTC (rev 144970)
+++ trunk/Source/WTF/wtf/TCSystemAlloc.cpp	2013-03-06 21:16:45 UTC (rev 144971)
@@ -35,6 +35,7 @@
 #include "TCSystemAlloc.h"
 
 #include "Assertions.h"
+#include "CheckedArithmetic.h"
 #include "TCSpinLock.h"
 #include "UnusedParam.h"
 #include "VMTags.h"
@@ -166,7 +167,8 @@
   if (alignment > pagesize) {
     extra = alignment - pagesize;
   }
-  void* result = mmap(NULL, size + extra,
+  Checked<size_t> mapSize = Checked<size_t>(size) + extra + 2 * pagesize;
+  void* result = mmap(NULL, mapSize.unsafeGet(),
                       PROT_READ | PROT_WRITE,
                       MAP_PRIVATE|MAP_ANONYMOUS,
                       VM_TAG_FOR_TCMALLOC_MEMORY, 0);
@@ -174,7 +176,9 @@
     mmap_failure = true;
     return NULL;
   }
-
+  mmap(result, pagesize, PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, VM_TAG_FOR_TCMALLOC_MEMORY, 0);
+  mmap(static_cast<char*>(result) + (mapSize - pagesize).unsafeGet(), pagesize, PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, VM_TAG_FOR_TCMALLOC_MEMORY, 0);
+  result = static_cast<char*>(result) + pagesize;
   // Adjust the return memory so it is aligned
   uintptr_t ptr = reinterpret_cast<uintptr_t>(result);
   size_t adjust = 0;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to