diff options
Diffstat (limited to 'regress')
-rw-r--r-- | regress/sys/kern/tame/Makefile | 6 | ||||
-rw-r--r-- | regress/sys/kern/tame/sigabrt/Makefile | 11 | ||||
-rw-r--r-- | regress/sys/kern/tame/sigabrt/sigabrt.c | 48 | ||||
-rw-r--r-- | regress/sys/kern/tame/sigabrt/sigabrt.out | 2 | ||||
-rw-r--r-- | regress/sys/kern/tame/sigkill/Makefile | 11 | ||||
-rw-r--r-- | regress/sys/kern/tame/sigkill/sigkill.c | 49 | ||||
-rw-r--r-- | regress/sys/kern/tame/sigkill/sigkill.out | 2 |
7 files changed, 129 insertions, 0 deletions
diff --git a/regress/sys/kern/tame/Makefile b/regress/sys/kern/tame/Makefile new file mode 100644 index 00000000000..d6100f1e1f3 --- /dev/null +++ b/regress/sys/kern/tame/Makefile @@ -0,0 +1,6 @@ +# $OpenBSD: Makefile,v 1.1 2015/07/27 18:03:36 semarie Exp $ + +SUBDIR += sigabrt +SUBDIR += sigkill + +.include <bsd.subdir.mk> diff --git a/regress/sys/kern/tame/sigabrt/Makefile b/regress/sys/kern/tame/sigabrt/Makefile new file mode 100644 index 00000000000..cba94fef7f3 --- /dev/null +++ b/regress/sys/kern/tame/sigabrt/Makefile @@ -0,0 +1,11 @@ +# $OpenBSD: Makefile,v 1.1 2015/07/27 18:03:36 semarie Exp $ +PROG= sigabrt +NOMAN= yes + +run-regress-${PROG}: ${PROG} + rm -f ./${PROG}.core + if ./${PROG}; then false; else true; fi + if [ ! -e ./${PROG}.core ]; then echo "No coredump"; false; fi + ./${PROG} | diff -I OpenBSD -u ${.CURDIR}/${PROG}.out - + +.include <bsd.regress.mk> diff --git a/regress/sys/kern/tame/sigabrt/sigabrt.c b/regress/sys/kern/tame/sigabrt/sigabrt.c new file mode 100644 index 00000000000..8b6d501f88e --- /dev/null +++ b/regress/sys/kern/tame/sigabrt/sigabrt.c @@ -0,0 +1,48 @@ +/* $OpenBSD: sigabrt.c,v 1.1 2015/07/27 18:03:36 semarie Exp $ */ +/* + * Copyright (c) 2015 Sebastien Marie <semarie@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/tame.h> + +#include <stdio.h> +#include <stdlib.h> +#include <signal.h> + +void +handler(int sigraised) +{ + /* this handler shouldn't not be called */ + printf("forbidden STDIO in SIGABRT handler\n"); +} + +int +main(int argc, char *argv[]) +{ + /* install SIGABRT handler */ + signal(SIGABRT, &handler); + + printf("permitted STDIO\n"); + fflush(stdout); + + tame(TAME_ABORT); + + /* this will triggered tame_fail() */ + printf("forbidden STDIO 1\n"); + + /* shouldn't continue */ + printf("forbidden STDIO 2\n"); + return (EXIT_SUCCESS); +} diff --git a/regress/sys/kern/tame/sigabrt/sigabrt.out b/regress/sys/kern/tame/sigabrt/sigabrt.out new file mode 100644 index 00000000000..7c93c1299f3 --- /dev/null +++ b/regress/sys/kern/tame/sigabrt/sigabrt.out @@ -0,0 +1,2 @@ +$OpenBSD: sigabrt.out,v 1.1 2015/07/27 18:03:36 semarie Exp $ +permitted STDIO diff --git a/regress/sys/kern/tame/sigkill/Makefile b/regress/sys/kern/tame/sigkill/Makefile new file mode 100644 index 00000000000..86910e48f01 --- /dev/null +++ b/regress/sys/kern/tame/sigkill/Makefile @@ -0,0 +1,11 @@ +# $OpenBSD: Makefile,v 1.1 2015/07/27 18:03:36 semarie Exp $ +PROG= sigkill +NOMAN= yes + +run-regress-${PROG}: ${PROG} + rm -f ./${PROG}.core + if ./${PROG}; then false; else true; fi + if [ -e ./${PROG}.core ]; then echo "Unexpected coredump"; false; fi + ./${PROG} | diff -I OpenBSD -u ${.CURDIR}/${PROG}.out - + +.include <bsd.regress.mk> diff --git a/regress/sys/kern/tame/sigkill/sigkill.c b/regress/sys/kern/tame/sigkill/sigkill.c new file mode 100644 index 00000000000..c423393e35a --- /dev/null +++ b/regress/sys/kern/tame/sigkill/sigkill.c @@ -0,0 +1,49 @@ +/* $OpenBSD: sigkill.c,v 1.1 2015/07/27 18:03:36 semarie Exp $ */ +/* + * Copyright (c) 2015 Sebastien Marie <semarie@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/tame.h> + +#include <stdio.h> +#include <stdlib.h> +#include <signal.h> + +void +handler(int sigraised) +{ + /* the handler shouldn't not be called */ + printf("forbidden STDIO in %d handler\n", sigraised); +} + +int +main(int argc, char *argv[]) +{ + /* install some handlers */ + signal(SIGHUP, &handler); + signal(SIGABRT, &handler); + + printf("permitted STDIO\n"); + fflush(stdout); + + tame(0); + + /* this will triggered tame_fail() */ + printf("forbidden STDIO 1\n"); + + /* shouldn't continue */ + printf("forbidden STDIO 2\n"); + return (EXIT_SUCCESS); +} diff --git a/regress/sys/kern/tame/sigkill/sigkill.out b/regress/sys/kern/tame/sigkill/sigkill.out new file mode 100644 index 00000000000..d593f6ee318 --- /dev/null +++ b/regress/sys/kern/tame/sigkill/sigkill.out @@ -0,0 +1,2 @@ +$OpenBSD: sigkill.out,v 1.1 2015/07/27 18:03:36 semarie Exp $ +permitted STDIO |