summaryrefslogtreecommitdiff
path: root/regress/sys/kern
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2017-02-19 19:59:13 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2017-02-19 19:59:13 +0000
commita6716fde212083ccc166a423de6b48f2f1d74560 (patch)
treec1e9505d8e5ab18ff1345f04420b8ad5abdd6076 /regress/sys/kern
parent854541e5787e18564071f9a86a584881e1b7819d (diff)
Clean up regress/sys/kern/pledge/generic tests: many tests failed because
wlpaths is disabled in GENERIC kernels: remove or disable failing test cases. Also remove the test_mmap() function testing the prot_exec promise since it would need to be run on a wxallowed partition. from semarie
Diffstat (limited to 'regress/sys/kern')
-rw-r--r--regress/sys/kern/pledge/generic/main.c40
-rw-r--r--regress/sys/kern/pledge/generic/manager.c8
-rw-r--r--regress/sys/kern/pledge/generic/tests.out75
3 files changed, 15 insertions, 108 deletions
diff --git a/regress/sys/kern/pledge/generic/main.c b/regress/sys/kern/pledge/generic/main.c
index 3297d590b87..76a555402e3 100644
--- a/regress/sys/kern/pledge/generic/main.c
+++ b/regress/sys/kern/pledge/generic/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.8 2015/10/30 07:24:20 semarie Exp $ */
+/* $OpenBSD: main.c,v 1.9 2017/02/19 19:59:12 tb Exp $ */
/*
* Copyright (c) 2015 Sebastien Marie <semarie@openbsd.org>
*
@@ -61,6 +61,7 @@ test_kill()
kill(0, SIGINT);
}
+#ifdef WLPATHS
static void
open_close(const char *filename)
{
@@ -96,16 +97,16 @@ test_wpaths()
printf("\n");
exit(EXIT_SUCCESS);
}
+#endif
static void
test_pledge()
{
- const char *wpaths[] = { "/sbin", NULL };
-
- if (pledge("stdio rpath", wpaths) != 0)
+ if (pledge("stdio rpath", NULL) != 0)
_exit(errno);
}
+#ifdef WLPATHS
static void
do_stat(const char *path)
{
@@ -150,25 +151,7 @@ test_stat()
printf("\n");
exit(EXIT_SUCCESS);
}
-
-static void
-test_mmap()
-{
- int fd;
- void * data;
-
- if ((fd = open("/dev/zero", O_RDONLY, 0)) == -1)
- _exit(errno);
-
- data = mmap(NULL, 4096, PROT_READ|PROT_WRITE|PROT_EXEC,
- MAP_FILE|MAP_SHARED, fd, 0);
-
- if (data == MAP_FAILED)
- _exit(errno);
-
- munmap(data, 4096);
- close(fd);
-}
+#endif
static void
test_rpath()
@@ -247,6 +230,7 @@ main(int argc, char *argv[])
start_test(&ret, "stdio wpath", NULL, test_wpath);
start_test(&ret, "cpath", NULL, test_cpath);
+#if WLPATHS
/*
* test whitelist path
*/
@@ -261,6 +245,7 @@ main(int argc, char *argv[])
start_test1(&ret, "stdio rpath", "generic", test_wpaths);
start_test1(&ret, "stdio rpath", "", test_wpaths);
start_test1(&ret, "stdio rpath", ".", test_wpaths);
+#endif
/*
* test pledge(2) arguments
@@ -269,20 +254,15 @@ main(int argc, char *argv[])
start_test(&ret, "stdio rpath", NULL, test_pledge);
/* reduce request */
start_test(&ret, "stdio rpath wpath", NULL, test_pledge);
- /* reduce request (with same/other wpaths) */
- start_test1(&ret, "stdio rpath wpath", "/sbin", test_pledge);
- start_test1(&ret, "stdio rpath wpath", "/", test_pledge);
/* add request */
start_test(&ret, "stdio", NULL, test_pledge);
/* change request */
start_test(&ret, "stdio unix", NULL, test_pledge);
/* test stat(2) */
+#if WLPATHS
start_test1(&ret, "stdio rpath", "/usr/share/man", test_stat);
-
- /* mmap */
- start_test1(&ret, "stdio rpath prot_exec", "/dev/zero", test_mmap);
- start_test1(&ret, "stdio rpath", "/dev/zero", test_mmap);
+#endif
/* stdio */
start_test(&ret, NULL, NULL, test_request_stdio);
diff --git a/regress/sys/kern/pledge/generic/manager.c b/regress/sys/kern/pledge/generic/manager.c
index 334d9238097..451a3ecc088 100644
--- a/regress/sys/kern/pledge/generic/manager.c
+++ b/regress/sys/kern/pledge/generic/manager.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: manager.c,v 1.4 2015/10/23 18:50:54 mmcc Exp $ */
+/* $OpenBSD: manager.c,v 1.5 2017/02/19 19:59:12 tb Exp $ */
/*
* Copyright (c) 2015 Sebastien Marie <semarie@openbsd.org>
*
@@ -128,8 +128,8 @@ grab_syscall(pid_t pid)
const char *errstr = NULL;
char *c;
/* truncate at first no-number */
- for (c = line + searchlen; (*c != '\0') && isdigit((unsigned char)*c);
- c++)
+ for (c = line + searchlen;
+ (*c != '\0') && isdigit((unsigned char)*c); c++)
;
*c = '\0';
@@ -195,7 +195,7 @@ _start_test(int *ret, const char *test_name, const char *request,
printf("NULL)");
} else
printf("skip");
-
+
/* unlink previous coredump (if exists) */
if (clear_coredump(ret, test_name) == -1)
return;
diff --git a/regress/sys/kern/pledge/generic/tests.out b/regress/sys/kern/pledge/generic/tests.out
index 6118824de9e..0a4be8c28b6 100644
--- a/regress/sys/kern/pledge/generic/tests.out
+++ b/regress/sys/kern/pledge/generic/tests.out
@@ -1,4 +1,4 @@
-# $OpenBSD: tests.out,v 1.12 2016/01/09 06:13:43 semarie Exp $
+# $OpenBSD: tests.out,v 1.13 2017/02/19 19:59:12 tb Exp $
test(test_nop): pledge=("",NULL) status=0 exit=0
test(test_inet): pledge=("",NULL) status=134 signal=6 coredump=present pledged_syscall=97
test(test_inet): pledge=("abort",NULL) status=5632 exit=22 (errno: "Invalid argument")
@@ -10,82 +10,9 @@ test(test_kill): pledge=("stdio",NULL) status=2 signal=2 pledged_syscall=not_fou
test(test_rpath): pledge=("stdio rpath",NULL) status=0 exit=0
test(test_wpath): pledge=("stdio wpath",NULL) status=0 exit=0
test(test_cpath): pledge=("cpath",NULL) status=0 exit=0
-test(test_wpaths): pledge=("stdio rpath",NULL)
- open_close("/etc/passwd") fd=3 errno=0
- open_close("generic") fd=3 errno=0
- open_close("../../../../../../../../../../../../../../../etc/passwd") fd=3 errno=0
- open_close("/nonexistent") fd=-1 errno=2
- status=0 exit=0
-test(test_wpaths): pledge=("stdio rpath",{NULL})
- open_close("/etc/passwd") fd=-1 errno=2
- open_close("generic") fd=-1 errno=2
- open_close("../../../../../../../../../../../../../../../etc/passwd") fd=-1 errno=2
- open_close("/nonexistent") fd=-1 errno=2
- status=0 exit=0
-test(test_wpaths): pledge=("stdio rpath",{"/",NULL})
- open_close("/etc/passwd") fd=3 errno=0
- open_close("generic") fd=3 errno=0
- open_close("../../../../../../../../../../../../../../../etc/passwd") fd=3 errno=0
- open_close("/nonexistent") fd=-1 errno=2
- status=0 exit=0
-test(test_wpaths): pledge=("stdio rpath",{"/etc",NULL})
- open_close("/etc/passwd") fd=3 errno=0
- open_close("generic") fd=-1 errno=2
- open_close("../../../../../../../../../../../../../../../etc/passwd") fd=3 errno=0
- open_close("/nonexistent") fd=-1 errno=2
- status=0 exit=0
-test(test_wpaths): pledge=("stdio rpath",{"/etc/",NULL})
- open_close("/etc/passwd") fd=3 errno=0
- open_close("generic") fd=-1 errno=2
- open_close("../../../../../../../../../../../../../../../etc/passwd") fd=3 errno=0
- open_close("/nonexistent") fd=-1 errno=2
- status=0 exit=0
-test(test_wpaths): pledge=("stdio rpath",{"/etc/passwd",NULL})
- open_close("/etc/passwd") fd=3 errno=0
- open_close("generic") fd=-1 errno=2
- open_close("../../../../../../../../../../../../../../../etc/passwd") fd=3 errno=0
- open_close("/nonexistent") fd=-1 errno=2
- status=0 exit=0
-test(test_wpaths): pledge=("stdio rpath",{"/bin",NULL})
- open_close("/etc/passwd") fd=-1 errno=2
- open_close("generic") fd=-1 errno=2
- open_close("../../../../../../../../../../../../../../../etc/passwd") fd=-1 errno=2
- open_close("/nonexistent") fd=-1 errno=2
- status=0 exit=0
-test(test_wpaths): pledge=("stdio rpath",{"generic",NULL})
- open_close("/etc/passwd") fd=-1 errno=2
- open_close("generic") fd=3 errno=0
- open_close("../../../../../../../../../../../../../../../etc/passwd") fd=-1 errno=2
- open_close("/nonexistent") fd=-1 errno=2
- status=0 exit=0
-test(test_wpaths): pledge=("stdio rpath",{"",NULL})
- open_close("/etc/passwd") fd=-1 errno=2
- open_close("generic") fd=3 errno=0
- open_close("../../../../../../../../../../../../../../../etc/passwd") fd=-1 errno=2
- open_close("/nonexistent") fd=-1 errno=2
- status=0 exit=0
-test(test_wpaths): pledge=("stdio rpath",{".",NULL})
- open_close("/etc/passwd") fd=-1 errno=2
- open_close("generic") fd=3 errno=0
- open_close("../../../../../../../../../../../../../../../etc/passwd") fd=-1 errno=2
- open_close("/nonexistent") fd=-1 errno=2
- status=0 exit=0
test(test_pledge): pledge=("stdio rpath",NULL) status=0 exit=0
test(test_pledge): pledge=("stdio rpath wpath",NULL) status=0 exit=0
-test(test_pledge): pledge=("stdio rpath wpath",{"/sbin",NULL}) status=256 exit=1 (errno: "Operation not permitted")
-test(test_pledge): pledge=("stdio rpath wpath",{"/",NULL}) status=256 exit=1 (errno: "Operation not permitted")
test(test_pledge): pledge=("stdio",NULL) status=256 exit=1 (errno: "Operation not permitted")
test(test_pledge): pledge=("stdio unix",NULL) status=256 exit=1 (errno: "Operation not permitted")
-test(test_stat): pledge=("stdio rpath",{"/usr/share/man",NULL})
- stat("/usr/share/man/man8/afterboot.8"): realpath="/usr/share/man/man8/afterboot.8" uid=0 gid=7 mode=100444
- stat("/usr/share/man/man8/"): realpath="/usr/share/man/man8" uid=0 gid=0 mode=40755
- stat("/usr/share/man"): realpath="/usr/share/man" uid=0 gid=0 mode=40755
- stat("/usr/share"): realpath="/usr/share" uid=0 gid=0 mode=40111
- stat("/usr"): realpath="/usr" uid=0 gid=0 mode=40111
- stat("/"): realpath="/" uid=0 gid=0 mode=40111
- stat("/usr/bin/gzip"): realpath=failed(2) errno=2
- status=0 exit=0
-test(test_mmap): pledge=("stdio rpath prot_exec",{"/dev/zero",NULL}) status=0 exit=0
-test(test_mmap): pledge=("stdio rpath",{"/dev/zero",NULL}) status=134 signal=6 coredump=present pledged_syscall=197
test(test_request_stdio): pledge=skip status=0 exit=0
test(test_request_tty): pledge=skip status=0 exit=0