Module Name:    src
Committed By:   kre
Date:           Fri Sep  1 16:27:02 UTC 2017

Modified Files:
        src/tests/lib/libc/sys: t_mincore.c

Log Message:
Use PROT_MPROTECT() (which would have been better had it been called
PROT_MAXPROTECT or PROT_ALLOWPROTECT or something) on the mmap() call
which specifies PROT_NONE, and which we later want to change to PROT_READ,
otherwise when PAX is enabled, the mprotect() will fail.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libc/sys/t_mincore.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libc/sys/t_mincore.c
diff -u src/tests/lib/libc/sys/t_mincore.c:1.11 src/tests/lib/libc/sys/t_mincore.c:1.12
--- src/tests/lib/libc/sys/t_mincore.c:1.11	Tue May 23 16:01:46 2017
+++ src/tests/lib/libc/sys/t_mincore.c	Fri Sep  1 16:27:02 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mincore.c,v 1.11 2017/05/23 16:01:46 christos Exp $ */
+/* $NetBSD: t_mincore.c,v 1.12 2017/09/01 16:27:02 kre Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_mincore.c,v 1.11 2017/05/23 16:01:46 christos Exp $");
+__RCSID("$NetBSD: t_mincore.c,v 1.12 2017/09/01 16:27:02 kre Exp $");
 
 #include <sys/mman.h>
 #include <sys/stat.h>
@@ -231,7 +231,8 @@ ATF_TC_BODY(mincore_resid, tc)
 		    resident, npgs);
 
 	addr2 = mmap(NULL, npgs * page, PROT_READ, MAP_ANON, -1, (off_t)0);
-	addr3 = mmap(NULL, npgs * page, PROT_NONE, MAP_ANON, -1, (off_t)0);
+	addr3 = mmap(NULL, npgs * page, PROT_MPROTECT(PROT_READ) | PROT_NONE,
+	    MAP_ANON, -1, (off_t)0);
 
 	if (addr2 == MAP_FAILED || addr3 == MAP_FAILED)
 		atf_tc_skip("could not mmap more anonymous test pages with "

Reply via email to