diff options
author | mpi <> | 2020-01-30 08:22:30 +0000 |
---|---|---|
committer | mpi <> | 2020-01-30 08:22:30 +0000 |
commit | 668fa98385559e6ca53555e32da8e7eb618f0d80 (patch) | |
tree | a7ed8c6b1fae21213c4669bd2c105cf274af844f /src/regress/lib/libc/sys | |
parent | a9c1dd59a3357c18bee994783c7c8ed45d3e593a (diff) | |
download | openbsd-668fa98385559e6ca53555e32da8e7eb618f0d80.tar.gz openbsd-668fa98385559e6ca53555e32da8e7eb618f0d80.tar.bz2 openbsd-668fa98385559e6ca53555e32da8e7eb618f0d80.zip |
Enable t_ptrace with an errno change compared to NetBSD.
Note that the last test triggers a kernel bug related to waitpid(9) and
ptraced processes. This is now visible thanks to recent make(1) changes.
guenther@ suggests to look at the logic behind `p_orphan' in FreeBSD to
fix this bug.
Diffstat (limited to 'src/regress/lib/libc/sys')
-rw-r--r-- | src/regress/lib/libc/sys/Makefile | 14 | ||||
-rw-r--r-- | src/regress/lib/libc/sys/README | 2 | ||||
-rw-r--r-- | src/regress/lib/libc/sys/macros.h | 30 | ||||
-rw-r--r-- | src/regress/lib/libc/sys/t_ptrace.c | 4 |
4 files changed, 31 insertions, 19 deletions
diff --git a/src/regress/lib/libc/sys/Makefile b/src/regress/lib/libc/sys/Makefile index e30e0a08fb..8c2c6eb3f8 100644 --- a/src/regress/lib/libc/sys/Makefile +++ b/src/regress/lib/libc/sys/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile,v 1.2 2020/01/13 17:06:56 bluhm Exp $ | 1 | # $OpenBSD: Makefile,v 1.3 2020/01/30 08:22:30 mpi Exp $ |
2 | 2 | ||
3 | # Copyright (c) 2019 Moritz Buhl <openbsd@moritzbuhl.de> | 3 | # Copyright (c) 2019 Moritz Buhl <openbsd@moritzbuhl.de> |
4 | # Copyright (c) 2019 Alexander Bluhm <bluhm@openbsd.org> | 4 | # Copyright (c) 2019 Alexander Bluhm <bluhm@openbsd.org> |
@@ -30,8 +30,8 @@ PROGS += t_access t_bind t_chroot t_clock_gettime t_dup t_fsync | |||
30 | PROGS += t_getgroups t_getitimer t_getlogin t_getpid t_getrusage | 30 | PROGS += t_getgroups t_getitimer t_getlogin t_getpid t_getrusage |
31 | PROGS += t_getsid t_getsockname t_gettimeofday t_kill t_link t_listen | 31 | PROGS += t_getsid t_getsockname t_gettimeofday t_kill t_link t_listen |
32 | PROGS += t_mkdir t_mknod t_msgctl t_msgget t_msgsnd t_msync t_pipe | 32 | PROGS += t_mkdir t_mknod t_msgctl t_msgget t_msgsnd t_msync t_pipe |
33 | PROGS += t_poll t_revoke t_select t_sendrecv t_setuid t_socketpair | 33 | PROGS += t_poll t_ptrace t_revoke t_select t_sendrecv t_setuid |
34 | PROGS += t_sigaction t_truncate t_umask t_write | 34 | PROGS += t_socketpair t_sigaction t_truncate t_umask t_write |
35 | 35 | ||
36 | # failing tests | 36 | # failing tests |
37 | .if 0 | 37 | .if 0 |
@@ -40,7 +40,6 @@ PROGS += t_mlock | |||
40 | PROGS += t_mmap | 40 | PROGS += t_mmap |
41 | PROGS += t_msgrcv | 41 | PROGS += t_msgrcv |
42 | PROGS += t_pipe2 | 42 | PROGS += t_pipe2 |
43 | PROGS += t_ptrace | ||
44 | PROGS += t_stat | 43 | PROGS += t_stat |
45 | PROGS += t_syscall | 44 | PROGS += t_syscall |
46 | PROGS += t_unlink | 45 | PROGS += t_unlink |
@@ -57,8 +56,9 @@ setup-t_truncate: | |||
57 | ${SUDO} touch truncate_test.root_owned | 56 | ${SUDO} touch truncate_test.root_owned |
58 | ${SUDO} chown root:wheel truncate_test.root_owned | 57 | ${SUDO} chown root:wheel truncate_test.root_owned |
59 | 58 | ||
60 | run-t_chroot: cleanup-t_chroot | 59 | run-t_chroot: cleanup-dir |
61 | cleanup-t_chroot: | 60 | run-t_ptrace: cleanup-dir |
61 | cleanup-dir: | ||
62 | ${SUDO} rm -rf dir | 62 | ${SUDO} rm -rf dir |
63 | 63 | ||
64 | CLEANFILES = access dummy mmap truncate_test.root_owned | 64 | CLEANFILES = access dummy mmap truncate_test.root_owned |
@@ -100,3 +100,5 @@ run-${PROG}-$n: | |||
100 | .endif | 100 | .endif |
101 | 101 | ||
102 | .include <bsd.regress.mk> | 102 | .include <bsd.regress.mk> |
103 | |||
104 | clean: cleanup-dir | ||
diff --git a/src/regress/lib/libc/sys/README b/src/regress/lib/libc/sys/README index 84a442eb5d..0f7d82e7b6 100644 --- a/src/regress/lib/libc/sys/README +++ b/src/regress/lib/libc/sys/README | |||
@@ -18,6 +18,7 @@ t_getrusage - no expected fail, PR kern/30115 is NetBSD, work more | |||
18 | t_mknod - remove tests for unsupported file types | 18 | t_mknod - remove tests for unsupported file types |
19 | t_msgget - remove msgget_limit test | 19 | t_msgget - remove msgget_limit test |
20 | t_poll - remove pollts_* tests | 20 | t_poll - remove pollts_* tests |
21 | t_ptrace - change EPERM -> EINVAL for PT_ATTACH of a parent | ||
21 | t_revoke - remove basic tests, revoke only on ttys supported | 22 | t_revoke - remove basic tests, revoke only on ttys supported |
22 | t_select - remove sigset_t struct as it is int on OpenBSD | 23 | t_select - remove sigset_t struct as it is int on OpenBSD |
23 | 24 | ||
@@ -26,7 +27,6 @@ t_mlock - wrong errno, succeeds where not expected, POSIX imprecise | |||
26 | t_mmap - ENOTBLK on test NetBSD is skipping, remove mmap_va0 test | 27 | t_mmap - ENOTBLK on test NetBSD is skipping, remove mmap_va0 test |
27 | t_msgrcv - msgrcv(id, &r, 3 - 1, 0x41, 004000) != -1 | 28 | t_msgrcv - msgrcv(id, &r, 3 - 1, 0x41, 004000) != -1 |
28 | t_pipe2 - closefrom(4) == -1, remove F_GETNOSIGPIPE and nosigpipe test | 29 | t_pipe2 - closefrom(4) == -1, remove F_GETNOSIGPIPE and nosigpipe test |
29 | t_ptrace - ptrace(0, 0, ((void *)0), 0) != -1 | ||
30 | t_stat - invalid GID with doas | 30 | t_stat - invalid GID with doas |
31 | t_syscall - SIGSEGV | 31 | t_syscall - SIGSEGV |
32 | t_unlink - wrong errno according to POSIX | 32 | t_unlink - wrong errno according to POSIX |
diff --git a/src/regress/lib/libc/sys/macros.h b/src/regress/lib/libc/sys/macros.h index 932f230c03..ef858d137a 100644 --- a/src/regress/lib/libc/sys/macros.h +++ b/src/regress/lib/libc/sys/macros.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: macros.h,v 1.1.1.1 2019/11/19 19:57:03 bluhm Exp $ */ | 1 | /* $OpenBSD: macros.h,v 1.2 2020/01/30 08:22:30 mpi Exp $ */ |
2 | /* Public domain - Moritz Buhl */ | 2 | /* Public domain - Moritz Buhl */ |
3 | 3 | ||
4 | #include <sys/param.h> | 4 | #include <sys/param.h> |
@@ -9,6 +9,7 @@ | |||
9 | 9 | ||
10 | #include <stdbool.h> | 10 | #include <stdbool.h> |
11 | #include <string.h> | 11 | #include <string.h> |
12 | #include <stdio.h> | ||
12 | 13 | ||
13 | #define __RCSID(str) | 14 | #define __RCSID(str) |
14 | #define __COPYRIGHT(str) | 15 | #define __COPYRIGHT(str) |
@@ -26,17 +27,26 @@ int sysctlbyname(char *, void *, size_t *, void *, size_t); | |||
26 | int | 27 | int |
27 | sysctlbyname(char* s, void *oldp, size_t *oldlenp, void *newp, size_t newlen) | 28 | sysctlbyname(char* s, void *oldp, size_t *oldlenp, void *newp, size_t newlen) |
28 | { | 29 | { |
29 | int ktc; | 30 | int mib[3], miblen; |
30 | if (strcmp(s, "kern.timecounter.hardware") == 0) | ||
31 | ktc = KERN_TIMECOUNTER_HARDWARE; | ||
32 | else if (strcmp(s, "kern.timecounter.choice") == 0) | ||
33 | ktc = KERN_TIMECOUNTER_CHOICE; | ||
34 | 31 | ||
35 | int mib[3]; | ||
36 | mib[0] = CTL_KERN; | 32 | mib[0] = CTL_KERN; |
37 | mib[1] = KERN_TIMECOUNTER; | 33 | if (strcmp(s, "kern.timecounter.hardware") == 0) { |
38 | mib[2] = ktc; | 34 | mib[1] = KERN_TIMECOUNTER; |
39 | return sysctl(mib, 3, oldp, oldlenp, newp, newlen); | 35 | mib[2] = KERN_TIMECOUNTER_HARDWARE; |
36 | miblen = 3; | ||
37 | } else if (strcmp(s, "kern.timecounter.choice") == 0) { | ||
38 | mib[1] = KERN_TIMECOUNTER; | ||
39 | mib[2] = KERN_TIMECOUNTER_CHOICE; | ||
40 | miblen = 3; | ||
41 | } else if (strcmp(s, "kern.securelevel") == 0) { | ||
42 | mib[1] = KERN_SECURELVL; | ||
43 | miblen = 2; | ||
44 | } else { | ||
45 | fprintf(stderr, "%s(): mib '%s' not supported\n", __func__, s); | ||
46 | return -42; | ||
47 | } | ||
48 | |||
49 | return sysctl(mib, miblen, oldp, oldlenp, newp, newlen); | ||
40 | } | 50 | } |
41 | 51 | ||
42 | /* t_mlock.c */ | 52 | /* t_mlock.c */ |
diff --git a/src/regress/lib/libc/sys/t_ptrace.c b/src/regress/lib/libc/sys/t_ptrace.c index 756c9c514e..78c4a8e47b 100644 --- a/src/regress/lib/libc/sys/t_ptrace.c +++ b/src/regress/lib/libc/sys/t_ptrace.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: t_ptrace.c,v 1.1.1.1 2019/11/19 19:57:04 bluhm Exp $ */ | 1 | /* $OpenBSD: t_ptrace.c,v 1.2 2020/01/30 08:22:30 mpi Exp $ */ |
2 | /* $NetBSD: t_ptrace.c,v 1.4 2018/05/14 12:44:40 kamil Exp $ */ | 2 | /* $NetBSD: t_ptrace.c,v 1.4 2018/05/14 12:44:40 kamil Exp $ */ |
3 | 3 | ||
4 | /*- | 4 | /*- |
@@ -171,7 +171,7 @@ ATF_TC_BODY(attach_chroot, tc) | |||
171 | rv = write(fds_toparent[1], &msg, sizeof(msg)); | 171 | rv = write(fds_toparent[1], &msg, sizeof(msg)); |
172 | FORKEE_ASSERTX(rv == sizeof(msg)); | 172 | FORKEE_ASSERTX(rv == sizeof(msg)); |
173 | 173 | ||
174 | ATF_REQUIRE_ERRNO(EPERM, | 174 | ATF_REQUIRE_ERRNO(EINVAL, |
175 | ptrace(PT_ATTACH, getppid(), NULL, 0) == -1); | 175 | ptrace(PT_ATTACH, getppid(), NULL, 0) == -1); |
176 | 176 | ||
177 | rv = read(fds_fromparent[0], &msg, sizeof(msg)); | 177 | rv = read(fds_fromparent[0], &msg, sizeof(msg)); |