diff options
| author | Anton Lindqvist <anton@basename.se> | 2018-08-28 19:07:26 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-08-28 10:07:26 -0700 |
| commit | b771b17ec95715c24715d730363f6f07bc46fd4f (patch) | |
| tree | cfdb14bb69866ad3bd3b35d21d6c803530b1f8b0 /pkg | |
| parent | 7ef1de9ea4b02a8799b3a7f4b1d7b06a586b3f37 (diff) | |
Add mandatory OpenBSD bits (#689)
all: add openbsd support
squash of the following commits:
* openbsd: add mandatory bits
* report: add OpenBSD support
* executor: skip building kvm on OpenBSD
* executor: add OpenBSD support
Linking against libutil is necessary due to usage of openpty(3).
* executor: fix typo in fail() message
* fixup! report: add OpenBSD support
* fixup! openbsd: add mandatory bits
* fixup! openbsd: add mandatory bits
* fixup! openbsd: add mandatory bits
* fixup! report: add OpenBSD support
* gometalinter: skip sys/openbsd
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/csource/generated.go | 34 | ||||
| -rw-r--r-- | pkg/host/host_openbsd.go | 16 | ||||
| -rw-r--r-- | pkg/osutil/osutil_bsd.go | 2 | ||||
| -rw-r--r-- | pkg/osutil/osutil_unix.go | 2 | ||||
| -rw-r--r-- | pkg/report/openbsd.go | 79 | ||||
| -rw-r--r-- | pkg/report/report.go | 1 | ||||
| -rw-r--r-- | pkg/report/testdata/openbsd/report/0 | 5 | ||||
| -rw-r--r-- | pkg/report/testdata/openbsd/report/1 | 26 | ||||
| -rw-r--r-- | pkg/report/testdata/openbsd/report/2 | 24 | ||||
| -rw-r--r-- | pkg/report/testdata/openbsd/report/3 | 5 | ||||
| -rw-r--r-- | pkg/report/testdata/openbsd/report/4 | 19 | ||||
| -rw-r--r-- | pkg/report/testdata/openbsd/report/5 | 2 |
12 files changed, 210 insertions, 5 deletions
diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go index 4f8d32f15..49fc2ffe8 100644 --- a/pkg/csource/generated.go +++ b/pkg/csource/generated.go @@ -155,7 +155,7 @@ static void use_temporary_dir(void) #endif #endif -#if GOOS_akaros || GOOS_netbsd || GOOS_freebsd || GOOS_test +#if GOOS_akaros || GOOS_netbsd || GOOS_freebsd || GOOS_openbsd || GOOS_test #if SYZ_EXECUTOR || SYZ_EXECUTOR_USES_FORK_SERVER && SYZ_REPEAT && SYZ_USE_TMP_DIR #include <dirent.h> #include <stdio.h> @@ -225,7 +225,7 @@ static void thread_start(void* (*fn)(void*), void* arg) #endif #endif -#if GOOS_freebsd || GOOS_netbsd || GOOS_akaros || GOOS_test +#if GOOS_freebsd || GOOS_netbsd || GOOS_openbsd || GOOS_akaros || GOOS_test #if SYZ_EXECUTOR || SYZ_THREADED #include <pthread.h> @@ -387,7 +387,7 @@ void child() #define do_sandbox_namespace() 0 #endif -#elif GOOS_freebsd || GOOS_netbsd +#elif GOOS_freebsd || GOOS_netbsd || GOOS_openbsd #include <unistd.h> @@ -405,6 +405,34 @@ static int do_sandbox_none(void) #define do_sandbox_namespace() 0 #endif +#if GOOS_openbsd + +#define __syscall syscall + +#if SYZ_EXECUTOR || __NR_syz_open_pts + +#if defined(__OpenBSD__) +#include <termios.h> +#include <util.h> +#else +#include <pty.h> +#endif + +static uintptr_t syz_open_pts(void) +{ + int master, slave; + + if (openpty(&master, &slave, NULL, NULL, NULL) == -1) + return -1; + if (dup2(master, master + 100) != -1) + close(master); + return slave; +} + +#endif + +#endif + #elif GOOS_fuchsia #include <fcntl.h> diff --git a/pkg/host/host_openbsd.go b/pkg/host/host_openbsd.go new file mode 100644 index 000000000..238edd46d --- /dev/null +++ b/pkg/host/host_openbsd.go @@ -0,0 +1,16 @@ +// Copyright 2017 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +package host + +import ( + "github.com/google/syzkaller/prog" +) + +func isSupported(c *prog.Syscall, sandbox string) (bool, string) { + return true, "" +} + +func init() { + checkFeature[FeatureCoverage] = unconditionallyEnabled +} diff --git a/pkg/osutil/osutil_bsd.go b/pkg/osutil/osutil_bsd.go index 60d3e62d3..976fd34fa 100644 --- a/pkg/osutil/osutil_bsd.go +++ b/pkg/osutil/osutil_bsd.go @@ -1,7 +1,7 @@ // Copyright 2017 syzkaller project authors. All rights reserved. // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -// +build freebsd,!appengine netbsd,!appengine +// +build freebsd,!appengine netbsd,!appengine openbsd,!appengine package osutil diff --git a/pkg/osutil/osutil_unix.go b/pkg/osutil/osutil_unix.go index ad6886bc0..8f31a43e0 100644 --- a/pkg/osutil/osutil_unix.go +++ b/pkg/osutil/osutil_unix.go @@ -1,7 +1,7 @@ // Copyright 2017 syzkaller project authors. All rights reserved. // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -// +build freebsd,!appengine netbsd,!appengine linux,!appengine darwin,!appengine +// +build freebsd,!appengine netbsd,!appengine openbsd,!appengine linux,!appengine darwin,!appengine package osutil diff --git a/pkg/report/openbsd.go b/pkg/report/openbsd.go new file mode 100644 index 000000000..dc05ae1bb --- /dev/null +++ b/pkg/report/openbsd.go @@ -0,0 +1,79 @@ +// Copyright 2018 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +package report + +import ( + "regexp" +) + +type openbsd struct { + kernelSrc string + kernelObj string + ignores []*regexp.Regexp +} + +func ctorOpenbsd(kernelSrc, kernelObj string, ignores []*regexp.Regexp) (Reporter, []string, error) { + ctx := &openbsd{ + kernelSrc: kernelSrc, + kernelObj: kernelObj, + ignores: ignores, + } + return ctx, nil, nil +} + +func (ctx *openbsd) ContainsCrash(output []byte) bool { + return containsCrash(output, openbsdOopses, ctx.ignores) +} + +func (ctx *openbsd) Parse(output []byte) *Report { + return simpleLineParser(output, openbsdOopses, nil, ctx.ignores) +} + +func (ctx *openbsd) Symbolize(rep *Report) error { + return nil +} + +var openbsdOopses = []*oops{ + { + []byte("cleaned vnode"), + []oopsFormat{ + { + title: compile("cleaned vnode: "), + fmt: "panic: cleaned vnode isn't", + }, + }, + []*regexp.Regexp{}, + }, + { + []byte("uvm_fault"), + []oopsFormat{ + { + title: compile("uvm_fault\\((?:.*\\n)+?.*Stopped at[ ]+([^\\+]+)"), + fmt: "uvm_fault: %[1]v", + }, + }, + []*regexp.Regexp{}, + }, + { + []byte("panic"), + []oopsFormat{ + { + title: compile("panic: pool_do_put: ([^:]+): double pool_put"), + fmt: "pool: double put: %[1]v", + }, + { + title: compile("panic: pool_do_get: ([^:]+) free list modified"), + fmt: "pool: free list modified: %[1]v", + }, + }, + []*regexp.Regexp{}, + }, + { + []byte("kernel:"), + []oopsFormat{}, + []*regexp.Regexp{ + compile("kernel relinking failed"), + }, + }, +} diff --git a/pkg/report/report.go b/pkg/report/report.go index 4a7c43145..ce953c8a1 100644 --- a/pkg/report/report.go +++ b/pkg/report/report.go @@ -78,6 +78,7 @@ var ctors = map[string]fn{ "gvisor": ctorGvisor, "freebsd": ctorFreebsd, "netbsd": ctorNetbsd, + "openbsd": ctorOpenbsd, "fuchsia": ctorFuchsia, "windows": ctorStub, } diff --git a/pkg/report/testdata/openbsd/report/0 b/pkg/report/testdata/openbsd/report/0 new file mode 100644 index 000000000..bb002c04d --- /dev/null +++ b/pkg/report/testdata/openbsd/report/0 @@ -0,0 +1,5 @@ +TITLE: uvm_fault: vn_writechk + +login: uvm_fault(0xffffff0018def850, 0x50, 0, 1) -> e +
kernel: page fault trap, code=0 +
Stopped at vn_writechk+0x13: testb $0x1,0x50(%rax) diff --git a/pkg/report/testdata/openbsd/report/1 b/pkg/report/testdata/openbsd/report/1 new file mode 100644 index 000000000..51b7dd62f --- /dev/null +++ b/pkg/report/testdata/openbsd/report/1 @@ -0,0 +1,26 @@ +TITLE: panic: cleaned vnode isn't + +login: cleaned vnode: 0xffffff001742a5c0, type VBAD, use 0, write 0, hold 0, +
tag VT_UFS, ino 26028, on dev 4, 0 flags 0x100, effnlink 1, nlink 1 +
mode 0177755, owner 0, group 0, size 0 +
panic: cleaned vnode isn't +
Stopped at db_enter+0xa: popq %rbp +
TID PID UID PRFLAGS PFLAGS CPU COMMAND +
*329861 4439 0 0x2 0 0K syz-executor1 +
db_enter() at db_enter+0xa +
panic() at panic+0x147 +
getnewvnode() at getnewvnode+0x3bc +
ffs_vget(ffff80000e400558,ffff80000e400580,ffffff000e5a7e20) at ffs_vget+0xc1 +
ufs_lookup() at ufs_lookup+0xee3 +
VOP_LOOKUP(ffffff001bf4d758,ffff80000e400530,ffffff001bf4d758) at VOP_LOOKUP+0x +
56 +
vfs_lookup(ffff80000e400568) at vfs_lookup+0x3c1 +
namei(ffff80000e400530) at namei+0x2f4 +
dofstatat(280,ffff80000e3b12a0,0,ffff80000e400750,7f7ffffe3bd8) at dofstatat+0x +
93 +
syscall(0) at syscall+0x489 +
Xsyscall_untramp(6,0,0,0,0,28) at Xsyscall_untramp+0xe4 +
end of kernel +
end trace frame: 0x7f7ffffe40b0, count: 4 +
https://www.openbsd.org/ddb.html describes the minimum info required in bug +
reports. Insufficient info makes it difficult to find and fix bugs. diff --git a/pkg/report/testdata/openbsd/report/2 b/pkg/report/testdata/openbsd/report/2 new file mode 100644 index 000000000..e2e017429 --- /dev/null +++ b/pkg/report/testdata/openbsd/report/2 @@ -0,0 +1,24 @@ +TITLE: pool: double put: mbufpl + +panic: pool_do_put: mbufpl: double pool_put: 0xffffff001d506200 +Stopped at db_enter+0xa: popq %rbp + TID PID UID PRFLAGS PFLAGS CPU COMMAND +*350399 57238 0 0 0x4000000 0 syz-executor1 +db_enter() at db_enter+0xa +panic() at panic+0x147 +pool_do_put(ffffff001d506200,ffffffff81eacbe8) at pool_do_put+0x2e2 +pool_put(fecbcf835145a619,ffffff001d506200) at pool_put+0x37 +m_free(ffffff001d506200) at m_free+0x11e +m_freem(2d) at m_freem+0x2d +soreceive(38a,ffffff001a63c930,0,0,ffff80000e423648,ffffff001071db90) at sorece +ive+0x1fc +recvit(ffff80000e2b7050,ffff80000e4236e0,0,ffff80000e4236f8,12eb78e821c8) at re +cvit+0x253 +sys_recvfrom(ffff80000e423780,ffff80000e2b7050,ffff80000e315170) at sys_recvfro +m+0xbc +syscall(0) at syscall+0x3e4 +Xsyscall_untramp(6,0,0,0,0,0) at Xsyscall_untramp+0xe4 +end of kernel +end trace frame: 0x12eb78e82220, count: 4 +https://www.openbsd.org/ddb.html describes the minimum info required in bug +reports. Insufficient info makes it difficult to find and fix bugs. diff --git a/pkg/report/testdata/openbsd/report/3 b/pkg/report/testdata/openbsd/report/3 new file mode 100644 index 000000000..ed1b9ffc3 --- /dev/null +++ b/pkg/report/testdata/openbsd/report/3 @@ -0,0 +1,5 @@ +TITLE: kernel: page fault trap, code=0 + +login: +
kernel: page fault trap, code=0 +
Stopped at vn_writechk+0x13: testb $0x1,0x50(%rax) diff --git a/pkg/report/testdata/openbsd/report/4 b/pkg/report/testdata/openbsd/report/4 new file mode 100644 index 000000000..9cb43cb91 --- /dev/null +++ b/pkg/report/testdata/openbsd/report/4 @@ -0,0 +1,19 @@ +TITLE: pool: free list modified: knotepl + +panic: pool_do_get: knotepl free list modified: page 0xffffff0016069000; item addr 0xffffff00160699b8; offset 0x10=0x15c9ef10 +Stopped at db_enter+0xa: popq %rbp + TID PID UID PRFLAGS PFLAGS CPU COMMAND +*261118 11352 0 0 0x4000000 0 syz-executor1 +db_enter() at db_enter+0xa +panic() at panic+0x147 +pool_do_get(1,ffffffff81e8e708,0) at pool_do_get+0x3e9 +pool_get(ffff80000e31f730,d) at pool_get+0x77 +kqueue_register(4,16,ffff80000e44f1f8) at kqueue_register+0x2ab +sys_kevent(ffff80000e44f280,ffff80000e31f730,ffff80000e2ace90) at sys_kevent+0x +207 +syscall(0) at syscall+0x3e4 +Xsyscall_untramp(6,0,0,0,0,0) at Xsyscall_untramp+0xe4 +end of kernel +end trace frame: 0x171c1a028b50, count: 7 +https://www.openbsd.org/ddb.html describes the minimum info required in bug +reports. Insufficient info makes it difficult to find and fix bugs. diff --git a/pkg/report/testdata/openbsd/report/5 b/pkg/report/testdata/openbsd/report/5 new file mode 100644 index 000000000..fd5008393 --- /dev/null +++ b/pkg/report/testdata/openbsd/report/5 @@ -0,0 +1,2 @@ + +reorder_kernel: kernel relinking failed; see /usr/share/relink/kernel/KCOV/relink.log |
