summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/lib/libc/sys/t_mprotect.c
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2016-12-05 15:52:27 -0200
committerRenato Botelho <renato@netgate.com>2016-12-05 15:52:27 -0200
commitec84a59afa973e7e021ba2ae8ecae4cb6ba37b1d (patch)
treed7d40ac77bda3d6fc35814a1a6484eb324b3c7df /contrib/netbsd-tests/lib/libc/sys/t_mprotect.c
parentca825f0a56d174ca9d3478d87cdca9f318a50cc6 (diff)
parent356fbc072920d7e71c42b310d6bfa2d1a3d36f9f (diff)
downloadFreeBSD-src-ec84a59afa973e7e021ba2ae8ecae4cb6ba37b1d.zip
FreeBSD-src-ec84a59afa973e7e021ba2ae8ecae4cb6ba37b1d.tar.gz
Merge remote-tracking branch 'origin/stable/11' into devel-11
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