Commit Graph

50 Commits

Author SHA1 Message Date
Dmitry Vyukov
a5e37d4a8e pkg/runtest: split parsing tests into OS/arch subtests 2020-09-20 15:12:12 +02:00
Dmitry Vyukov
55b6cd4333 pkg/runtest: test parsing of all tests
Currently we only test parsing in tools/syz-runtest
and for test OS in pkg/runtest tests.
This means errors in tests for other OSes won't be
noticed until somebody runs tests manually.
Test parsing of all tests in pkg/runtest tests.
Fix up 2 broken tests.
2020-09-13 19:28:47 +02:00
Dmitry Vyukov
c52d06e410 sys/linux/test: mark f2fs tests as manual
Introduce "manual" requirement for tests (only run if explicitly selected)
and mark f2fs tests as manual. There are too many of them.

Follow up to #2032
2020-09-13 19:28:47 +02:00
Dmitry Vyukov
306464056c sys/test/test: add a hanging test
Ensure that we can handle hanging syscalls in all modes.
2020-09-12 13:03:27 +02:00
Mark Johnston
1bf9153625 pkg/runtest: re-enable 32-bit test target tests on FreeBSD
They now pass since we set DataOffset correctly for those targets.
This reverts 594e57536f.
2020-08-12 18:09:10 +02:00
Mark Johnston
594e57536f pkg/runtest: disable 32-bit tests on FreeBSD for now
FreeBSD requires a non-default SYZ_DATA_OFFSET on 32-bit targets.
2020-08-08 11:09:48 +02:00
Cheng-Min Chiang
20a3465b97 sys/linux: add descriptions for BPF LSM
This commit includes the following changes:
* executor: add a new syz_btf_id_by_name psuedo-syscall
* sys/linux: add descriptions for BPF LSM subsystem
* sys/linux: add instructions on how to dump vmlinux and install
  bpftool
* sys/linux/test: add tests for the new psuedo-syscall
* pkg/host: add support detection for the new psuedo-syscall
* pkg/runtest: skip the coverage test when invoking the new
  psuedo-syscall

Update #533.
2020-08-07 09:28:26 +02:00
TheOfficialFloW
b094755316
all: initialize vhci in linux
* all: initialize vhci in linux

* executor/common_linux.h: improve vhci initialization

* pkg/repro/repro.go: add missing vhci options

* executor/common_linux.h: fix type and add missing header

* executor, pkg: do it like NetInjection

* pkg/csource/csource.go: do not emit syz_emit_vhci if vhci is not enabled

* executor/common_linux.h: fix format string

* executor/common_linux.h: initialize with memset

For som reason {0} gets complains about missing braces...

* executor/common_linux.h: simplify vhci init

* executor/common_linux.h: try to bring all available hci devices up

* executor/common_linux.h: find which hci device has been registered

* executor/common_linux.h: use HCI_VENDOR_PKT response to retrieve device id

* sys/linux/dev_vhci.txt: fix structs of inquiry and report packets

* executor/common_linux.h: remove unnecessary return statement and check vendor_pkt read size

* executor/common_linux.h: remove unnecessary return statement and check vendor_pkt read size

* sys/linux/dev_vhci.txt: pack extended_inquiry_info_t

* sys/linux/l2cap.txt: add l2cap_conf_opt struct

* executor/common_linux.h: just fill bd addr will 0xaa

* executor/common_linux.h: just fill bd addr will 0xaa
2020-07-30 11:33:48 +02:00
Dmitry Vyukov
c4b454fc54 pkg/runtest: tell ASAN to not mess with our NONFAILING
It seems that different gcc's have different defaults for ASAN flags.
Some fail with:

        run.go:67: nonfailing none/thr/repeat            : FAIL: run 0: call 0 is not executed
            	ASAN:DEADLYSIGNAL
            	=================================================================
            	==67143==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f7b0befb0a2 bp 0x7f7b0cfdad10 sp 0x7f7b0cfda490 T1)
            	    #0 0x7f7b0befb0a1  (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x8d0a1)
            	    #1 0x404bbb in syz_compare(long, long, long, long) (/tmp/utor355225125.0+0x404bbb)
            	    #2 0x403cdf in execute_call(thread_t*) (/tmp/utor355225125.0+0x403cdf)
            	    #3 0x404006 in worker_thread(void*) (/tmp/utor355225125.0+0x404006)
            	    #4 0x7f7b0bc584a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x74a3)
            	    #5 0x7f7b0b99ad0e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe8d0e)

            	AddressSanitizer can not provide additional info.
            	SUMMARY: AddressSanitizer: SEGV (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x8d0a1)
            	Thread T1 created by T0 here:
            	    #0 0x7f7b0be9ef59 in __interceptor_pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x30f59)
            	    #1 0x406117 in execute_one() (/tmp/utor355225125.0+0x406117)
2020-07-16 12:22:57 +02:00
Dmitry Vyukov
6b24f02a11 pkg/runtest: allow to select a subset of tests to run 2020-07-15 09:26:23 +02:00
Alexander Egorenkov
bbad15ae75 target: support of big-endian architectures
* Introduce the new target flag 'LittleEndian' which specifies
  of which endianness the target is.
* Introduce the new requires flag 'littleendian' for tests to
  selectively enable/disable tests on either little-endian architectures
  or big-endian ones.
* Disable KD unit test on s390x architecture because the test
  works only on little-endian architecture.

Signed-off-by: Alexander Egorenkov <Alexander.Egorenkov@ibm.com>
2020-06-23 21:24:30 +02:00
Dmitry Vyukov
2fcb2b5c16 .golangci.yml: enable gocognit checker
Finds too complex functions.
Similar to gocyclo, but uses somewhat different metric.
2020-06-05 12:23:19 +02:00
Matthew Dempsky
a86ce602b3 syz-runtest: disable csource tests for HostFuzzer targets
HostFuzzer targets require that we cross-compile the csource tests and
then copy them to the target system. The code to copy files is
currently missing from syz-runtest; also, at least for Fuchsia (which
uses HostFuzzer mode), cross-compiling is non-trivial.
2020-06-03 10:30:14 +02:00
Dmitry Vyukov
0ee915a4b7 pkg/runtest: disable broken test combinations
Amusingly this was always broken but nobody was ever able to compile
32-bit binaries on Linux since the addition of the tests.
2020-05-18 11:34:42 +02:00
Dmitry Vyukov
67206203d3 pkg/runtest: enable 32-bit tests
32-bit tests should work on CI now.
But don't run them in -short mode,
otherwise it takes too long.
2020-05-18 11:34:42 +02:00
Marco Vanotti
aa6c6a5572 sys/fuchsia: Add cprng and vmo tests.
This commit adds two new tests for fuchsia. One tests a basic syscall
(zx_cprng_draw), and the other does multiple tests over a vmo.
2020-03-21 07:02:15 +01:00
Dmitry Vyukov
d13d795888 tools/syz-runtest: debug all programs in debug mode 2019-12-16 19:37:38 +01:00
Dmitry Vyukov
8825ff8ff2 pkg/runtest: shrink if condition 2019-11-16 09:58:54 +01:00
Dmitry Vyukov
a129861adb pkg/ipc: move target characteristics out of config flags
They don't belong there, executor does not know about them.
In preparation for future changes.
2019-11-16 09:58:54 +01:00
Dmitry Vyukov
aa27601f9e pkg/host: rename some features
Rename some features in preparation for subsequent changes
which will align names across the code base.
2019-11-16 09:58:54 +01:00
Dmitry Vyukov
157653cfe7 pkg/csource: rename some options
Rename some options in preparation for subsequent changes
which will align names across the code base.
2019-11-16 09:58:54 +01:00
Jiri Pirko
d40d75d2d7 executor: move fixed pci devlink handle into network namespace
In case there is a fixed pci devlink handle "pci/pci/0000:00:10.0"
on the system (initial network namespace), it is moved to a working
network namespace.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
2019-11-03 14:20:59 +01:00
Andrey Konovalov
5ff4e14cb1 pkg/runtest: allow empty signal 2019-09-24 10:45:51 +02:00
Andrey Konovalov
d62be7809c runtest: add a flag to specify tests to run 2019-09-17 15:58:29 +02:00
Dmitry Vyukov
ad87cdf3c7 pkg/runtest: detect and ignore flakes
Add retry logic that detects and ignores episodic flakes.
This test episodically flakes on syzbot.
We run with the default timeout, but require a test
to pass in 50+% of cases.
Running 72 test binaries in parallel I am getting 35-44 failures out of 72
with 1 retry. With 3 retries it drops to ~7. With 5 it is close to 0.
Use 7 retries for now. Let's see if it still flakes.
2019-06-04 14:57:43 +02:00
Andrey Konovalov
142ce68175 pkg/runtest: add simple USB runtest 2019-05-31 13:35:25 +02:00
Dmitry Vyukov
712bfcbdd8 pkg/runtest: test host.Setup
This would catch binfmt_misc breakage on non-linux.
2019-05-21 12:35:51 +02:00
Dmitry Vyukov
4b69c3cbac pkg/runtest: make tests pass on freebsd
The problem is stupid: <endian.h> should be included as <sys/endian.h> on freebsd.
Pass actual host OS to executor build as HOSTGOOS and use it to figure out
how we should include this header.
2019-03-07 20:37:43 +01:00
Andrey Konovalov
dfd609eca1 execprog, stress, prog2c: unify flags to enable additional features
This change makes all syz-execprog, syz-prog2c and syz-stress accept
-enable and -disable flags to enable or disable additional features
(tun, net_dev, net_reset, cgroups and binfmt_misc) instead of having
a separate flag for each of them.

The default (without any flags) behavior isn't changed: syz-execprog
and syz-stress enabled all the features (provided the runtime supports
them) and syz-prog2c disables all of them.
2019-03-05 14:30:10 +01:00
Dmitry Vyukov
6193630786 pkg/runtest: don't print skipped/broken tests by default
SKIP/BROKEN distract too much attention from FAIL tests
and are not usually interesting. Add Verbose flag that
controls printing of SKIP/BROKEN tests. Enable it in
pkf/runtest/run_test.go by default and disable in tools/syz-runtest.
2019-02-13 15:58:42 +01:00
Dmitry Vyukov
78a290863d pkg/runtest: run syz tests in non-repeat mode
Turns out it can affect some tests,
e.g. some things manifest only after executor restart
(executor binary marked as non-executable by the test).
2019-02-08 16:27:53 +01:00
Dmitry Vyukov
25e10a0434 executor: remove ability to detect kernel bugs
This ability was never used but we maintain a bunch of code for it.
syzkaller also recently learned to spoof this error code
with some ptrace magic (probably intercepted control flow again
and exploited executor binary).
Drop all of it.
2019-01-31 11:35:53 +01:00
Dmitry Vyukov
724adc5445 sys/test/test: add tests for test exiting in the middle of execution 2019-01-31 11:35:53 +01:00
Andrey Konovalov
c2faf9b2d5 all: detect extra coverage support
Based on whether the kernel supports KCOV_REMOTE_ENABLE ioctl.
2019-01-16 19:19:53 +01:00
Andrey Konovalov
b5df78dc5d all: support extra coverage
Right now syzkaller only supports coverage collected from the threads that
execute syscalls. However some useful things happen in background threads,
and it would be nice to collect coverage from those threads as well.

This change adds extra coverage support to syzkaller. This coverage is not
associated with a particular syscall, but rather with the whole program.
Executor passes extra coverage over the same ipc mechanism to syz-fuzzer
with syscall number set to -1. syz-fuzzer then passes this coverage to
syz-manager with the call name "extra".

This change requires the following kcov patch:
https://github.com/xairy/linux/pull/2
2019-01-16 19:19:53 +01:00
Dmitry Vyukov
2b084c9886 pkg/csource: use 0 for missing syscall args
We don't specify trailing unused args for some syscalls
(e.g. ioctl that does not use its arg).
Executor always filled tailing unsed args with 0's
but pkg/csource didn't. Some such syscalls actually
check that the unsed arg is 0 and as the result failed with C repro.

We could statically check and eliminate all such cases,
but it turns out the warning fires in 1500+ cases:
a3ace5a63f/gistfile1.txt

So instead fill such args with 0's in pkg/csource too.
2018-12-27 13:11:57 +01:00
Dmitry Vyukov
c7ba317e9b tools/syz-runtest: test program parsing before booting VMs
It sucks to wait for VMs to boot just to discover that programs don't parse.
2018-12-10 16:37:02 +01:00
Dmitry Vyukov
593b260b02 pkg/ipc: move sandbox helpers from ipcconfig
Currently syz-runtest fails to start because -debug flag is defined
both in syz-runtest and ipcconfig.
But moving sandbox functions we prevent ipcconfig from being imported into syz-runtest.
2018-12-10 16:37:02 +01:00
Dmitry Vyukov
95fe19c19e prog: introduce strict parsing mode
Over time we relaxed parsing to handle all kinds of invalid programs
(excessive/missing args, wrong types, etc).
This is useful when reading old programs from corpus.
But this is harmful for e.g. reading test inputs as they can become arbitrary outdated.
For runtests which creates additional problem of executing not
what is actually written in the test (or at least what author meant).
Add strict parsing mode that does not tolerate any errors.
For now it just checks excessive syscall arguments.
2018-12-10 16:37:01 +01:00
Andrey Konovalov
582e1f0d1d ipc: add ProgInfo struct
This patch add a new struct ProgInfo that for now holds info about each
call in a program []CallInfo, but in the future will be expanded with remote
coverage info. Update all the callers to use the new interface as well.
2018-11-22 13:49:50 +01:00
Dmitry Vyukov
7296c0747f pkg/host: improve KMEMLEAK support
Rewind kmemleak fd before reading it second time,
otherwise we will read truncated reports.

Auto-learn what leak reports we've already seen
and ignore them in future. This is required because
there are some false positives and some fire too frequently.
So now we will hit each leak only once per manager run,
but we still will try to reproduce them.
2018-09-28 14:57:20 +02:00
Zach Riggle
0eca949a6c RFC: android: Add support for untrusted_app sandboxing (#697)
executor: add support for android_untrusted_app sandbox

This adds a new sandbox type, 'android_untrusted_app', which restricts
syz-executor to the privileges which are available to third-party applications,
e.g. those installed from the Google Play store.

In particular, this uses the UID space reserved for applications (instead of
the 'setuid' sandbox, which uses the traditional 'nobody' user / 65534)
as well as a set of groups which the Android-specific kernels are aware of,
and finally ensures that the SELinux context is set appropriately.

Dependencies on libselinux are avoided by manually implementing the few
functions that are needed to change the context of the current process,
and arbitrary files.  The underlying mechanisms are relatively simple.

Fixes google/syzkaller#643

Test: make presubmit
Bug: http://b/112900774
2018-09-17 11:33:11 +02:00
Dmitry Vyukov
fd85ed4885 pkg/runtest, pkg/csource: don't run tests on openbsd
The tests are currently broken on openbsd.
2018-09-17 10:59:06 +02:00
Dmitry Vyukov
596466b38c pkg/runtest: fixes for fuchsia
Add simple fuchsia program, the one that is run during image testing.
Fix csource errno printing for fuchsia.
Fix creation of executable files (chmod is not implemented on fuchsia).
Check that we get signal/coverage from all syscalls.
2018-09-06 10:56:09 +02:00
Dmitry Vyukov
3a2fe60529 executor: fix cgroups
1. Create per-proc cgroup in executor.
2. Setup cgroups after chdir into test dir
   (it assumes relative paths against test dir).
3. Add test.
2018-08-09 16:05:46 +02:00
Dmitry Vyukov
922e8e2734 executor: mount binfmt_mist
We forgot to mount binfmt_misc. Mount it. Add a test.
Increase per-call timeout, otherwise last execve timesout.
Fix csource waiting for call completion at the end of program.
2018-08-09 16:05:46 +02:00
Dmitry Vyukov
3653592507 pkg/runtest: assorted improvements
Support checking "blocked"/"unfinished" flags for calls.
Support test constanints, e.g. "requires: threaded" or "requires: -sandbox=setuid".
Some improvements in tools/syz-runtest.

Update #603
2018-08-08 15:05:01 +02:00
Dmitry Vyukov
df7f6947ba pkg/runtest: skip 32-bit tests in short mode
Fails on travis...
2018-08-03 21:24:35 +02:00
Dmitry Vyukov
2763e04c22 tools/syz-runtest: add tool for program unit testing
The tool is run as:

$ syz-runtest -config manager.config

This runs all programs from sys/*/test/* in different modes
on actual VMs and checks results.

Fixes #603
2018-08-03 21:08:02 +02:00
Dmitry Vyukov
5ba57bfe16 pkg/runtest: add package for syzkaller program unit-testing
Package runtest is a driver for end-to-end testing of syzkaller programs.
It tests program execution via both executor and csource,
with different sandboxes and execution modes (threaded, repeated, etc).
It can run test OS programs locally via run_test.go
and all other real OS programs via tools/syz-runtest
which uses manager config to wind up VMs.
Test programs are located in sys/*/test/* files.

Update #603
2018-08-03 18:47:42 +02:00