Commit Graph

387 Commits

Author SHA1 Message Date
Dmitry Vyukov
8257de047b sys/linux: open files from /proc 2017-11-27 09:08:59 +01:00
Dmitry Vyukov
7061d1973b sys/syz-extract: fix mmap on arm
__NR_mmap is missing on arm entirely,
so we disable mmap during generate.
Patch mmap to mmap2 right in syz-extract,
so that mmap is never missing.
2017-11-23 08:51:04 +01:00
Dmitry Vyukov
fba338cd51 pkg/csource: add function to parse serialized options
Also move options and options tests into a separate file,
add serialization function.
2017-11-17 17:57:51 +01:00
Dmitry Vyukov
c4d43f4773 pkg/osutil: don't leace runaway processes
When manager is stopped there are sometimes runaway qemu
processes still running. Set PDEATHSIG for all subprocesses.
We never need child processes outliving parents.
2017-11-16 12:48:02 +01:00
Andrey Konovalov
dd1609f876 executor: proceed even if /dev/net/tun is not available
For some racy bugs syzkaller can generate a C reproducer with tun
enabled, when it's not actuallly required to trigger the bug.
Some kernel developers (that don't have CONFIG_TUN=y on their setups)
complain about such C repros.
When tun is not available, instead of exiting, print a message that tun
initialization failed and proceed.
2017-11-08 17:43:40 +01:00
zoulasc
0460a8dda0 csource: Fix sed(1) invocation
There is no need to specify '-' as the filename for sed(1):
- The default behavior is to read stdin
- It was not done in all places
- It breaks on NetBSD sed(1) (although I am tempted to fix it now :-)
  and it does not work
2017-11-06 11:27:45 +03:00
Dmitry Vyukov
636a4dbf38 pkg/csource: add freebsd/netbsd support 2017-10-26 15:31:23 +02:00
Dmitry Vyukov
3704c60135 executor: fix build breakages due to doexit
Some standard libraries contain "using ::exit;",
which breaks with the current redefinition of exit.
2017-10-19 11:06:05 +02:00
Dmitry Vyukov
c2337c94bf executor: fix akaros nonfailing mode 2017-10-16 14:21:54 +02:00
Dmitry Vyukov
85b1f93f8d executor, pkg/ipc: unify ipc protocol between linux and other OSes
We currently use more complex and functional protocol on linux,
and a simple ad-hoc protocol on other OSes.
This leads to code duplication in both ipc and executor.
Linux supports coverage, shared memory communication and fork server,
which would also be useful for most other OSes.

Unify communication protocol and parametrize it by
(1) use of shmem or only pipes, (2) use of fork server.

This reduces duplication in ipc and executor and will
allow to support the useful features for other OSes easily.

Finally, this fixes akaros support as it currently uses
syz-stress running on host (linux) and executor running on akaros.
2017-10-16 14:21:54 +02:00
Dmitry Vyukov
f78642861b pkg/csource: support akaros 2017-10-16 14:21:54 +02:00
Dmitry Vyukov
f0565e6231 executor: write debug output to stderr
We print all other output to stderr, write debug output to stderr as well.
This does not matter for the main use case of running syz-execprog -debug,
but can is helpful if we want to communicate with syz-executor via stdin/stdout.
2017-10-16 14:21:54 +02:00
Dmitry Vyukov
66aeb467de pkg/ipc: don't send program padding to executor
Currently we always send 2MB of data to executor in ipc_simple.go.
Send only what's consumed by the program, and don't send the trailing zeros.
Serialized programs usually take only few KBs.
2017-10-12 19:08:18 +02:00
Dmitry Vyukov
c2aee24101 executor: include missing header
writev requires <sys/uio.h>. Include it.
2017-10-10 19:03:04 +02:00
Dmitry Vyukov
179a860885 all: basic freebsd support
For now we just make Go part build for freebsd.
2017-10-02 14:17:32 +02:00
Dmitry Vyukov
eb97aa0610 executor: support fragmentation in syz_emit_ethernet
A recent linux commit "tun: enable napi_gro_frags() for TUN/TAP driver"
added support for fragmentation when emitting packets via tun.
Support this feature in syz_emit_ethernet.
2017-10-02 13:56:36 +02:00
Dmitry Vyukov
bdffe2484c executor: fix execution of windows syscalls
First, they must be called with stdcall convention.
Second, wrap them in __try/__except because they can crash.
2017-09-27 18:59:50 +02:00
Dmitry Vyukov
af442a22d9 executor, sys/windows: initial windows support 2017-09-25 15:19:06 +02:00
Dmitry Vyukov
0a5156336e pkg/csource: disable linux/386 tests
Another attempt to fix travis build.
2017-09-22 13:18:28 +02:00
Dmitry Vyukov
913d592f97 all: more assorted fuchsia support 2017-09-22 13:10:55 +02:00
Dmitry Vyukov
da1873aadd sys/targets: move targets from sys package
This breaks circular dependency between:
sysgen -> sys/linux -> sys -> sysgen
With this circular dependency it is very difficult to
update format of generated descriptions because sysgen does not build.
2017-09-15 16:02:37 +02:00
Dmitry Vyukov
19f9bc13d3 pkg/csource: support archs other than x86_64 2017-09-15 16:02:37 +02:00
Dmitry Vyukov
52a33fd516 prog: remove default target and all global state
Now each prog function accepts the desired target explicitly.
No global, implicit state involved.
This is much cleaner and allows cross-OS/arch testing, etc.
2017-09-15 16:02:37 +02:00
Dmitry Vyukov
f7b1163afb syz-manager/mgrconfig: explicitly specify target in config
Add target config parameter (e.g. linux/amd64) which controls target OS/arch.
No more explicit assumptions about target.
2017-09-15 16:02:37 +02:00
Dmitry Vyukov
ffe7e17368 prog, sys: move types to prog
Large overhaul moves syscalls and arg types from sys to prog.
Sys package now depends on prog and contains only generated
descriptions of syscalls.
Introduce prog.Target type that encapsulates all targer properties,
like syscall list, ptr/page size, etc. Also moves OS-dependent pieces
like mmap call generation from prog to sys.

Update #191
2017-09-05 15:52:42 +02:00
Dmitry Vyukov
5db39ab953 sys: rename Call to Syscall
In preparation for moving sys types to prog
to avoid confusion between sys.Call and prog.Call.
2017-09-05 10:38:22 +02:00
Dmitry Vyukov
a7206b24ca pkg/compiler: check and generate types
Move most of the logic from sysgen to pkg/compiler.

Update #217
2017-09-02 13:06:53 +02:00
Dmitry Vyukov
838e336594 sys, prog: switch values to to uint64
We currently use uintptr for all values.
This won't work for 32-bit archs.
Moreover in some cases we use uintptr but assume
that it is always 64-bits (e.g. in encodingexec).
Switch everything to uint64.

Update #324
2017-08-19 10:16:23 +02:00
Dmitry Vyukov
32e29dda2c pkg/repro: fix invalid options minimization
Repro can generate Sandbox="namespace"/UseTmpDir=false.
This combination is broken for two reasons:
 - on second and subsequent executions of the program,
   it fails to create syz-tmp dir
 - with Procs>1, it fails right away, because all procs
   try to create syz-tmp dir

Don't generate such combination.
2017-08-09 15:41:52 +02:00
Dmitry Vyukov
8b78527436 pkg/csource, pkg/repro: filter out invalid options combinations
We currently have 2 invalid options combinations:
 - collide without threads
 - procs>1 without repeat
They are invalid in the sense that result of csource.Write
is the same for them. Filter out these combinations.
This cuts csource testing time in half and reduces repro minimization time.
2017-08-09 15:41:52 +02:00
Dmitry Vyukov
a3c5751de3 executor: sandbox with RLIMIT_MEMLOCK
Locking memory is a reasonably legitimate local DoS vector.
E.g. bpf maps allow allocation of large chunks of kernel memory
without RLIMIT_MEMLOCK, which leads to hangups.
Set RLIMIT_MEMLOCK=8MB in executor.
2017-08-08 13:24:46 +02:00
Andrey Konovalov
e83310d8a2 pkg/csource: make all usleeps random
We can't know the exact values of those sleeps in advance, they can be
different for different bugs. Making them random increases the chance that
the C repro executes with the right timings at some point.
2017-07-24 14:22:54 +02:00
Dmitry Vyukov
6231964849 pkg/csource: reformat 2017-07-05 19:45:25 +02:00
Andrey Konovalov
d50208f93e pkg/csourse: don't generate __NR_X defines for old syscalls 2017-07-05 15:46:38 +02:00
Dmitry Vyukov
a7b199253f all: use consistent file permissions
Currently we have unix permissions for new files/dirs
hardcoded throughout the code base. Some places use 0644,
some - 0640, some - 0600 and a variety of other constants.

Introduce osutil.MkdirAll/WriteFile that use the default
permissions and use them throughout the code base.

This makes permissions consistent and also allows to easily
change the permissions later if we change our minds.

Also merge pkg/fileutil into pkg/osutil as they become
dependent on each other. The line between them was poorly
defined anyway as both operate on files.
2017-07-03 14:00:47 +02:00
Dmitry Vyukov
d8daf57eca pkg/csource: regenerate 2017-06-26 15:34:54 +02:00
Dmitry Vyukov
baad3b4b02 pkg/csource: move from csource 2017-06-17 14:41:15 +02:00