summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/lib/libc/sys/t_mprotect.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/netbsd-tests/lib/libc/sys/t_mprotect.c')
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_mprotect.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_mprotect.c b/contrib/netbsd-tests/lib/libc/sys/t_mprotect.c
index ee345aa..5dc3eae 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_mprotect.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_mprotect.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mprotect.c,v 1.3 2011/07/20 22:53:44 jym Exp $ */
+/* $NetBSD: t_mprotect.c,v 1.4 2016/05/28 14:34:49 christos 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.3 2011/07/20 22:53:44 jym Exp $");
+__RCSID("$NetBSD: t_mprotect.c,v 1.4 2016/05/28 14:34:49 christos Exp $");
#include <sys/param.h>
#include <sys/mman.h>
@@ -78,10 +78,7 @@ paxinit(void)
rv = sysctlbyname("security.pax.mprotect.enabled",
&pax_enabled, &len, NULL, 0);
- if (rv != 0)
- return false;
-
- return paxset(1, 1);
+ return rv == 0;
}
static bool
@@ -194,6 +191,12 @@ ATF_TC_BODY(mprotect_exec, tc)
break;
}
+ if (!paxinit())
+ return;
+ if (pax_enabled == 1 && pax_global == 1)
+ atf_tc_skip("PaX MPROTECT restrictions enabled");
+
+
/*
* Map a page read/write and copy a trivial assembly function inside.
* We will then change the mapping rights:
@@ -262,7 +265,7 @@ ATF_TC_BODY(mprotect_pax, tc)
size_t i;
int rv;
- if (paxinit() != true)
+ if (!paxinit() || !paxset(1, 1))
return;
/*
OpenPOWER on IntegriCloud