A small code review. Reviewers: Michael Starzinger,
Message:
Hey Michi,
Here's the change we discussed offline to use PAGE_NOACCESS on Windows,
PTAL.
-- Benedikt
Description:
Use PAGE_NOACCESS for guard pages in Windows.
Up until now we used PAGE_GUARD for guard pages in Windows, which
will raise a STATUS_GUARD_PAGE_VIOLATION exception on first access
and grant regular access afterwards. This behavior is required to
implement automatic stack checking, or more generally to implement
applications that monitor the growth of large dynamic data structures.
However, this is not what we want for our guard pages, which are
used as a security mechanism. What we really want is PAGE_NOACCESS
here, which is the Windows-equivalent of PROT_NONE that we use on
all other platforms.
Please review this at
https://codereview.chromium.org/23458022/
SVN Base:
https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files +4, -4:
M src/platform-cygwin.cc
M src/platform-posix.cc
M src/platform-win32.cc
Index: src/platform-cygwin.cc
diff --git a/src/platform-cygwin.cc b/src/platform-cygwin.cc
index
10525d934584608f8987a298cc9e6cfc5b82e290..8873150fb974b1c0a4897406642497e7ad6002a0
100644
--- a/src/platform-cygwin.cc
+++ b/src/platform-cygwin.cc
@@ -375,7 +375,7 @@ bool VirtualMemory::Guard(void* address) {
if (NULL == VirtualAlloc(address,
OS::CommitPageSize(),
MEM_COMMIT,
- PAGE_READONLY | PAGE_GUARD)) {
+ PAGE_NOACCESS)) {
return false;
}
return true;
Index: src/platform-posix.cc
diff --git a/src/platform-posix.cc b/src/platform-posix.cc
index
504d140138c178fe50ff19480e20dcefd3db3a99..b111213f6d61783e217293061fa9d309a8206181
100644
--- a/src/platform-posix.cc
+++ b/src/platform-posix.cc
@@ -152,7 +152,7 @@ void OS::ProtectCode(void* address, const size_t size) {
void OS::Guard(void* address, const size_t size) {
#if defined(__CYGWIN__)
DWORD oldprotect;
- VirtualProtect(address, size, PAGE_READONLY | PAGE_GUARD, &oldprotect);
+ VirtualProtect(address, size, PAGE_NOACCESS, &oldprotect);
#else
mprotect(address, size, PROT_NONE);
#endif
Index: src/platform-win32.cc
diff --git a/src/platform-win32.cc b/src/platform-win32.cc
index
87387e7d12246aa2065c8bf35108bcee3dea8633..4b2004a382cfcaae7ca45aec4b5f0b58f5de149f
100644
--- a/src/platform-win32.cc
+++ b/src/platform-win32.cc
@@ -897,7 +897,7 @@ void OS::ProtectCode(void* address, const size_t size) {
void OS::Guard(void* address, const size_t size) {
DWORD oldprotect;
- VirtualProtect(address, size, PAGE_READONLY | PAGE_GUARD, &oldprotect);
+ VirtualProtect(address, size, PAGE_NOACCESS, &oldprotect);
}
@@ -1473,7 +1473,7 @@ bool VirtualMemory::Guard(void* address) {
if (NULL == VirtualAlloc(address,
OS::CommitPageSize(),
MEM_COMMIT,
- PAGE_READONLY | PAGE_GUARD)) {
+ PAGE_NOACCESS)) {
return false;
}
return true;