summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2016-09-24 07:26:15 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2016-09-24 07:26:15 +0000
commitf6ef2dc3461904995c16fcd9d2f188a4543f0082 (patch)
tree1e3fcf7692d37b217b75ad18b70e9fe0e7ca92dc /regress
parent5cf280d1e646627dcfb53cfc999126f2f9b9c42c (diff)
recpect W^X, sparc64 still has a problem: non-exec mmap: execute
#1 is done, the others not. ok kettenis@ millert@
Diffstat (limited to 'regress')
-rw-r--r--regress/sys/kern/noexec/noexec.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/regress/sys/kern/noexec/noexec.c b/regress/sys/kern/noexec/noexec.c
index 65be84475cf..6d8b047457a 100644
--- a/regress/sys/kern/noexec/noexec.c
+++ b/regress/sys/kern/noexec/noexec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: noexec.c,v 1.15 2014/04/18 14:38:21 guenther Exp $ */
+/* $OpenBSD: noexec.c,v 1.16 2016/09/24 07:26:14 otto Exp $ */
/*
* Copyright (c) 2002,2003 Michael Shalayeff
@@ -135,6 +135,8 @@ noexec_mmap(void *p, size_t size)
memcpy(p + page_size * 2, p, page_size);
fdcache(p + page_size * 1, TESTSZ);
fdcache(p + page_size * 2, TESTSZ);
+ if (mprotect(p, size + 2 * page_size, PROT_READ|PROT_EXEC) != 0)
+ err(1, "mprotect");
/* here we must fail on segv since we said it gets executable */
fail = 1;
@@ -242,7 +244,7 @@ main(int argc, char *argv[])
(void) strlcat(label, "-mmap", sizeof(label));
} else {
if ((ptr = mmap(p, size + 2 * page_size,
- PROT_READ|PROT_WRITE|PROT_EXEC,
+ PROT_READ|PROT_WRITE,
MAP_ANON, -1, 0)) == MAP_FAILED)
err(1, "mmap");
func = &noexec_mmap;