Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/sys Use PROT_MPROTECT() (which would have bee...



details:   https://anonhg.NetBSD.org/src/rev/acc91cd3d3d7
branches:  trunk
changeset: 356100:acc91cd3d3d7
user:      kre <kre%NetBSD.org@localhost>
date:      Fri Sep 01 16:27:02 2017 +0000

description:
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.

diffstat:

 tests/lib/libc/sys/t_mincore.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r bd6c96a99705 -r acc91cd3d3d7 tests/lib/libc/sys/t_mincore.c
--- a/tests/lib/libc/sys/t_mincore.c    Fri Sep 01 15:19:59 2017 +0000
+++ b/tests/lib/libc/sys/t_mincore.c    Fri Sep 01 16:27:02 2017 +0000
@@ -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 @@
                    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 "



Home | Main Index | Thread Index | Old Index