8012015: Use PROT_NONE when reserving memory

Reserved memory had PROT_READ+PROT_WRITE access on Linux/bsd, now changed to PROT_NONE.

Reviewed-by: dholmes, ctornqvi
This commit is contained in:
Mikael Vidstedt 2013-04-29 11:03:49 -07:00
parent c108e3a79f
commit 9e8a3585b0
5 changed files with 96 additions and 6 deletions

View file

@ -2906,9 +2906,10 @@ static char* anon_mmap(char* requested_addr, size_t bytes, bool fixed) {
flags |= MAP_FIXED;
}
// Map uncommitted pages PROT_READ and PROT_WRITE, change access
// to PROT_EXEC if executable when we commit the page.
addr = (char*)::mmap(requested_addr, bytes, PROT_READ|PROT_WRITE,
// Map reserved/uncommitted pages PROT_NONE so we fail early if we
// touch an uncommitted page. Otherwise, the read/write might
// succeed if we have enough swap space to back the physical page.
addr = (char*)::mmap(requested_addr, bytes, PROT_NONE,
flags, -1, 0);
if (addr != MAP_FAILED) {