summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2019-01-31 19:14:13 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2019-01-31 19:14:13 +0000
commit1676e6495620027a2512a4343589fe8d4f01815a (patch)
tree719fbeef5f896c54e9fbc917659837227263ff5b
parenta2fba35ac68224d9980c75981ec79cb2f3e1e1d9 (diff)
Instead of skipping the text mmap test, do a non fixed mmap in this
case. This gives us another test case. Make error messages more verbose. Fix white spaces.
-rw-r--r--regress/sys/kern/noexec/Makefile19
-rw-r--r--regress/sys/kern/noexec/noexec.c20
-rw-r--r--regress/sys/kern/noexec/testfly.S6
3 files changed, 31 insertions, 14 deletions
diff --git a/regress/sys/kern/noexec/Makefile b/regress/sys/kern/noexec/Makefile
index 4438dd6614c..cbfe35e27c0 100644
--- a/regress/sys/kern/noexec/Makefile
+++ b/regress/sys/kern/noexec/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.18 2018/09/12 11:59:40 kettenis Exp $
+# $OpenBSD: Makefile,v 1.19 2019/01/31 19:14:12 bluhm Exp $
PROG= noexec
SRCS= noexec.c testfly.S
@@ -11,55 +11,70 @@ REGRESS_TARGETS= nxtext-mmap nxtext-mprotect \
nxheap nxheap-mmap nxheap-mprotect \
nxmmap nxmmap-mprotect \
nxstack nxstack-mmap nxstack-mprotect
-REGRESS_SKIP_TARGETS+= nxtext-mmap
.PHONY: ${REGRESS_TARGETS}
nxtext-mmap: ${PROG}
+ @echo '\n====== $@ ======'
./${PROG} -T -m
nxtext-mprotect: ${PROG}
+ @echo '\n====== $@ ======'
./${PROG} -T -p
nxdata: ${PROG}
+ @echo '\n====== $@ ======'
./${PROG} -D
nxdata-mprotect: ${PROG}
+ @echo '\n====== $@ ======'
./${PROG} -D -p
nxdata-mmap: ${PROG}
+ @echo '\n====== $@ ======'
./${PROG} -D -m
nxbss: ${PROG}
+ @echo '\n====== $@ ======'
./${PROG} -B
nxbss-mmap: ${PROG}
+ @echo '\n====== $@ ======'
./${PROG} -B -m
nxbss-mprotect: ${PROG}
+ @echo '\n====== $@ ======'
./${PROG} -B -p
nxheap: ${PROG}
+ @echo '\n====== $@ ======'
./${PROG} -H
nxheap-mmap: ${PROG}
+ @echo '\n====== $@ ======'
./${PROG} -H -m
nxheap-mprotect: ${PROG}
+ @echo '\n====== $@ ======'
./${PROG} -H -p
nxstack: ${PROG}
+ @echo '\n====== $@ ======'
./${PROG} -S
nxstack-mmap: ${PROG}
+ @echo '\n====== $@ ======'
./${PROG} -S -m
nxstack-mprotect: ${PROG}
+ @echo '\n====== $@ ======'
./${PROG} -S -p
nxmmap: ${PROG}
+ @echo '\n====== $@ ======'
./${PROG} -m
nxmmap-mprotect: ${PROG}
+ @echo '\n====== $@ ======'
./${PROG} -m -p
.if ${MACHINE} != "alpha" && \
diff --git a/regress/sys/kern/noexec/noexec.c b/regress/sys/kern/noexec/noexec.c
index 6d24484bd75..4a854630f99 100644
--- a/regress/sys/kern/noexec/noexec.c
+++ b/regress/sys/kern/noexec/noexec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: noexec.c,v 1.18 2018/05/23 19:22:54 bluhm Exp $ */
+/* $OpenBSD: noexec.c,v 1.19 2019/01/31 19:14:12 bluhm Exp $ */
/*
* Copyright (c) 2002,2003 Michael Shalayeff
@@ -204,6 +204,7 @@ main(int argc, char *argv[])
switch (ch) {
case 'T':
p = &testfly;
+ pflags &=~ MAP_FIXED;
(void) strlcat(label, "text", sizeof(label));
continue;
case 'D':
@@ -243,19 +244,20 @@ main(int argc, char *argv[])
switch (ch) {
case 'm':
if (p) {
- if ((ptr = mmap(p, size + 2 * page_size,
- PROT_READ|PROT_WRITE,
- pflags, -1, 0)) == MAP_FAILED)
- err(1, "mmap");
(void) strlcat(label, "-mmap", sizeof(label));
} else {
- if ((ptr = mmap(p, size + 2 * page_size,
- PROT_READ|PROT_WRITE,
- MAP_ANON, -1, 0)) == MAP_FAILED)
- err(1, "mmap");
+ pflags = MAP_ANON;
func = &noexec_mmap;
(void) strlcat(label, "mmap", sizeof(label));
}
+ ptr = mmap(p, size + 2 * page_size,
+ PROT_READ|PROT_WRITE, pflags, -1, 0LL);
+ if (ptr == MAP_FAILED) {
+ err(1, "mmap: addr %p, len %zu, prot %d, "
+ "flags %d, fd %d, offset %lld",
+ p, size + 2 * page_size,
+ PROT_READ|PROT_WRITE, pflags, -1, 0LL);
+ }
p = ptr;
break;
case 'p':
diff --git a/regress/sys/kern/noexec/testfly.S b/regress/sys/kern/noexec/testfly.S
index f54e56cf777..02ae56b4dba 100644
--- a/regress/sys/kern/noexec/testfly.S
+++ b/regress/sys/kern/noexec/testfly.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: testfly.S,v 1.5 2018/09/12 11:59:40 kettenis Exp $ */
+/* $OpenBSD: testfly.S,v 1.6 2019/01/31 19:14:12 bluhm Exp $ */
/*
* Copyright (c) 2002,2003 Michael Shalayeff
@@ -61,8 +61,8 @@ END(testfly)
#if defined(__sparc64__)
ENTRY(testfly)
retl
- nop
+ nop
END(testfly)
#endif
-
+
.space 8192