summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2002-08-31 22:56:02 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2002-08-31 22:56:02 +0000
commit531a9f8317493da4fb9480f053564447122eafbd (patch)
treecb4a64f949b13ca37f56f8a9a3e4da26de574868
parentdae4b41c76cfa54cf5d55464c49b7ac86176378b (diff)
a combined non-exec test set.
allows reusing same testing code for: - text & mprotect (not finished, not enabled); - data, data & mprotect; - bss, bss & mprotect; - heap, heap & mprotect; - stack, stack & mprotect. also a test for mmaping pages in those areas and see how it allows execution (suggested by art@), not enabled yet. all tested on i386 and hppa.
-rw-r--r--regress/sys/kern/Makefile7
-rw-r--r--regress/sys/kern/noexec/Makefile48
-rw-r--r--regress/sys/kern/noexec/noexec.c206
-rw-r--r--regress/sys/kern/nxbss/Makefile13
-rw-r--r--regress/sys/kern/nxbss/nxbss.c61
-rw-r--r--regress/sys/kern/nxheap-mprotect/Makefile15
-rw-r--r--regress/sys/kern/nxheap-mprotect/nxheap-mprotect.c77
-rw-r--r--regress/sys/kern/nxheap/Makefile15
-rw-r--r--regress/sys/kern/nxheap/nxheap.c60
-rw-r--r--regress/sys/kern/nxstack-mprotect/Makefile15
-rw-r--r--regress/sys/kern/nxstack-mprotect/nxstack-mprotect.c71
-rw-r--r--regress/sys/kern/nxstack/Makefile15
-rw-r--r--regress/sys/kern/nxstack/nxstack.c55
13 files changed, 256 insertions, 402 deletions
diff --git a/regress/sys/kern/Makefile b/regress/sys/kern/Makefile
index d9fe464e026..ab08538f4eb 100644
--- a/regress/sys/kern/Makefile
+++ b/regress/sys/kern/Makefile
@@ -1,12 +1,9 @@
-# $OpenBSD: Makefile,v 1.38 2002/08/31 20:29:46 mickey Exp $
+# $OpenBSD: Makefile,v 1.39 2002/08/31 22:56:01 mickey Exp $
SUBDIR+= execve getrusage kqueue mmap mmap2 mmap3 dup2 minherit rlimit-file
SUBDIR+= fcntl_dup dup2_self pread preadv exit pwrite pwritev
SUBDIR+= syscall __syscall unfdpass accept nanosleep sysvmsg sysvsem
-SUBDIR+= sysvshm rfork gettimeofday signal exec_self
-SUBDIR+= nxstack nxstack-mprotect
-SUBDIR+= nxheap nxheap-mprotect
-SUBDIR+= nxbss
+SUBDIR+= sysvshm rfork gettimeofday signal exec_self noexec
install:
diff --git a/regress/sys/kern/noexec/Makefile b/regress/sys/kern/noexec/Makefile
new file mode 100644
index 00000000000..548ba25d7fa
--- /dev/null
+++ b/regress/sys/kern/noexec/Makefile
@@ -0,0 +1,48 @@
+# $OpenBSD: Makefile,v 1.1 2002/08/31 22:56:01 mickey Exp $
+
+.if ${MACHINE} == "sparc64" || ${MACHINE} == "sparc" || \
+ ${MACHINE} == "alpha" || ${MACHINE} == "macppc" || \
+ ${MACHINE} == "mvmeppc" || ${MACHINE} == "i386" || \
+ ${MACHINE} == "hppa"
+
+PROG= noexec
+CFLAGS+=-Wall -Werror
+LDSTATIC= ${STATIC}
+REGRESSTARGETS= nxtext-mprotect \
+ nxdata nxdata-mprotect \
+ nxbss nxbss-mprotect \
+ nxheap nxheap-mprotect \
+ nxstack nxstack-mprotect
+
+nxtext-mprotect: ${PROG}
+ #@./${PROG} -T -p
+
+nxdata: ${PROG}
+ @./${PROG} -D
+
+nxdata-mprotect: ${PROG}
+ @./${PROG} -D -p
+
+nxbss: ${PROG}
+ @./${PROG} -B
+
+nxbss-mprotect: ${PROG}
+ @./${PROG} -B -p
+
+nxheap: ${PROG}
+ @./${PROG} -H
+
+nxheap-mprotect: ${PROG}
+ @./${PROG} -H -p
+
+nxstack: ${PROG}
+ @./${PROG} -S
+
+nxstack-mprotect: ${PROG}
+ @./${PROG} -S -p
+
+.else
+REGRESSTARGETS= # this architecture has no test for this
+.endif
+
+.include <bsd.regress.mk>
diff --git a/regress/sys/kern/noexec/noexec.c b/regress/sys/kern/noexec/noexec.c
new file mode 100644
index 00000000000..a4041729582
--- /dev/null
+++ b/regress/sys/kern/noexec/noexec.c
@@ -0,0 +1,206 @@
+/* $OpenBSD: noexec.c,v 1.1 2002/08/31 22:56:01 mickey Exp $ */
+
+/*
+ * Copyright (c) 2002 Michael Shalayeff
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <signal.h>
+#include <string.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <errno.h>
+#include <err.h>
+
+volatile sig_atomic_t fail;
+int page_size;
+char label[64] = "non-exec ";
+
+#define PAD 64*1024
+#define TEST 256 /* assuming the testfly() will fit */
+u_int64_t data[PAD+TEST] = { 0 };
+u_int64_t bss[PAD+TEST];
+
+void
+testfly()
+{
+}
+
+void
+sigsegv(int sig, siginfo_t *sip, void *scp)
+{
+ _exit(fail);
+}
+
+int
+noexec(void *p, size_t size)
+{
+
+ fail = 0;
+ printf("%s: execute\n", label);
+ ((void (*)(void))p)();
+
+ return (1);
+}
+
+int
+noexec_mprotect(void *p, size_t size)
+{
+
+ /* here we must fail on segv since we said it gets executable */
+ fail = 1;
+ mprotect(p, size, PROT_READ|PROT_WRITE|PROT_EXEC);
+ printf("%s: execute\n", label);
+ ((void (*)(void))p)();
+
+ /* here we are successfull on segv and fail if it still executes */
+ fail = 0;
+ mprotect(p, size, PROT_READ|PROT_WRITE);
+ printf("%s: catch a signal\n", label);
+ ((void (*)(void))p)();
+
+ return (1);
+}
+
+void *
+getaddr(void *a)
+{
+ void *ret;
+
+ if ((void *)&ret < a)
+ ret = (void *)((u_long)&ret - 4 * page_size);
+ else
+ ret = (void *)((u_long)&ret + 4 * page_size);
+
+ return (void *)((u_long)ret & ~(page_size - 1));
+}
+
+int
+noexec_mmap(void *p, size_t size)
+{
+ void *addr;
+
+ /* here we must fail on segv since we said it gets executable */
+ fail = 1;
+ if ((addr = mmap(p, size, PROT_READ|PROT_WRITE|PROT_EXEC,
+ MAP_ANON|MAP_FIXED, -1, 0)) == MAP_FAILED)
+ err(1, "mmap");
+ printf("%s: execute\n", label);
+ ((void (*)(void))addr)();
+
+ exit(0);
+}
+
+void
+usage(void)
+{
+ extern char *__progname;
+ fprintf(stderr, "Usage: %s [-s <size>] -[TDBHS] [-p] [-m]\n",
+ __progname);
+ exit(2);
+}
+
+int
+main(int argc, char *argv[])
+{
+ u_int64_t stack[256]; /* assuming the testfly() will fit */
+ struct sigaction sa;
+ int (*func)(void *, size_t);
+ size_t size;
+ char *ep;
+ void *p;
+ int ch;
+
+ if ((page_size = sysconf(_SC_PAGESIZE)) < 0)
+ err(1, "sysconf");
+
+ p = NULL;
+ func = &noexec;
+ size = TEST;
+ while ((ch = getopt(argc, argv, "TDBHSmps")) != -1)
+ switch (ch) {
+ case 'T':
+ p = &testfly;
+ strcat(label, "text");
+ break;
+ case 'D':
+ p = &data[PAD];
+ strcat(label, "data");
+ break;
+ case 'B':
+ p = &bss[PAD];
+ strcat(label, "bss");
+ break;
+ case 'H':
+ p = malloc(TEST); /* XXX align? */
+ if (p == NULL)
+ err(2, "malloc");
+ strcat(label, "heap");
+ break;
+ case 'S':
+ p = &stack;
+ strcat(label, "stack");
+ break;
+ case 's': /* only valid for stack */
+ size = strtoul(optarg, &ep, 0);
+ if (size > ULONG_MAX)
+ errno = ERANGE;
+ if (errno)
+ err(1, "invalid size: %s", optarg);
+ if (*ep)
+ errx(1, "invalid size: %s", optarg);
+ break;
+ case 'm':
+ func = &noexec_mmap;
+ break;
+ case 'p':
+ func = &noexec_mprotect;
+ break;
+ default:
+ usage();
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (argc > 0)
+ usage();
+
+ if (p == NULL)
+ exit(2);
+
+ sa.sa_sigaction = &sigsegv;
+ sa.sa_flags = SA_SIGINFO;
+ sigemptyset(&sa.sa_mask);
+ sigaction(SIGSEGV, &sa, NULL);
+
+ memcpy(p, &testfly, TEST);
+
+ exit((*func)(p, size));
+}
diff --git a/regress/sys/kern/nxbss/Makefile b/regress/sys/kern/nxbss/Makefile
deleted file mode 100644
index d51974c6bd5..00000000000
--- a/regress/sys/kern/nxbss/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# $OpenBSD: Makefile,v 1.3 2002/07/26 01:52:02 deraadt Exp $
-
-.if ${MACHINE} == "sparc64" || ${MACHINE} == "sparc" || \
- ${MACHINE} == "alpha" || ${MACHINE} == "hppa"
-
-PROG= nxbss
-LDSTATIC= ${STATIC}
-
-.else
-REGRESSTARGETS= # this architecture has no test for this
-.endif
-
-.include <bsd.regress.mk>
diff --git a/regress/sys/kern/nxbss/nxbss.c b/regress/sys/kern/nxbss/nxbss.c
deleted file mode 100644
index e7fd7b8250a..00000000000
--- a/regress/sys/kern/nxbss/nxbss.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* $OpenBSD: nxbss.c,v 1.2 2002/07/26 23:30:42 deraadt Exp $ */
-
-/*
- * Copyright (c) 2002 Michael Shalayeff
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <stdio.h>
-#include <signal.h>
-#include <string.h>
-
-#define PAD 64*1024
-#define TEST 256
-u_int64_t buf[PAD+TEST]; /* assuming the testfly() will fit */
-
-void
-testfly()
-{
-}
-
-void
-sigsegv(int sig)
-{
- _exit(0);
-}
-
-int
-main(void)
-{
- void *p = &buf[PAD];
- signal(SIGSEGV, sigsegv);
-
- memcpy(p, &testfly, TEST);
- ((void (*)(void))p)();
- exit(1);
-}
diff --git a/regress/sys/kern/nxheap-mprotect/Makefile b/regress/sys/kern/nxheap-mprotect/Makefile
deleted file mode 100644
index 48aa0547e73..00000000000
--- a/regress/sys/kern/nxheap-mprotect/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# $OpenBSD: Makefile,v 1.1 2002/08/27 16:37:42 matthieu Exp $
-
-.if ${MACHINE} == "sparc64" || ${MACHINE} == "sparc" || \
- ${MACHINE} == "alpha" || ${MACHINE} == "macppc" || \
- ${MACHINE} == "mvmeppc" || ${MACHINE} == "i386" || \
- ${MACHINE} == "hppa"
-
-PROG= nxheap-mprotect
-LDSTATIC= ${STATIC}
-
-.else
-REGRESSTARGETS= # this architecture has no test for this
-.endif
-
-.include <bsd.regress.mk>
diff --git a/regress/sys/kern/nxheap-mprotect/nxheap-mprotect.c b/regress/sys/kern/nxheap-mprotect/nxheap-mprotect.c
deleted file mode 100644
index 60f1a84d376..00000000000
--- a/regress/sys/kern/nxheap-mprotect/nxheap-mprotect.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* $OpenBSD: nxheap-mprotect.c,v 1.3 2002/08/27 18:32:12 matthieu Exp $ */
-
-/*
- * Copyright (c) 2002 Michael Shalayeff
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <stdio.h>
-#include <signal.h>
-#include <string.h>
-#include <stdlib.h>
-
-#define SIZE 256 /* assuming the testfly() will fit */
-
-
-volatile sig_atomic_t fail;
-
-void
-testfly()
-{
-}
-
-void
-sigsegv(int sig)
-{
- _exit(fail);
-}
-
-int
-main(void)
-{
- u_int64_t *buf;
-
- buf = (u_int64_t *)malloc(SIZE);
-
- signal(SIGSEGV, sigsegv);
- memcpy(buf, &testfly, SIZE);
-
- printf("making it execute\n");
- /* here we must fail on segv since we said it gets executable */
- fail = 1;
- mprotect(buf, sizeof(buf), PROT_READ|PROT_WRITE|PROT_EXEC);
- ((void (*)(void))buf)();
-
- printf("making it catch a signal\n");
- /* here we are successfull on segv and fail if it still executes */
- fail = 0;
- mprotect(buf, sizeof(buf), PROT_READ|PROT_WRITE);
- ((void (*)(void))buf)();
-
- exit(1);
-}
diff --git a/regress/sys/kern/nxheap/Makefile b/regress/sys/kern/nxheap/Makefile
deleted file mode 100644
index af83e7b3847..00000000000
--- a/regress/sys/kern/nxheap/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# $OpenBSD: Makefile,v 1.1 2002/08/31 20:29:47 mickey Exp $
-
-.if ${MACHINE} == "sparc64" || ${MACHINE} == "sparc" || \
- ${MACHINE} == "alpha" || ${MACHINE} == "macppc" || \
- ${MACHINE} == "mvmeppc" || ${MACHINE} == "i386" || \
- ${MACHINE} == "hppa"
-
-PROG= nxheap
-LDSTATIC= ${STATIC}
-
-.else
-REGRESSTARGETS= # this architecture has no test for this
-.endif
-
-.include <bsd.regress.mk>
diff --git a/regress/sys/kern/nxheap/nxheap.c b/regress/sys/kern/nxheap/nxheap.c
deleted file mode 100644
index 9502c69e7fb..00000000000
--- a/regress/sys/kern/nxheap/nxheap.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/* $OpenBSD: nxheap.c,v 1.1 2002/08/31 20:29:47 mickey Exp $ */
-
-/*
- * Copyright (c) 2002 Michael Shalayeff
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <signal.h>
-#include <string.h>
-
-#define SIZE 256 /* assuming the testfly() will fit */
-
-void
-testfly()
-{
-}
-
-void
-sigsegv(int sig)
-{
- _exit(0);
-}
-
-int
-main(void)
-{
- u_int64_t *buf;
-
- buf = (u_int64_t *)malloc(SIZE);
-
- signal(SIGSEGV, sigsegv);
- memcpy(buf, &testfly, SIZE);
-
- ((void (*)(void))buf)();
- exit(1);
-}
diff --git a/regress/sys/kern/nxstack-mprotect/Makefile b/regress/sys/kern/nxstack-mprotect/Makefile
deleted file mode 100644
index ce55a4704a7..00000000000
--- a/regress/sys/kern/nxstack-mprotect/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# $OpenBSD: Makefile,v 1.2 2002/07/27 08:01:31 deraadt Exp $
-
-.if ${MACHINE} == "sparc64" || ${MACHINE} == "sparc" || \
- ${MACHINE} == "alpha" || ${MACHINE} == "macppc" || \
- ${MACHINE} == "mvmeppc" || ${MACHINE} == "i386" || \
- ${MACHINE} == "hppa"
-
-PROG= nxstack-mprotect
-LDSTATIC= ${STATIC}
-
-.else
-REGRESSTARGETS= # this architecture has no test for this
-.endif
-
-.include <bsd.regress.mk>
diff --git a/regress/sys/kern/nxstack-mprotect/nxstack-mprotect.c b/regress/sys/kern/nxstack-mprotect/nxstack-mprotect.c
deleted file mode 100644
index 94ccd078624..00000000000
--- a/regress/sys/kern/nxstack-mprotect/nxstack-mprotect.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/* $OpenBSD: nxstack-mprotect.c,v 1.1 2002/07/27 06:52:37 mickey Exp $ */
-
-/*
- * Copyright (c) 2002 Michael Shalayeff
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <stdio.h>
-#include <signal.h>
-#include <string.h>
-
-volatile sig_atomic_t fail;
-
-void
-testfly()
-{
-}
-
-void
-sigsegv(int sig)
-{
- _exit(fail);
-}
-
-int
-main(void)
-{
- u_int64_t buf[256]; /* assuming the testfly() will fit */
-
- signal(SIGSEGV, sigsegv);
- memcpy(buf, &testfly, sizeof(buf));
-
- printf("making it execute\n");
- /* here we must fail on segv since we said it gets executable */
- fail = 1;
- mprotect(buf, sizeof(buf), PROT_READ|PROT_WRITE|PROT_EXEC);
- ((void (*)(void))&buf)();
-
- printf("making it catch a signal\n");
- /* here we are successfull on segv and fail if it still executes */
- fail = 0;
- mprotect(buf, sizeof(buf), PROT_READ|PROT_WRITE);
- ((void (*)(void))&buf)();
-
- exit(1);
-}
diff --git a/regress/sys/kern/nxstack/Makefile b/regress/sys/kern/nxstack/Makefile
deleted file mode 100644
index 124e99060e0..00000000000
--- a/regress/sys/kern/nxstack/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# $OpenBSD: Makefile,v 1.3 2002/07/26 01:52:02 deraadt Exp $
-
-.if ${MACHINE} == "sparc64" || ${MACHINE} == "sparc" || \
- ${MACHINE} == "alpha" || ${MACHINE} == "macppc" || \
- ${MACHINE} == "mvmeppc" || ${MACHINE} == "i386" || \
- ${MACHINE} == "hppa"
-
-PROG= nxstack
-LDSTATIC= ${STATIC}
-
-.else
-REGRESSTARGETS= # this architecture has no test for this
-.endif
-
-.include <bsd.regress.mk>
diff --git a/regress/sys/kern/nxstack/nxstack.c b/regress/sys/kern/nxstack/nxstack.c
deleted file mode 100644
index 83c64b31599..00000000000
--- a/regress/sys/kern/nxstack/nxstack.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/* $OpenBSD: nxstack.c,v 1.2 2002/07/01 19:37:57 art Exp $ */
-
-/*
- * Copyright (c) 2002 Michael Shalayeff
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <signal.h>
-#include <string.h>
-
-void
-testfly()
-{
-}
-
-void
-sigsegv(int sig)
-{
- _exit(0);
-}
-
-int
-main(void)
-{
- u_int64_t buf[256]; /* assuming the testfly() will fit */
-
- signal(SIGSEGV, sigsegv);
- memcpy(buf, &testfly, sizeof(buf));
- ((void (*)(void))&buf)();
- exit(1);
-}