aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/csource
Commit message (Collapse)AuthorAgeFilesLines
* pkg/csource: split emitCall functionDmitry Vyukov2018-12-271-11/+16
| | | | | gometalinter points that emitCall is too complex. Factor out call name emission.
* pkg/csource: use 0 for missing syscall argsDmitry Vyukov2018-12-272-0/+62
| | | | | | | | | | | | | | 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: https://gist.githubusercontent.com/dvyukov/e59ba1d9a211ee32fa0ba94fab86a943/raw/a3ace5a63f7281f0298f51ea9842ead1e4713418/gistfile1.txt So instead fill such args with 0's in pkg/csource too.
* pkg/csource: fix PRINTF removalDmitry Vyukov2018-12-261-1/+1
| | | | PRINTF now accepts arguments.
* executor: create more net devices on linuxDmitry Vyukov2018-12-261-15/+26
|
* executor: restrict ipc resource usageDmitry Vyukov2018-12-261-1/+21
| | | | | For context see: https://groups.google.com/d/msg/syzkaller-bugs/ZaBzAJbn6i8/Py9FVlAqDQAJ
* sys/linux: extend AX25/ROSE/NETROM descriptionsDmitry Vyukov2018-12-241-2/+26
|
* prog, pkg/csource: more readable serialization for stringsDmitry Vyukov2018-12-151-52/+4
| | | | | | | Always serialize strings in readable format (non-hex). Serialize binary data in readable format in more cases. Fixes #792
* pkg/csource: support tun and setuid repros on {free,open}bsdGreg Steuck2018-12-133-8/+17
| | | | | | * expose procid on BSD for tun, always declare loop() * deal with terrible bsd includes * replicate loop() declaration
* executor: reapply setuid sandbox for bsdGreg Steuck2018-12-111-0/+70
| | | | | | | | | | * Revert "Revert "executor: add setuid sandbox for openbsd"" The problem is the low file descriptor limit. This reverts commit 4093e33b1338f274ae0062f555de9d6af8640d61. * executor/executor make sure the file descriptor limit is sufficient
* Revert "executor: add setuid sandbox for openbsd"Greg Steuck2018-12-101-70/+0
| | | | This reverts commit 6565f24da9f4eb36702339ba290213995fcc902f.
* executor: add setuid sandbox for openbsdGreg Steuck2018-12-101-0/+70
| | | | | | | | | | * executor/common_bsd: add setuid sandbox Fixes #833 cc @mptre * Reduced duplications, resolved TODO.
* executor: fix handling of big-endian bitfieldsDmitry Vyukov2018-12-082-21/+22
| | | | | Currently we apply big-endian-ness and bitfield-ness in the wrong order in copyin. This leads to totally bogus result. Fix this.
* pkg/csource: exclude linux/arm64 testsDmitry Vyukov2018-12-051-7/+5
| | | | | | | | | | | | | | | I think I misinterpreted the error that episodically happens on ci: collect2: error: ld terminated with signal 11 [Segmentation fault], core dumped compiler invocation: aarch64-linux-gnu-gcc [-Wall -Werror -O1 -g -o /tmp/syz-executor570589071 -pthread -DGOOS_linux=1 -DGOARCH_arm64=1 -x c - -static] as OOM, but they all involve aarch64-linux-gnu-gcc: https://travis-ci.org/google/syzkaller/jobs/461827347 https://travis-ci.org/google/syzkaller/jobs/460226110 https://travis-ci.org/google/syzkaller/jobs/463564291 So I guess the problem can be with the arm64 toolchain that just crashes randomly.
* pkg/csource: reduce short testsDmitry Vyukov2018-12-032-40/+43
| | | | | | | | | | | | pkg/csource test gets OOM-killed on travis: https://travis-ci.org/google/syzkaller/jobs/461827347 https://travis-ci.org/google/syzkaller/jobs/460226110 Add several measures: - set GOMAXPROCS=1 to restrict parallel processes - remove -g from compiler invocation - reduce set of tests run in short mode to compensate for GOMAXPROCS=1 - also reduce set of tests in full mode as they timeout now
* pkg/csource: use defines from sys/syscall.h on *bsdGreg Steuck2018-12-021-0/+1
| | | Fixes #841
* executor: add support for tap interfaces on FreeBSDMichael Tüxen2018-12-011-1/+15
|
* openbsd: repair pkg/csource_testGreg Steuck2018-11-302-43/+35
|
* executor: Use correct macros.Michael Tuexen2018-11-301-1/+1
| | | | Suggested by Dmitry Vyukov.
* executor: Fix compilation on FreeBSD.Michael Tuexen2018-11-301-5/+4
| | | | | | | This is an autogenerated file, but it seem that changes to it resulting from changes in executor/common_bsd.h must also be committed. e
* executor: FreeBSD: fixed endian.h pathmsvoelker2018-11-231-0/+4
| | | | The include statement for endian.h failed on FreeBSD. Changed include statement to syz/endian.h for FreeBSD.
* sys/fuchsia: update VMAR syscallsMarco Vanotti2018-11-211-3/+3
| | | | | | | | | | | | | | | | | | | | | | | * sys/fuchsia: update vmar syscalls. In a previous zircon commit[0], the vmar related syscalls (like `zx_vmar_map`, `zx_vmar_protect` and `zx_vmar_allocate`) changed the order of their parameters, making putting the flags parameter as the second parameter, and renaming it to "options". This commit modifies vmars.txt so that it reflects the latest state of the syscalls in zircon. I also modified the usage in `executor/common_fuchsia.h` I ran make extract, make generate and compiled syzkaller to test this change. [0]: https://fuchsia-review.googlesource.com/c/zircon/+/168060 * sys/fuchsia run make generate This commit is just the result of running make generate after its parent. This regenerates the definitions for the modified VMAR syscalls.
* executor: OpenBSD network package injectionGreg Steuck2018-11-171-6/+214
| | | | | | | | | | | | | | | | | | | | | | | | Squash of: * Doc typo * Ported some tun related functions. * Copy vnet.txt from linux to openbsd. * Simplified syz_emit_ethernet and stubbed out vnet.txt. * Undo clang-format header sorting: headers are order sensitive. * Uniquify tap devices by pid. * clang-format off for includes * Happier clang-format. * Partially revert "Uniquify tap devices by pid." Just rely on procid magic instead of getting it from a flag.
* sys/targest: introduce target.BuildOSDmitry Vyukov2018-11-171-3/+3
| | | | | | | | We can't cross-compile native binaries from just any OS to any other. For most OSes we can do only native compilation. Some can only be compiled from linux. To date we avoided this problem completely (mostly assumed linux build OS). Make this notion of what can build what explicit.
* pkg/csource: add support for creating reproducers on OpenBSDAnton Lindqvist2018-11-171-1/+2
|
* executor: fix inclusion of kvm arch-specific codeDmitry Vyukov2018-10-311-2/+2
| | | | | We use GOOS now to figure out target arch (which can be different from host arch).
* Android: Fix sandbox implementationZach Riggle2018-10-121-3/+10
| | | | | | | | | | | My test harness for this code performed some steps that are not performed when syz-executor is invoked directy. Specifcally, we need to operate from a directory under /data/data, and have the correct UID/GID set as the owner of the directory. My test harness now correctly sets these, all sandbox operations succeed, and loop() is invoked.
* executor: Fuchsia: Use zx_task_resume_from_exception()Scott Graham2018-10-101-2/+2
| | | | | zx_task_resume() is deprecated; switch to using zx_task_resume_from_exception() instead.
* executor: tune memcg container logicDmitry Vyukov2018-10-101-12/+6
| | | | | | | | | | | | The current memcg container seems to lead to lots of hangs/stalls. Presumably the problem is with oom_score_adj and KASAN. Executor process tree eats all memory and then the leaf process is killed but the memory is not returned to memcg due to KASAN quarantine; and the parent processes are protected from killing with oom_score_adj=-1000. As the result the kernel locks up. 1. Don't use oom_score_adj=-1000. Instead bump leaf process score to 1000 (kill always). 2. Increase size of memcg to be larger than expected KASAN quarantine size.
* executor: fix build on newer linux distrosDmitry Vyukov2018-09-271-2/+30
| | | | | | | This sucks a lot, but ebtables.h is now broken too on Debian 4.17: ebtables.h: In function ‘ebt_entry_target* ebt_get_target(ebt_entry*)’: ebtables.h:197:19: error: invalid conversion from ‘void*’ to ‘ebt_entry_target*’
* executor: make the debug output useful for race condition debuggingAlexander Popov2018-09-241-4/+1
| | | | | | | | | | | | | | | Sometimes race conditions are reproduced by syz-execprog and are not reproduced by the programs generated with syz-prog2c. In such cases it's very helpful to know when exactly the fuzzing syscalls are executed. Unfortunately, adding timestamps to the output of the original 'debug' mode doesn't work. This mode provides very verbose output, which slows down executor and breaks the repro. So let's make the executor debug output less verbose and add the timestamps. Signed-off-by: Alexander Popov <alex.popov@linux.com>
* executor: fix buildDmitry Vyukov2018-09-201-12/+0
| | | | | | | | Move debug_dump_data back to executor.cc. debug_dump_data in common_linux.h does not play well with pkg/csource debug stripping logic. It strips a large random piece of code since it thinks debug_dump_data definition is actually debug_dump_data call site.
* executor: move debug_dump_data() into common_linux.hAnton Lindqvist2018-09-201-0/+12
| | | | | Compiling the executor on OpenBSD currently fails: executor/executor.cc:1316:6: error: unused function 'debug_dump_data'
* executor: make sandboxes more modularDmitry Vyukov2018-09-171-36/+3
| | | | | | | | Currently we have a global fixed set of sandboxes, which makes it hard to add new OS-specific ones (all OSes need to updated to say that they don't support this sandbox). Let it each OS say what sandboxes it supports instead.
* RFC: android: Add support for untrusted_app sandboxing (#697)Zach Riggle2018-09-174-34/+167
| | | | | | | | | | | | | | | | | | | | | 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
* pkg/runtest, pkg/csource: don't run tests on openbsdDmitry Vyukov2018-09-171-0/+5
| | | | The tests are currently broken on openbsd.
* executor: reset oom_score_adj for test processDmitry Vyukov2018-09-111-0/+3
| | | | oom_score_adj is inherited, so we need to reset it to 0.
* executor: sandbox with memory/pid cgroupsDmitry Vyukov2018-09-101-10/+32
| | | | | | | Set limit of 32 pids and 200MB per test process. This should prevent things like fork bombs and frequent OOMs. Fixes #589
* pkg/runtest: fixes for fuchsiaDmitry Vyukov2018-09-061-1/+7
| | | | | | | 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.
* sys/linux: add syz_execute_funcDmitry Vyukov2018-08-301-3/+11
| | | | | | The function executes random code. Update #310
* Add mandatory OpenBSD bits (#689)Anton Lindqvist2018-08-281-3/+31
| | | | | | | | | | | | | | | | | | 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
* executor: fix gcc warnings in fuchsia generated codeDmitry Vyukov2018-08-192-21/+25
| | | | | | gcc complains about function declarations not being prototypes, signed/unsigned cast mismatch and casts between incompatible functions. Fix them.
* executor: fix FS_XFLAG_IMMUTABLE for 32-bit modeDmitry Vyukov2018-08-091-13/+5
| | | | FS_IOC_FSSETXATTR is not supported in compat mode, use FS_IOC_SETFLAGS instead.
* pkg/csource: fix 32-bit syscall callsDmitry Vyukov2018-08-091-1/+7
| | | | | | syscall accepts args as ellipsis, resources are uint64 and take 2 slots without the cast, which is wrong. Cast resources to long when passing to syscall.
* executor: fix cgroupsDmitry Vyukov2018-08-091-4/+4
| | | | | | | 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.
* executor: mount binfmt_mistDmitry Vyukov2018-08-091-6/+9
| | | | | | 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.
* executor: clean up immutable dirsDmitry Vyukov2018-08-091-0/+10
| | | | | | Turns out dirs can be immutable too. Update #650
* executor: remove unnecessary hooks on fuchsiaDmitry Vyukov2018-08-091-5/+0
| | | | These are not needed now.
* sys/fuchsia: add syscall description for binding channels to LauncherDokyung Song2018-08-081-0/+1
|
* executor: manually define struct fsxattrDmitry Vyukov2018-08-081-1/+11
| | | | | | | | | | | | | | | | | | It should be in <linux/fs.h> but is not there on some distros/arches as expected. Travis build fails with: <stdin>: In function ‘remove_dir’: <stdin>:152:13: error: variable ‘attr’ has initializer but incomplete type <stdin>:152:13: error: excess elements in struct initializer [-Werror] <stdin>:152:13: error: (near initialization for ‘attr’) [-Werror] <stdin>:152:21: error: storage size of ‘attr’ isn’t known <stdin>:153:20: error: ‘FS_IOC_FSSETXATTR’ undeclared (first use in this function) <stdin>:153:20: note: each undeclared identifier is reported only once for each function it appears in <stdin>:152:21: error: unused variable ‘attr’ [-Werror=unused-variable] cc1: all warnings being treated as errors https://travis-ci.org/google/syzkaller/jobs/413574080
* executor: clean up immutable filesDmitry Vyukov2018-08-081-0/+11
| | | | Fixes #650