diff src/os/bsd/vm/os_bsd.cpp @ 10157:f32b6c267d2e

8012015: Use PROT_NONE when reserving memory Summary: Reserved memory had PROT_READ+PROT_WRITE access on Linux/bsd, now changed to PROT_NONE. Reviewed-by: dholmes, ctornqvi
author mikael
date Mon, 29 Apr 2013 11:03:49 -0700
parents 8be1318fbe77
children 9ce110b1d14a
line wrap: on
line diff
--- a/src/os/bsd/vm/os_bsd.cpp	Mon Apr 29 16:36:17 2013 -0400
+++ b/src/os/bsd/vm/os_bsd.cpp	Mon Apr 29 11:03:49 2013 -0700
@@ -2080,9 +2080,10 @@
     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) {