Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Use PAGE_NOACCESS for guard pages in Windows.
Browse files Browse the repository at this point in the history
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.

R=cdn@chromium.org

Review URL: https://codereview.chromium.org/23458022

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16604 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
  • Loading branch information
bmeurer@chromium.org committed Sep 10, 2013
1 parent 9f56581 commit 24a0cab
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/platform-cygwin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ bool VirtualMemory::Guard(void* address) {
if (NULL == VirtualAlloc(address,
OS::CommitPageSize(),
MEM_COMMIT,
PAGE_READONLY | PAGE_GUARD)) {
PAGE_NOACCESS)) {
return false;
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/platform-posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/platform-win32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,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);
}


Expand Down Expand Up @@ -1441,7 +1441,7 @@ bool VirtualMemory::Guard(void* address) {
if (NULL == VirtualAlloc(address,
OS::CommitPageSize(),
MEM_COMMIT,
PAGE_READONLY | PAGE_GUARD)) {
PAGE_NOACCESS)) {
return false;
}
return true;
Expand Down

0 comments on commit 24a0cab

Please sign in to comment.