Commit Graph

208 Commits

Author SHA1 Message Date
Dmitry Vyukov
8fa0c867d4 syz-fuzzer: generates hints only for the call that gave new coverage
During smashing we know what call gave new coverage,
so we can concentrate just on it.
This helps to reduce amount of hints generated (we have too many of them).
2017-10-23 09:59:39 +02:00
Dmitry Vyukov
5044885ca2 prog: add a TODO for hints 2017-10-23 09:59:39 +02:00
Dmitry Vyukov
4f9fc95501 prog: fix bugs in hints generation
Add a random hints test and fix bugs it uncovers.
2017-10-23 09:59:39 +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
354c324465 syz-fuzzer: don't send/check CallIndex for inputs
The call index check episodically fails:

2017/10/02 22:07:32 bad call index 1, calls 1, program:

under unknown circumstances. I've looked at the code again
and don't see where/how we can mess CallIndex.
Added a new test for minimization that especially checks resulting
CallIndex.
It would be good to understand what happens, but we don't have
any reproducers. CallIndex is actually unused at this point.
Manager only needs call name. So remove CallIndex entirely.
2017-10-10 10:41:27 +02:00
Dmitry Vyukov
8cb7d3dcfc all: initial support for fuchsia
Nothing works, but builds.

Update #191
2017-09-20 21:19:29 +02:00
Dmitry Vyukov
539e603206 syz-manager, syz-fuzzer, executor: ensure that binaries are consistent
Check that manager/fuzzer/executor are build on the same git revision,
use the same syscall descriptions and the same target arch.

Update #336
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
91def5c506 prog: remove special knowledge about "mmap" syscall
Abstract "mmap" away as it can be called differently on another OS.
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
34bc139642 sys: compile all supported targets into the package
Currently we compile in only GOOS/GOARCH target.
Compile in all targets so that they can be selected at runtime.
2017-09-15 16:02:37 +02:00
Dmitry Vyukov
4a7f7fab1e prog: allow more than 1 target 2017-09-15 16:02:37 +02:00
Dmitry Vyukov
0ed1da4a12 prog: remove unused declaration 2017-09-05 19:02:12 +02:00
Dmitry Vyukov
e52bd33700 prog: move resource-related functions to a separate file 2017-09-05 19:02:12 +02:00
Dmitry Vyukov
eb45aa4244 prog, sys: move dictionary of special strings to sys
It is target-specific.
2017-09-05 19:02:12 +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
4fc4702694 prog: dot-import sys
In preparation for moving sys types to prog to reduce later diffs.
2017-09-05 10:46:34 +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
1c0d4caf7c sys: change BitfieldLast to BitfieldMiddle
That's the condition we always want.
Currently we always check:
t.BitfieldOffset() == 0 || t.BitfieldLast()
now can check just:
!t.BitfieldMiddle()
2017-09-04 20:51:56 +02:00
Dmitry Vyukov
b6e402dd48 sys: remove IntSignalno 2017-09-04 20:25:23 +02:00
Dmitry Vyukov
399addc875 sys, pkg/compiler: move padding computation to compiler
This makes types constant during execution, everything is precomputed.
2017-09-04 20:25:23 +02:00
Dmitry Vyukov
a5c115a64b prog: move ptrSize const to test
It is used only by a single test. Remove it from non-test code.
2017-09-04 20:25:22 +02:00
Dmitry Vyukov
8c64b078d1 pkg/compiler: detect resources without ctors
Fixes #217
2017-09-04 20:25: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
Victor Chibotaru
aa51461a34 hints: add some more tests for DataArg 2017-09-01 18:14:53 +02:00
Victor Chibotaru
d9a07bf6e9 hints: add new mutations and tests 2017-09-01 17:17:08 +02:00
Victor Chibotaru
49c11eb514 ipc, prog, fuzzer, execprog: add hints generation code
A hint is basically a tuple consisting of a pointer to an argument
in one of the syscalls of a program and a value, which should be
assigned to that argument.

A simplified version of hints workflow looks like this:
    1. Fuzzer launches a program and collects all the comparisons' data
for every syscall in the program.
    2. Next it tries to match the obtained comparison operands' values
vs. the input arguments' values.
    3. For every such match the fuzzer mutates the program by
replacing the pointed argument with the saved value.
    4. If a valid program is obtained, then fuzzer launches it and
checks if new coverage is obtained.

This commit includes:
    1. All the code related to hints generation, parsing and mutations.
    2. Fuzzer functions to launch the process.
    3. Some new stats gathered by fuzzer and manager, related to hints.
    4. An updated version of execprog to test the hints process.
2017-08-30 18:40:14 +02:00
Victor Chibotaru
07c84b670b executor, ipc: modify the IO between KCOV<->executor<->fuzzer
Now executor is able to read comparisons data from KCOV and write them
to fuzzer.
2017-08-30 18:40:14 +02:00
Dmitry Vyukov
9ec49e082f prog: restore missing struct fields
We already do this for syscall arguments.
Helps to save some old programs after description changes.
2017-08-25 21:56:07 +02:00
Dmitry Vyukov
f238fbd42d all: support i386 arch
Update #191
2017-08-19 19:17:27 +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
6a0246bf72 prog: simplify code
Result of running gofmt -s.
2017-08-14 14:32:23 +02:00
Dmitry Vyukov
0939075822 prog: reuse defaultArg
Reuse defaultArg in generateArg. There is code that does the same.
Also, don't generate pointer value for output arguments.
2017-08-09 10:38:38 +02:00
Dmitry Vyukov
c3ba5e72f5 prog: fix restoration of default arguments
Currently fails on:
 - pointers
 - VMAs
 - structs
 - fixed-size structs
2017-08-09 10:28:10 +02:00
Alexander Potapenko
d8b0de2df3 prog: reduce the "uber-mmap" size
During minimization we create a single memory mapping that contains all
the smaller mmap() ranges, so that other mmap() calls can be dropped.
This "uber-mmap" used to start at 0x7f0000000000 regardless of where the
smaller mappings were located. Change its starting address to the
beginning of the first small mmap() range.
2017-08-08 17:57:01 +02:00
Alexander Potapenko
77825d061d prog: don't mutate mmap() calls too often
Due to https://github.com/google/syzkaller/issues/316 there're too many
mmap() calls in the programs, and syzkaller is spending quite a bit of
time mutating them. Most of the time changing mmap() calls won't give
us new coverage, so let's not do it too often.
2017-08-02 16:20:28 +02:00
Andrey Konovalov
1517bd9548 prog: generate missing syscall args when decoding
After a change in syscall description the number of syscall arguments
might change and some of the programs in corpus get invalidated.

This change makes syzkaller to generate missing arguments when decoding a
program as an attempt to fix and keep more programs from corpus.
2017-08-01 19:19:05 +02:00
Andrey Konovalov
1172db0ccf prog: fix encoding for exec of result args
ResultArg might have const value.

Also add a test.
2017-08-01 18:38:20 +02:00
Andrey Konovalov
493773c70d prog: properly remove calls when splicing progs
Use removeCall() to update use references.

Also add a test and speed up other ones.
2017-08-01 15:57:03 +02:00
Andrey Konovalov
2b21a44565 prog: return error instead of panic when parsing 2017-07-24 16:37:24 +02:00
Andrey Konovalov
94f1595a77 prog: allow recursion for optional pointers
When syzkaller generates arg that uses a few structs that reference each
other via pointers, it can go into infinite recursion and crash.

Fix this by forcing pointer args to be null when the depth of recursion
reaches 3 for some struct.
2017-07-19 15:46:50 +02:00
Andrey Konovalov
cfc46d9d0b prog: split Arg into smaller structs
Right now Arg is a huge struct (160 bytes), which has many different fields
used for different arg kinds. Since most of the args we see in a typical
corpus are ArgConst, this results in a significant memory overuse.

This change:
- makes Arg an interface instead of a struct
- adds a SomethingArg struct for each arg kind we have
- converts all *Arg pointers into just Arg, since interface variable by
  itself contains a pointer to the actual data
- removes ArgPageSize, now ConstArg is used instead
- consolidates correspondence between arg kinds and types, see comments
  before each SomethingArg struct definition
- now LenType args that denote the length of VmaType args are serialized as
  "0x1000" instead of "(0x1000)"; to preserve backwards compatibility
  syzkaller is able to parse the old format for now
- multiple small changes all over to make the above work

After this change syzkaller uses twice less memory after deserializing a
typical corpus.
2017-07-17 14:34:09 +02:00
Andrey Konovalov
d14bf09d4c prog: fix PtrType generation
The inner return value can't be nil, arguments are always created now.
2017-06-27 12:41:07 +02:00
Andrey Konovalov
b3ea23c379 repro: always minimize over EnableTun 2017-06-12 19:48:23 +02:00
Andrey Konovalov
4d1df73af9 csource: force enable tun flag when required 2017-06-12 19:48:23 +02:00
Dmitry Vyukov
09ec77612c prog: extend output on validation error 2017-06-06 17:21:00 +02:00
Dmitry Vyukov
46c6ed89bf pkg/ifuzz: move from ifuzz 2017-06-03 10:41:09 +02:00
Dmitry Vyukov
0fcd5fd3dd all: speed up tests
Mark tests as parallel where makes sense.
Speed up sys.TransitivelyEnabledCalls.

Execution time is now:

ok  	github.com/google/syzkaller/config		0.172s
ok  	github.com/google/syzkaller/cover		0.060s
ok  	github.com/google/syzkaller/csource		3.081s
ok  	github.com/google/syzkaller/db			0.395s
ok  	github.com/google/syzkaller/executor		0.060s
ok  	github.com/google/syzkaller/fileutil		0.106s
ok  	github.com/google/syzkaller/host		1.530s
ok  	github.com/google/syzkaller/ifuzz		0.491s
ok  	github.com/google/syzkaller/ipc			1.374s
ok  	github.com/google/syzkaller/log			0.014s
ok  	github.com/google/syzkaller/prog		2.604s
ok  	github.com/google/syzkaller/report		0.045s
ok  	github.com/google/syzkaller/symbolizer		0.062s
ok  	github.com/google/syzkaller/sys			0.365s
ok  	github.com/google/syzkaller/syz-dash		0.014s
ok  	github.com/google/syzkaller/syz-hub/state	0.427s
ok  	github.com/google/syzkaller/vm			0.052s

However, main time is still taken by rebuilding sys package.

Fixes #182
2017-05-29 13:15:07 +02:00
Dmitry Vyukov
220dc49106 csource: reproduce crashes with fault injection 2017-05-26 17:22:57 +02:00