Module Name:    src
Committed By:   pgoyette
Date:           Sat Mar 25 01:39:20 UTC 2017

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

Log Message:
Rather than ghecking system global state to see if mprotect might be
enabled, use the newly-committed sysctl proc.curproc.paxflags variable


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/sys/t_mprotect.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_mprotect.c
diff -u src/tests/lib/libc/sys/t_mprotect.c:1.5 src/tests/lib/libc/sys/t_mprotect.c:1.6
--- src/tests/lib/libc/sys/t_mprotect.c:1.5	Fri Mar 24 08:18:27 2017
+++ src/tests/lib/libc/sys/t_mprotect.c	Sat Mar 25 01:39:20 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mprotect.c,v 1.5 2017/03/24 08:18:27 martin Exp $ */
+/* $NetBSD: t_mprotect.c,v 1.6 2017/03/25 01:39:20 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_mprotect.c,v 1.5 2017/03/24 08:18:27 martin Exp $");
+__RCSID("$NetBSD: t_mprotect.c,v 1.6 2017/03/25 01:39:20 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/mman.h>
@@ -62,23 +62,16 @@ static bool
 paxinit(void)
 {
 	size_t len = sizeof(int);
-	int pax_global = -1;
-	int pax_enabled = -1;
+	int pax_flags;
 	int rv;
 
-	rv = sysctlbyname("security.pax.mprotect.global",
-	    &pax_global, &len, NULL, 0);
+	rv = sysctlbyname("proc.curproc.paxflags",
+	    &pax_flags, &len, NULL, 0);
 
 	if (rv != 0)
 		return false;
 
-	rv = sysctlbyname("security.pax.mprotect.enabled",
-	    &pax_enabled, &len, NULL, 0);
-
-	if (rv != 0)
-		return false;
-
-	return pax_global == 1 && pax_enabled == 1;
+	return ((pax_flags & CTL_PROC_PAXFLAGS_MPROTECT) != 0);
 }
 
 ATF_TC_WITH_CLEANUP(mprotect_access);

Reply via email to