summaryrefslogtreecommitdiff
path: root/regress/sys
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2002-07-01 18:15:52 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2002-07-01 18:15:52 +0000
commit19682fa3d8e13fc94286ca2aa8ac87030bf8eda2 (patch)
tree796b0d662ac0bf755f639ffe5b33c3d973a869e3 /regress/sys
parent5b599e0094027239ac02006e286e1edf947b8de2 (diff)
a test to see if stack is executable
Diffstat (limited to 'regress/sys')
-rw-r--r--regress/sys/kern/nxstack/Makefile6
-rw-r--r--regress/sys/kern/nxstack/nxstack.c54
2 files changed, 60 insertions, 0 deletions
diff --git a/regress/sys/kern/nxstack/Makefile b/regress/sys/kern/nxstack/Makefile
new file mode 100644
index 00000000000..ef09bf99338
--- /dev/null
+++ b/regress/sys/kern/nxstack/Makefile
@@ -0,0 +1,6 @@
+# $OpenBSD: Makefile,v 1.1 2002/07/01 18:15:51 mickey Exp $
+
+PROG= nxstack
+LDSTATIC= ${STATIC}
+
+.include <bsd.regress.mk>
diff --git a/regress/sys/kern/nxstack/nxstack.c b/regress/sys/kern/nxstack/nxstack.c
new file mode 100644
index 00000000000..d8584c1dae7
--- /dev/null
+++ b/regress/sys/kern/nxstack/nxstack.c
@@ -0,0 +1,54 @@
+/* $OpenBSD: nxstack.c,v 1.1 2002/07/01 18:15:51 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>
+
+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);
+}