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

Unified Diff: src/platform-linux.cc

Issue 7352007: Add guard pages in front of platform allocations (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 5 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 | src/platform-macos.cc » ('j') | src/platform-win32.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform-linux.cc
===================================================================
--- src/platform-linux.cc (revision 8619)
+++ src/platform-linux.cc (working copy)
@@ -370,13 +370,16 @@
// TODO(805): Port randomization of allocated executable memory to Linux.
const size_t msize = RoundUp(requested, sysconf(_SC_PAGESIZE));
int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
- void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ void* mbase = mmap(NULL, msize + Page::kPageSize, prot,
Vyacheslav Egorov (Chromium) 2011/07/12 23:23:29 V8 uses "one argument per line" convention.
Cris Neckar 2011/07/14 17:32:28 Done.
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (mbase == MAP_FAILED) {
LOG(i::Isolate::Current(),
StringEvent("OS::Allocate", "mmap failed"));
return NULL;
}
*allocated = msize;
+ mprotect(mbase, Page::kPageSize, PROT_NONE);
+ mbase += Page::kPageSize;
Vyacheslav Egorov (Chromium) 2011/07/12 23:23:29 I am a bit concerned that we are spreading (and du
Cris Neckar 2011/07/14 17:32:28 Done.
UpdateAllocatedSpaceLimits(mbase, msize);
return mbase;
}
@@ -384,7 +387,7 @@
void OS::Free(void* address, const size_t size) {
// TODO(1240712): munmap has a return value which is ignored here.
- int result = munmap(address, size);
+ int result = munmap(address - Page::kPageSize, size + Page::kPageSize);
USE(result);
ASSERT(result == 0);
}
« no previous file with comments | « no previous file | src/platform-macos.cc » ('j') | src/platform-win32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698