Skip to content
Permalink
Browse files
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):

Canonical link: https://commits.webkit.org/129984@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@144971 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
ojhunt committed Mar 6, 2013
1 parent 7591e7f commit 918cac25f9d1902efb609e610ea8c6d542355e5d
Showing 2 changed files with 19 additions and 2 deletions.
@@ -1,3 +1,16 @@
2013-03-04 Oliver Hunt <oliver@apple.com>

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 <tuxator@o2.pl>

Typo in inline function in ByteOrder.h
@@ -35,6 +35,7 @@
#include "TCSystemAlloc.h"

#include "Assertions.h"
#include "CheckedArithmetic.h"
#include "TCSpinLock.h"
#include "UnusedParam.h"
#include "VMTags.h"
@@ -166,15 +167,18 @@ static void* TryMmap(size_t size, size_t *actual_size, size_t alignment) {
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);
if (result == reinterpret_cast<void*>(MAP_FAILED)) {
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;

0 comments on commit 918cac2

Please sign in to comment.