Commit Graph

611 Commits

Author SHA1 Message Date
Dmitry Vyukov
a793204dd2 pkg/compiler: fix corner case in alignment calculation 2018-02-19 21:48:20 +01:00
Dmitry Vyukov
d9222fc03a pkg/report: improve ODEBUG bug reports 2018-02-19 21:48:20 +01:00
Dmitry Vyukov
75a7c5e2d1 prog: rework address allocation
1. mmap all memory always, without explicit mmap calls in the program.
This makes lots of things much easier and removes lots of code.
Makes mmap not a special syscall and allows to fuzz without mmap enabled.

2. Change address assignment algorithm.
Current algorithm allocates unmapped addresses too frequently
and allows collisions between arguments of a single syscall.
The new algorithm analyzes actual allocations in the program
and places new arguments at unused locations.
2018-02-19 21:48:20 +01:00
Dmitry Vyukov
6051a5b552 prog: combine RequiresBitmasks and RequiresChecksums into RequiredFeatures 2018-02-19 21:48:20 +01:00
Dmitry Vyukov
dd768bf1c6 prog: reorder Minimize arguments
Make the predicate the last argument.
It's more common and convenient (arguments are not separated by multiple lines).
2018-02-19 21:48:20 +01:00
Dmitry Vyukov
833f78c7b0 executor: fix build
Older versions of linux require an additional header.
2018-02-17 19:11:57 +01:00
Dmitry Vyukov
9df1a36a98 sys/linux: add bridge netfilter support 2018-02-17 19:02:12 +01:00
Dmitry Vyukov
414c035582 pkg/compiler: support template template arguments
Can be useful for netfilter descriptions.
2018-02-17 19:02:12 +01:00
Dmitry Vyukov
dd4fcef5a2 pkg/compiler: allow len of var-len arrays
All netfilter subsystems use this unfortunately,
so demote this to a warning.
2018-02-17 19:02:12 +01:00
Dmitry Vyukov
77ed06bf16 pkg/report: skip mm/util.c in guilty files 2018-02-14 20:17:11 +01:00
Dmitry Vyukov
88bc17df05 pkg/report: improve corrupted report detection
Detect informational kernel reports that are not bugs in itself,
but contain stack traces. If we see them in the middle of another
report, we know stacks are intermixed and the report is potentially
corrupted.
2018-02-12 11:26:51 +01:00
Dmitry Vyukov
4e9b726d97 pkg/report: harden more against corrupted reports 2018-02-10 13:35:21 +01:00
Dmitry Vyukov
7d9727902f pkg/report: better titles for some kmalloc bugs 2018-02-10 12:33:20 +01:00
Dmitry Vyukov
e67d44e011 executor: compile with -O2
We don't frequently debug it and it does some intensive computations
on coverage, so no reason to not compile with -O2.
2018-02-10 12:14:13 +01:00
Dmitry Vyukov
2b6b214cf2 pkg/csource: fix debug calls
debug calls are only properly stripped if they are on a single line.
2018-02-09 20:31:41 +01:00
Dmitry Vyukov
033b610ec9 sys/linux: improve netfilter descriptions
Put the underflow entry at the end.
Entries must end on an unconditional, non-goto entry,
otherwise fallthrough from the last entry is invalid.

Add arp tables support.

Split unspec matches/targets to unspec and inet.

Reset ipv6 and arp tables in executor.

Fix number of counters in tables.

Plus a bunch of assorted fixes for matches/targets.
2018-02-09 20:14:33 +01:00
Dmitry Vyukov
9fb5ec4367 pkg/report: special-case extraction of guilty file for rcu stalls 2018-02-07 14:22:10 +01:00
Dmitry Vyukov
d2473bc545 pkg/report: improve guilty frame extraction
1. Make extractStackFrame more picky about stray frames.
This fixes some TODO's in tests where we matched completley
unrelated frames printed by another task.

2. Extract KASAN guilty frame from report header
if the frame should not be skipped (e.g. not __lock_acquire).
This makes parsing more tolerant to corrupted reports.
2018-02-07 13:46:35 +01:00
Dmitry Vyukov
f34079dbcf pkg/report: detect when several reports are intermixed
If there are more than one report, detect where the second
report starts and extract description only from the first report.
There are too many cases where several reports gets intermixed
and as the result we extract bogus description.
2018-02-07 09:41:12 +01:00
Dmitry Vyukov
66c15deb7a pkg/report: fix KASAN report parsing
We did not skip kasan_check_read.
Also don't let stack parsing to silently sink to another stack trace.
2018-02-06 15:29:56 +01:00
Dmitry Vyukov
645ce5da79 pkg/report: improve report titles
1. Replace stacktraceRe with custom code which is more flexible.
stacktraceRe stumbled on any unrelated lines and
could not properly parse truncated stacks.

2. Match report regexp earlier.
If we match simler title regexp, but don't match
report regexp or fail to parse stack trace, the report is corrupted.
This eliminates lots of duplicate corrupted oops entries,
which were there only because we had complex regexp's in titles.

3. Ignore low-level frames during stack parsing.
E.g. we never want to report a GPF in lock_acquire or memcpy
(somewhat similar to what we do for guilty files).

4. Add a bunch of specialized formats for WARNINGs.
There is number of generic debugging facilities (like ODEBUG,
debug usercopy, kobject, refcount_t, etc), and the bug
is never in these facilities, it's in the caller instead.

5. Improve some other oops formats.

6. Add a bunch of additional tests.

This resolves most of TODOs in tests.
Fixes #515
2018-02-06 14:44:03 +01:00
Dmitry Vyukov
e86ddaca2e sys/syz-extract: save unsupported consts to the const files
We currently print unsupported consts to console during make extract.
But this is not very useful as there are too many output now.
This also does not allow to understand what's unsupported
in newly checked-in descriptions, or what's unsupported in all current
decriptions.

Save unsupported consts to the const files instead.
This solves all of the above problems.
2018-02-01 20:18:51 +01:00
Dmitry Vyukov
e525e980ea pkg/report: add more TODO cases 2018-02-01 15:49:05 +01:00
Dmitry Vyukov
08d47756d0 executor: fix 32-bit support
ipt_get_entries.entrytable must be pointer aligned,
so in 32-bit build there is no padding before it.
2018-01-28 09:17:03 +01:00
Dmitry Vyukov
08146b1a84 sys/linux: extend netfilter descriptions 2018-01-27 17:08:43 +01:00
Dmitry Vyukov
e8b4970547 pkg/compiler: allow unions with only 1 field
Unions with only 1 field are not actually unions,
and can always be replaced with the option type.
However, they are still useful when there will be
more options in future but currently only 1 is described.
Alternatives are:
 - not using union (but then all existing programs will be
   broken when union is finally introduced)
 - adding a fake field (ugly and reduces fuzzer efficiency)

Allow unions with only 1 field.
2018-01-27 17:08:43 +01:00
Dmitry Vyukov
1d18b11287 pkg/report: fix guilty file regexps 2018-01-25 10:57:31 +01:00
Dmitry Vyukov
866f1102f7 pkg/email: handle emails without Content-Type header
git-send-email sends emails without Content-Type,
let's assume it's text.
2018-01-24 19:37:00 +01:00
Dmitry Vyukov
ca9c302d80 pkg/compiler, prog: fix template parent lens
It's possible that a struct can have 2+ parents,
which is the same template (differs only by arguments).
See the new test case.
Support such case.
2018-01-24 11:35:22 +01:00
Dmitry Vyukov
a5b7566c4a executor: handle old and new selinux mount points 2018-01-23 12:56:00 +01:00
Dmitry Vyukov
3d76cc40d9 pkg/compiler: fix len of parent template struct
Consider the following example:

type len_templ1[DATA1, DATA2] {
	data	DATA1
	inner	len_temp2[DATA2]
}

type len_temp2[DATA] {
	data	DATA
	len	len[len_templ1, int8]
}

Here len refers to a parent struct, but the struct is a template,
so it's actual name is something like "len_templ1[int8, int16]".
Currently this does not work as compiler barks at incorrect
len target.

Make this work.
2018-01-23 11:38:53 +01:00
Dmitry Vyukov
14d1e424b6 pkg/compiler: allow use of empty strings
This comes up in several contexts in netfilter.
2018-01-23 11:05:51 +01:00
Dmitry Vyukov
de3e24c4b6 pkg/compiler: allow strings as template arguments
Needed for netfilter descriptions.
2018-01-23 10:44:01 +01:00
Dmitry Vyukov
40a6602675 sys/linux: add netfilter descriptions
Lots of TODOs and only ipv4, but some start.
2018-01-22 12:19:33 +01:00
Dmitry Vyukov
b7f99b54ae sys/linux: more selinux descriptions 2018-01-18 19:58:49 +01:00
Dmitry Vyukov
3661e26e74 pkg/compiler: support non-zero-terminated strings
Add stringnoz type.
2018-01-18 18:48:39 +01:00
Dmitry Vyukov
c77c36d5fa pkg/report: add another negative test case 2018-01-18 14:55:44 +01:00
Dmitry Vyukov
dcf3aa89fe pkg/report: allow up to 15 lines from "Call Trace" to first frame
Fixes a bunch of reports incorrectly marked as corrupted.
2018-01-18 10:28:07 +01:00
Dmitry Vyukov
d7bc58204e dashboard/app: collect more info for better reports
Collect kernel build commit title/date.
Add support for kernel repo aliases (to be able
to say linux-next instead of full git repo address).
Collect on what managers a bug happened.
Reuse Crash.ReportLen as generic crash reporting priority.
Make it possible to prioritize reporting of particular
kernel repos and arches.

Fixes #473
2018-01-17 19:52:30 +01:00
Dmitry Vyukov
a46e53184f pkg/git: fix potential hang
If extractFixTags exits early with error,
git process will hang due to stdout overflow
and never exit.
2018-01-16 18:46:04 +01:00
Dmitry Vyukov
c206e64a01 syz-ci: use the original syzkaller commit for patch testing
Currently we use the latest syzkaller commit that syz-ci uses itself.
As the result syz-execprog can fail to deserialize the reproducer.
Use the original syzkaller commit.
2018-01-16 13:37:14 +01:00
Dmitry Vyukov
837a69870d pkg/report: add another TODO test case 2018-01-15 20:21:30 +01:00
Dmitry Vyukov
b705c02263 executor: fix tun/device setup for sandbox=namespace
For sandbox=namespace we first create network devices
and then do CLONE_NEWNS, which brings us into a new
namespace which actually does not have any of these devices.
Tun mostly worked, because we hold fd to the tun device.
However, even for tun we could not see the "syz0" device.
2018-01-15 19:09:16 +01:00
Dmitry Vyukov
212f927d3c executor: setup network devices
We test in a new network namespace, which does not have any
devices set up (even lo). Create/up as many devices as possible.
Give them some addresses and use these addresses in descriptions.
2018-01-13 12:52:09 +01:00
Dmitry Vyukov
9ea6693e1b pkg/compiler: allow string/array as template type 2018-01-13 12:52:09 +01:00
Dmitry Vyukov
a94baff95e sys/syz-sysgen: don't generate syz_ syscall numbers
They don't seem to be used today.
2018-01-13 12:52:09 +01:00
Dmitry Vyukov
5585946e22 pkg/compiler: support void type
"void": type with static size 0
	mostly useful inside of templates and varlen unions
	can't be syscall argument
2018-01-13 12:52:09 +01:00
Dmitry Vyukov
6b52293f4d pkg/compiler: support type templates
Netlink descriptions contain tons of code duplication,
and need much more for proper descriptions. Introduce
type templates to simplify writing such descriptions
and remove code duplication.

Note: type templates are experimental, have poor error handling
and are subject to change.

Type templates can be declared as follows:

```
type buffer[DIR] ptr[DIR, array[int8]]
type fileoff[BASE] BASE
type nlattr[TYPE, PAYLOAD] {
	nla_len		len[parent, int16]
	nla_type	const[TYPE, int16]
	payload		PAYLOAD
} [align_4]
```

and later used as follows:

```
syscall(a buffer[in], b fileoff[int64], c ptr[in, nlattr[FOO, int32]])
```
2018-01-13 12:52:09 +01:00
Dmitry Vyukov
9dc808a65e pkg/ast: refactor Walk
Refactor Walk so that it's possible to abort or wrap walk of child nodes.
Will be needed for future changes.
2018-01-11 11:45:35 +01:00
Dmitry Vyukov
7a4d53c30f pkg/report: add test where we fail to provide good title 2018-01-11 11:45:35 +01:00
Dmitry Vyukov
02a19b646c syz-manager: add comment explaining why we don't set corrupted for repros 2018-01-10 09:41:28 +01:00
Dmitry Vyukov
6bfc81c142 syz-fuzzer: improve kmemleak support
Don't print object size (can change from kernel to kernel
and from config to config).
Fix function extraction regexp (must be non-eager).
Account for MSECS_MIN_AGE.
Ignore some known false positives.
2018-01-09 21:24:29 +01:00
Dmitry Vyukov
1014e5506e pkg/report: ignore kernel/workqueue.c as guilty file 2018-01-08 12:56:44 +01:00
Dmitry Vyukov
66288e0e0b pkg/compiler: add builtin bool type aliases
This adds builtin:

type bool8 int8[0:1]
type bool16 int16[0:1]
type bool32 int32[0:1]
type bool64 int64[0:1]
type boolptr intptr[0:1]

We used to use just int's for bools.
But bool types provide several advantages:
 - make true/false probability equal
 - improve description expressiveness
 - reduce search space (we will take advantage of this later)
2018-01-08 12:52:31 +01:00
Dmitry Vyukov
f01cb93788 pkg/compiler: make signalno a type alias
We don't need compiler support for such things anymore,
now we simply can do:

type signalno int32[0:65]
2018-01-08 12:52:31 +01:00
Dmitry Vyukov
402a0dc87e sys: support type aliases (aka typedefs)
Complex types that are often repeated can be given short type aliases using the
following syntax:

```
type identifier underlying_type
```

For example:

```
type signalno int32[0:65]
type net_port proc[20000, 4, int16be]
```

Then, type alias can be used instead of the underlying type in any contexts.
Underlying type needs to be described as if it's a struct field, that is,
with the base type if it's required. However, type alias can be used as syscall
arguments as well. Underlying types are currently restricted to integer types,
`ptr`, `ptr64`, `const`, `flags` and `proc` types.
2018-01-08 12:52:31 +01:00
Dmitry Vyukov
93b4c6f135 pkg/report: add few more test cases where we fail 2018-01-08 12:46:51 +01:00
Dmitry Vyukov
8dc787547e pkg/report: add tests where we produce bad title 2018-01-06 17:40:52 +01:00
Dmitry Vyukov
a8927abe6c prog: support opt for proc types 2018-01-06 17:40:49 +01:00
Dmitry Vyukov
8e6b9eeb27 pkg/compiler: add bitsize type
This is need for few crypto/xfrm descriptions.
2018-01-06 17:40:36 +01:00
Dmitry Vyukov
bb0359b914 pkg/ipc: always prepend handshake errors with executor pid
Helps to understand what program caused it.
2018-01-06 17:39:19 +01:00
Dmitry Vyukov
053171eaf2 pkg/csource: fix build of generated files
On another machine both clang and gcc produce:

test.c:163:32: error: invalid suffix "+procid" on integer constant
       *(uint32_t*)0x20001004 = 0x25dfdbfe+procid*4;

Not sure why this wasn't caught on buildbot.
2018-01-06 15:26:40 +01:00
Dmitry Vyukov
7b28cc9307 pkg/report: add few tests where we mis-detect title/guilty file 2018-01-06 15:10:54 +01:00
Dmitry Vyukov
342feda2bf pkg/report: don't treat CONFIG_DEBUG_OBJECTS debug output as bugs 2018-01-06 14:54:09 +01:00
Dmitry Vyukov
6deb615310 sys/linux: fix some copy-paste errors 2017-12-28 19:16:42 +01:00
Dmitry Vyukov
f9e22d6230 pkg/email: don't add <> to email when name is empty
Just unnecessary clutter.
2017-12-28 08:51:39 +01:00
Dmitry Vyukov
086787dd7e pkg/csource: tidy up generated code a bit
Remove dup newlines around includes.
Makes int values shorter if not hurting readability.
Increase line len to 80.
Remove {} when not needed during copyout.
2017-12-27 20:02:58 +01:00
Dmitry Vyukov
fd3e9f2b97 executor: introduce uint64/32/16/8 types
The "define uint64_t unsigned long long" were too good to work.
With a different toolchain I am getting:

cstdint:69:11: error: expected unqualified-id
  using ::uint64_t;
          ^
executor/common.h:34:18: note: expanded from macro 'uint64_t'

Do it the proper way: introduce uint64/32/16/8 types and use them.

pkg/csource then does s/uint64/uint64_t/ to not clutter code with
additional typedefs.
2017-12-27 11:15:04 +01:00
Dmitry Vyukov
34c18f5f43 executor: fix another format bug
Detected only by clang.
2017-12-27 10:21:12 +01:00
Dmitry Vyukov
09c8f4c00a pkg/report: add more cases where we fail to parse reports 2017-12-27 09:18:26 +01:00
Dmitry Vyukov
17f5c9e05f pkg/csource: add top-level repeat loop
Even if all 3 levels of processes in executor exit,
execprog will still recreate them.
Model the same in csource.
This matters when the inner process kills loop
and then everything stops.
2017-12-27 09:18:26 +01:00
Dmitry Vyukov
c1d8c1b352 pkg/csource: simplify generated code
We already have procid variable, no need to introduce i.
2017-12-27 09:18:26 +01:00
Dmitry Vyukov
b7b7ac19fd executor: check format strings
I see a crash which says:

	#0: too much cover 0 (errno 0)

while the code is:

	uint64_t n = ...;
	if (n >= kCoverSize)
		fail("#%d: too much cover %u", th->id, n);

It seems that the high part of n is set, but we don't see it.

Add printf format attribute to fail and friends and fix all similar cases.
Caught a bunch of similar cases and a missing argument in:

exitf("opendir(%s) failed due to NOFILE, exiting");
2017-12-27 09:18:26 +01:00
Dmitry Vyukov
6f03c35620 dashboard/app: extract fixing tags from commits
Support the new scheme of associating fixing commits with bugs.
Now we provide a tag along the lines of:

Reported-by: <syzbot+a4a91f6fc35e102@syzkaller.appspotmail.com>

The tag is supposed to be added to the commit.
Then we parse commit logs and extract these tags.

The final part on the dashboard is not ready yet,
but syz-ci should already parse and send the tags.
2017-12-27 09:09:18 +01:00
Dmitry Vyukov
8e40909025 pkg/csource: mimic the way syscalls are scheduled in executor
Currently csource uses completely different, simpler way of scheduling
syscalls onto threads (thread per call with random sleeps).
Mimic the way calls are scheduled in executor.

Fixes #312
2017-12-22 18:55:38 +01:00
Dmitry Vyukov
26cd53f078 executor: remove dead code
doexit already contains an infinite loop.
2017-12-22 13:42:27 +01:00
Dmitry Vyukov
3645389673 pkg/csource: fix handling of proc types
Generated program always uses pid=0 even when there are multiple processes.
Make each process use own pid.

Unfortunately required to do quite significant changes to prog,
because the current format only supported fixed pid.

Fixes #490
2017-12-22 11:59:46 +01:00
Dmitry Vyukov
6f298a18e5 pkg/csource: limit thread stacks
We always set RLIMIT_AS to 128MB. I've debugged a program with 21 syscalls.
With collide it creates 42 threads. With default stack size of 8MB this
requires: 42*8 = 336MB. Thread creation fails and nothing works.
Limit thread stacks the same way executor does.

Fixes #488
2017-12-22 11:59:46 +01:00
Dmitry Vyukov
7b62abdb0a pkg/csource: fix string escaping bug 2017-12-22 11:59:46 +01:00
Dmitry Vyukov
af9163c763 pkg/report: add test where we fail to detect guilty function 2017-12-19 13:44:03 +01:00
Dmitry Vyukov
779a655b43 pkg/report: add test where we fail to detect corrupted report 2017-12-19 13:39:14 +01:00
Dmitry Vyukov
a87e30dc1b pkg/email: improve parsing of splitted lines
Allow:

full-commit-title-on-next-line

This allows commit titles between 70 and 80 cols with gmail.

Also be more permissive wrt spaces and tabs.
2017-12-19 13:36:40 +01:00
Dmitry Vyukov
d30c3e81eb pkg/report: add test for a bug in report parsing 2017-12-18 15:34:08 +01:00
Dmitry Vyukov
a20097eafe syz-manager, syz-fuzzer: allow re-minimizing/re-smashing inputs
By default we don't re-minimize/re-smash programs from corpus,
it takes lots of time on start and is unnecessary.
However, when we improve/fix minimization/smashing,
we may want to.

Introduce corpus database versions and allow to re-minimize/re-smash
on version bumps.
2017-12-18 14:10:56 +01:00
Dmitry Vyukov
0d231ceb73 syz-fuzzer: refactor
syz-fuzzer organically grew from a small nice main function
into a huge single-file monster with tons of global state.

Start refactoring it into something more managable.
This change separates 2 things:
1. Proc: a single fuzzing process (ipc.Env wrapper).
2. WorkQueue: holds global non-fuzzing work items.
More work needed, but this is good first step.
2017-12-18 09:50:17 +01:00
Dmitry Vyukov
d5beb42ace pkg/csource: make strings more readable
If string contains a file name or a crypto alg name,
don't escape it all to hex.
2017-12-17 11:39:14 +01:00
Dmitry Vyukov
a33677f8bf prog: use dense indexes for copyout instructions
Fixes #174
2017-12-17 11:39:14 +01:00
Dmitry Vyukov
fea5478f46 prog: add DeserializeExec
Factor out program parsing from pkg/csource.
csource code that parses program and at the same time
formats output is very messy and complex.
New aproach also allows to understand e.g.
when a call has copyout instructions which is
useful for better C source output.
2017-12-17 11:39:14 +01:00
Dmitry Vyukov
431d3c90b1 pkg/csource: refactor
csource.go is too large and messy.
Move Build/Format into buid.go.
Move generation of common header into common.go.
Split generation of common header into smaller managable functions.
2017-12-17 11:39:14 +01:00
Dmitry Vyukov
c5826ff7aa pkg/ipc: make threaded/collide per-program options
Currently threaded/collide are global environment flags.
It can be useful to turn off collider during some executions
(minimization, triage, etc).
Make them per-program options.
2017-12-17 11:39:14 +01:00
Dmitry Vyukov
eaeccee1d7 pkg/report: add another test 2017-12-17 11:39:14 +01:00
Dmitry Vyukov
019cf5f235 sys: move test syscalls to a separate target
We have them in linux solely for historical reasons.

Fixes #462
2017-12-17 11:39:14 +01:00
Andrey Konovalov
ea8dc17ee9 executor: fix macros in common.h 2017-12-14 08:54:55 +01:00
Andrey Konovalov
06ea774dca pkg/report: fix __this_cpu_* report header call trace capture 2017-12-13 19:48:13 +01:00
Dmitry Vyukov
414a185f4d pkg/report: add another corruped report format 2017-12-12 15:35:21 +01:00
Dmitry Vyukov
433029d5d4 pkg/report: add another guilty file test 2017-12-12 14:23:28 +01:00
Dmitry Vyukov
32f694fc72 pkg/report: properly infer kernel location if kcov is not enabled
We used to infer kernel source location based on __sanitizer_cov_trace_pc symbol.
But it's not present if KCOV is not enabled.
Look at more symbols.
2017-12-12 14:02:59 +01:00
Dmitry Vyukov
4224245438 pkg/report: add few more corrupted reports 2017-12-12 13:51:27 +01:00
Dmitry Vyukov
867fe6a840 pkg/report: improve using __this_cpu_add() in preemptible code report 2017-12-12 13:40:08 +01:00
Dmitry Vyukov
1b3ae9a6d0 pkg/report: handle syzkaller binaries
syzkallerNNN binaries are coming from pkg/repro.
2017-12-12 13:29:45 +01:00
Dmitry Vyukov
081721ff15 pkg/report: clean guilty files 2017-12-12 12:24:52 +01:00
Dmitry Vyukov
7130893383 pkg/report: merge TestLinuxParseLog into TestParse
That was the last test that used inline input data.
Merge it into TestParse.
Test Output for all crashes in TestParse.
Support multiple oopes in crash
Add more test cases for start/end line.
2017-12-12 12:20:41 +01:00
Dmitry Vyukov
9d0132a2fb pkg/report: move guilty file test data to testdir/
linux_test.go is total mess and very hard to work with.
Turns out we had 2 tests that do exactly the same
(verify Report), but nobody ever noticed.

Move all test data to testdir/. One file per crash.
2017-12-12 11:59:13 +01:00
Dmitry Vyukov
1556ebc4cc pkg/report: move test data to testdir/
linux_test.go is total mess and very hard to work with.
Turns out we had 2 tests that do exactly the same
(verify Report), but nobody ever noticed.

Move all test data to testdir/. One file per crash.
2017-12-12 11:28:37 +01:00
Andrey Konovalov
8d4ab42605 pkg/report: bad unlock balance can be a WARNING 2017-12-11 16:01:10 +01:00
Andrey Konovalov
c0020ec197 pkg/report: detect corrupted old-style KASAN reports 2017-12-11 16:01:10 +01:00
Andrey Konovalov
02b8de13ac pkg/report: better detect corrupted stack traces
We may find stack frames from the second stack trace in a report when
searching from frames of the first one.
2017-12-11 16:01:10 +01:00
Andrey Konovalov
27f5dfefff pkg/report: improve report header extraction
Allow stack traces to be intermixed with random kernel messages that don't
start with a ' ' char (all frames in a stack trace do).

Also improve report headers for BUGs from mm/usercopy.c, as we get quite a
lot of those.
2017-12-11 14:42:45 +01:00
Andrey Konovalov
2d8c311ede pkg/report: fix corrupted call trace detection
linuxSymbolizeRe can match "IP: depot_fetch_stack+0x11/0x40", which is not
part of the call stack trace. Add another regexp that only matches frames.
2017-12-08 15:53:22 +01:00
Andrey Konovalov
20860a992a pkg/report: add arch/*/mm/fault.c to guilty file blacklist 2017-12-08 15:25:06 +01:00
Andrey Konovalov
38a2a3f586 pkg/report: fix report extraction
Try extracting report from console output only first. If that doesn't work,
try extracting it from the whole log.

Add regexp for executor printed BUGs.

Optimize regexps for rcu detected stalls.

Update rep.StartPos and rep.EndPos in vm/vm.go as well as rep.Output.
2017-12-08 15:08:13 +01:00
Dmitry Vyukov
71ac44a0c2 executor: fix build
exitf function was not defined with some combinations of options in csource.
Fix defines and switch exitf back to fail, fail already checks ENOMEM/EAGAIN,
so there is no reason to use exitf in this particular case.
2017-12-06 10:34:58 +01:00
Dmitry Vyukov
9a976e63d1 pkg/report: add proper oops format for kernel reboot 2017-12-05 20:08:06 +01:00
Andrey Konovalov
0796857b79 pkg/report: add log parsing test 2017-12-05 14:19:39 +01:00
Dmitry Vyukov
09582d5306 syz-manager: send public web addr to dashboard 2017-12-04 11:58:55 +01:00
Dmitry Vyukov
84a6637d28 pkg/report: add fuzz test
Found 3 bugs already.
Update #457
2017-12-04 11:10:12 +01:00
Dmitry Vyukov
7a5e495bdf pkg/report: fix out-of-bounds access
Update #457
2017-12-04 11:04:01 +01:00
Dmitry Vyukov
99ea3eaf5b pkg/report: test that Report is never empty
If Parse detects a crash, it must provide something in the Report field.
If Report is empty, something is wrong with parsing.

Update #457
2017-12-04 10:59:53 +01:00
Dmitry Vyukov
c92879679c pkg/report: extinguish panics
We see panic during report parsing as in #457.
This does not really fix them, but should stop managers crashing.

Update #457
2017-12-04 10:53:25 +01:00
Andrey Konovalov
e0375d3ee6 pkg/report: return raw log in Report.Output 2017-12-01 16:16:28 +01:00
Andrey Konovalov
5683420f11 pkg/report, pkg/repro: fix report parsing
pkg/repro expects pkg/report to return CrashStart index in the whole report,
not only in the kernel output.
2017-12-01 09:15:57 +01:00
Andrey Konovalov
16668351f6 pkg/report: improve task hung report headers 2017-11-30 22:35:35 +01:00
Dmitry Vyukov
5153aeaffd syz-ci: test images before using them
Boot and minimally test images before declaring them as good
and switching to using them.

If image build/boot/test fails, upload report about this to dashboard.
2017-11-30 14:50:50 +01:00
Andrey Konovalov
d5bd1f79fd pkg/report: improve trying to register non-static key header 2017-11-30 11:45:21 +01:00
Dmitry Vyukov
29b0fd90e6 pkg/report: include Maintainers into report
Currently getting a complete report requires a complex,
multi-step dance (including getting information that
external users are not interested in -- guilty file).

Simplify interface down to 2 functions: Parse and Symbolize.
Parse does what it did before, Symbolize symbolizes report
and fills in maintainers. This simplifies both implementations
of Reporter interface and all users of the interface.

Potentially we could get this down to 1 function Parse
that does everything. However, (1) Symbolize can fail,
while Parse cannot, (2) usually we want to ignore (log)
Symbolize errors, but otherwise proceed with the report,
(3) repro does not need symbolization for all but the
last report.
2017-11-29 18:24:30 +01:00
Andrey Konovalov
46c864566a pkg/report: improve bad unlock balance corruption detection 2017-11-29 15:18:44 +01:00
Dmitry Vyukov
34f2c2332b pkg/report: add Output to Report
Whole raw output is indivisble part of Report,
currently we always pass Output separately along with Report.
Make Output a Report field.

Then, put whole Report into manager Crash and repro context and Result.
There is little point in passing Report as aa bunch of separate fields.
2017-11-29 14:36:51 +01:00
Andrey Konovalov
19d272a98f pkg/report: detect suspicious RCU usage report corruption 2017-11-29 14:26:38 +01:00
Andrey Konovalov
4263b2afbe pkg/report: add sl*b.c to guilty blacklist 2017-11-29 13:45:46 +01:00
Andrey Konovalov
c2a67000b6 pkg/repro: rerun repro when report is corrupted 2017-11-29 13:23:31 +01:00
Andrey Konovalov
7bd85f2aea pkg/report: fix corrupted stack trace detection
Look for stack frames in the next 10 lines after 'Call Trace' instead of 3.
2017-11-28 15:54:13 +01:00
Dmitry Vyukov
ac93d7e1d8 pkg/compiler: add check that len does not refer to array with varlen elements
This [almost] always means a bug in descriptions.
Fix all bugs identified by the check.
2017-11-28 14:55:21 +01:00
Dmitry Vyukov
afba0b55e6 sys/linux: add binder descriptions 2017-11-27 15:09:30 +01:00
Dmitry Vyukov
8257de047b sys/linux: open files from /proc 2017-11-27 09:08:59 +01:00
Andrey Konovalov
6834199b8c pkg/report: various corrupted report detection improvements 2017-11-23 16:17:40 +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
31af2ce022 vm/gce: fix boot output capture
Turns out GetSerialPortOutput API does not work if instance has
serial port connections enabled (which we always have).
Get output from serial port relay service instead.
2017-11-22 17:56:48 +01:00
Andrey Konovalov
7bd6e42d35 pkg/report: fix corrupted reports detection
Add another regexp to oopses that should match the whole report.
Report is considered corrupted when it doesn't.
2017-11-22 16:12:55 +01:00
Andrey Konovalov
c8b87c9cf7 pkg/report: fix corrupted KASAN reports detection
KASAN report might not have Allocated or Freed stack traces at all.
2017-11-22 13:41:47 +01:00
Andrey Konovalov
53a23f2a37 pkg/report: corrupted report detection fixes 2017-11-22 13:17:21 +01:00
Dmitry Vyukov
657a01b951 pkg/email: ignore missing To: header
We've got such email.
2017-11-22 12:03:31 +01:00
Andrey Konovalov
e06afd3259 pkg/repro: don't bisect single entry 2017-11-22 11:45:38 +01:00
Dmitry Vyukov
ad0af9fff5 vm: return Report from MonitorExecution
This allows callers to get access to Report.Corrupted.
Better than adding 6-th return value and will allow
to pipe other report properties if necessary.
2017-11-21 19:02:35 +01:00
Dmitry Vyukov
f07ea3fc22 sys/linux: remove get_kernel_syms, add quotactl syscall
get_kernel_syms does not seem to be present upstream.
Describe an old quotactl syscall.
Also fix umount/umount2 names in kallsyms.
2017-11-20 17:23:24 +01:00
Dmitry Vyukov
9badd05327 vm/gce: provide VM console output on boot failures
"can't ssh into the instance" is not a very useful error.
2017-11-19 12:29:00 +01:00
Dmitry Vyukov
a1469efbdd pkg/email: unsplit arguments for test command 2017-11-17 20:43:47 +01:00
Dmitry Vyukov
00f6ff581c pkg/email: truncate garbage after patches 2017-11-17 18:54:19 +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
3fb087023a pkg/osutil: properly set gid for sandboxing 2017-11-17 14:28:45 +01:00
Dmitry Vyukov
e3d7179396 pkg/git: fix branch during fetch 2017-11-17 14:17:47 +01:00
Dmitry Vyukov
2f7fc0ff65 pkg/kernel: sandbox make invocation 2017-11-17 14:56:34 +03: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
Dmitry Vyukov
9a98ae3fb6 pkg/git: provide more helper functions
Add Patch, Checkout, CheckRepoAddress and CheckBranch.
Will be needed for patch testing.
2017-11-16 10:12:17 +01:00
Dmitry Vyukov
95cf3e7247 pkg/email: fix base64-encoded body parsing
We currently handle base64 only for attachments,
but text/plain body can also be base64-encoded.
2017-11-16 10:10:12 +01:00
Dmitry Vyukov
447a290a8c pkg/config: provide SaveData function
Parallel to LoadFile/LoadData.
2017-11-16 10:10:12 +01:00
Dmitry Vyukov
cf38de0018 pkg/report: avoid compiling a bunch of regexps on every crash 2017-11-14 10:16:27 +01:00
Dmitry Vyukov
bbbea5a373 pkg/report: pass report as []byte to isCorrupted
We always pass report/log as []byte.
Pass it here the same way for consistency and to avoid
unnecessary large memory allocation/copy.
2017-11-14 10:13:38 +01:00
Dmitry Vyukov
4bd78cef05 pkg/report, pkg/repro, syz-manager: name crash attributes consistently
We currently have several names for crash attributes, which is disturbing.
E.g. crash title is called "Title" or "Desc". Name them consistently.

Title - single line bug identity.
Report - whole crash text.
Log - whole fuzzer/kernel output.
2017-11-14 10:04:22 +01:00
Dmitry Vyukov
82b3b903a0 pkg/report: make isCorrupted linux-specific
isCorrupted is linux-specific, but is a global function.
Name can collide with other OSes. Make is linux method.
2017-11-14 09:47:44 +01:00
Dmitry Vyukov
10112655d7 vm: remove needOutput arg for MonitorExecution
Always wait 10 secs for output.
If anything this can only lead to missed crashes during repro.
Let's unify manager and repro behavior.
2017-11-14 09:45:34 +01:00
Dmitry Vyukov
7a53e7e35d pkg/report: combine report data into a struct
Parse returns 5 variables now. Later we may want to add crash "priority".
Introduce Report struct that holds all report data.
2017-11-14 09:41:55 +01:00
Andrey Konovalov
f9a8d567eb pkg/report: add corrupted report detection
This change makes pkg/report try to detect corrupted reports by
using some heuristics.
2017-11-13 17:18:16 +03: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
Dmitry Vyukov
6c412fa20c pkg/git: add another commit prefix 2017-11-08 14:16:36 +01:00
Andrey Konovalov
a2c64463a2 execprog: correctly handle fault injections
syz-execprog doesn't utilize info about fault injections from a prog log.
Since syz-execprog is used by the repro package to reproduce crashes,
crashes caused by fault injections might not reproduce.
2017-11-07 16:17:18 +01:00
Dmitry Vyukov
8f3e774b76 syz-ci: improve commit matching
1. Fetch last 200K commits instead of commits for past year.
For merged commits both author date and commit date can be
arbitrary long in past (e.g. we got a commit dated by 2014).

2. Strip some commit prefixes from commits.
We have some trees where backports are prefixed with "BACKPORT:".
Previously we could no match such commits.
2017-11-07 13:31:00 +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
6ddaf205ad dashboard/app: email fixes
1. Allows sending emails upstream.
2. Filter out duplicate emails coming from our mailing lists.
3. Increase retry attempts for email commands
   (don't want them to fail due to concurrent crash reports from managers).
2017-10-31 10:06:02 +01:00
Dmitry Vyukov
636a4dbf38 pkg/csource: add freebsd/netbsd support 2017-10-26 15:31:23 +02:00
Dmitry Vyukov
0038451914 pkg/report: add netbsd stub 2017-10-25 18:36:49 +02:00
Dmitry Vyukov
e729550825 all: basic building on netbsd
This just makes make TARGETOS=netbsd succeed.
We don't yet have prog target for netbsd.
2017-10-23 10:10:05 +02:00
Dmitry Vyukov
6755f62592 syz-fuzzer: fix manager polling
We need to always poll manager to send stats/maxsignal,
we just need not request candidates if we have plenty of work.
2017-10-23 09:59:39 +02:00
Dmitry Vyukov
afa9178d57 pkg/ipc: fix reading comp hints
if/else branches are intermixed
2017-10-23 09:59:39 +02:00
Dmitry Vyukov
ab829b1b0b pkg/report: more linux spinlock oops messages 2017-10-22 14:30:13 +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
f26811f080 pkg/ast: fix TestParseAll 2017-10-19 10:45:27 +02:00
Dmitry Vyukov
6a4810dd45 pkg/report: strip unnecessary info from "workqueue lockup" crashes 2017-10-18 16:56:05 +02:00
Dmitry Vyukov
296be8cc8d pkg/ipc: move fallback coverage into executor
It seems to explode linux corpus.
So make it freebsd-specific.
2017-10-18 16:49:25 +02:00
Dmitry Vyukov
f89294761c executor: use forkserver for freebsd
Use forkserver and shmem for freebsd.
This greatly improves speed.
Also introduce fallback coverage signal based
on unique (syscall+errno) pairs.
2017-10-18 12:01:24 +02:00
Dmitry Vyukov
6368c469a5 pkg/report: support freebsd 2017-10-18 12:01:24 +02:00
Dmitry Vyukov
85c802e4cf pkg/report: support multiple OSes
Introduce report.Reporter interface.
Add an implementation per-OS.
Make users be explicit about OS they are testing.
2017-10-18 12:01:24 +02:00
Dmitry Vyukov
6a06c36fe1 pkg/report: don't use access size for KASAN reports
Including access size potentially leads to failure to deduplicate
reports when size comes from user or for racy bugs (bug is detected
on different accesses depending on timings).
We already drop size from UAF and OOB, drop it for other bug types.
2017-10-17 15:09:01 +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
63c290f77c pkg/host: add akaros support 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
95a2bea795 pkg/ipc, pkg/osutil: remove filepath.Abs fuchsia workarounds
This claimed to be fixed:
https://fuchsia.atlassian.net/browse/DNO-158
2017-10-12 10:16:39 +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
4906c32192 pkg/ipc: extend error when fail to start executor
We currently return raw error, so sometimes it's hard to tell
even what call produced the error (e.g. just "invalid argument").
Extend the error so that it's clear that it comes from cmd.Start.
2017-10-10 18:59:23 +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
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
1cfc524354 syz-fuzzer: use osutil.HandleInterrupts instead of custom code
We already have osutil.HandleInterrupts for this.
Simplifies porting to new OSes.
2017-10-02 13:57:04 +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
8136bdad2f pkg/kd: add KD protocol decoder
Very primitive decoder that only decodes amd64 exceptions.
Use it in vm/gce. Now crashes contain something more or less
reasonable which is caught by manager as crash:

BUG: first chance exception 0x80000003

&kd.stateChange64{state:0x3030, processorLevel:0x6, processor:0x0,
numProcessors:0x2, thread:0xffff9c0bd015e080, pc:0xfffff8017615c380,
exception:kd.exception64{code:0x80000003, flags:0x0, record:0x0,
address:0xfffff8017615c380, numParams:0x1, unused:0x0, params:[15]uint64{
0x0, 0x40, 0xfffff801768699e0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0}, firstChance:0x1}, report:kd.controlReport{
dr6:0xffff0ff0, dr7:0x400, eflags:0x86, numInstr:0x10, reportFlags:0x3,
instr:[16]uint8{0xcc, 0xc3, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xf, 0x1f,
0x84, 0x0, 0x0, 0x0, 0x0, 0x0}, cs:0x10, ds:0x2b, es:0x2b, fs:0x53}}
2017-09-28 16:53:58 +02:00
Dmitry Vyukov
6350e5c2cf pkg/ipc: fix windows
Abs does not work on fuchsia only, use it on windows.
Also maintain stats.
2017-09-27 18:59:50 +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
255e8b5e54 pkg/ipc: windows port 2017-09-25 15:19:06 +02:00
Dmitry Vyukov
dcf893f99c pkg/osutil: windows port 2017-09-25 15:19:06 +02:00
Dmitry Vyukov
4a00221526 pkg/host: add windows stub 2017-09-25 15:19:06 +02:00
Dmitry Vyukov
e9c477a5b3 sys/syz-extract: support fuchsia 2017-09-25 08:47:48 +02:00
Dmitry Vyukov
997ce2252a pkg/report: suppress another android boot message 2017-09-23 08:22:53 +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
324664de57 pkg/repro: fix nil target in prog 2017-09-22 13:16:24 +02:00
Dmitry Vyukov
913d592f97 all: more assorted fuchsia support 2017-09-22 13:10:55 +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
d606e60dfe executor: split source per-OS
Update #191
2017-09-20 21:19:29 +02:00
Dmitry Vyukov
c7ff68231e pkg/host: add fuchsia support 2017-09-20 21:19:29 +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
66393d1884 pkg/compiler: don't genererate missing syscalls
We used to generate them only because manager had no idea
what arch it is testing. So syscalls numbers had to match
between all arches.
This is not needed anymore.
Also don't generate unreferenced structs/resources.
2017-09-15 16:02:37 +02:00
Dmitry Vyukov
4f60e46e49 syz-manager: check that files we are using are not changing under us
If kernel or syzkaller binaries are rebuilt when manager uses them,
nothing good will happen. Manager can start mixing coverage from
old and new kernels, or crash on unknown syscalls.
2017-09-15 16:02:37 +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
c0cabacda7 syz-fuzzer, syz-execprog: add -arch flag
arch flag specifies target arch, which can be different from GOARCH.
For example, 386 executor with amd64 fuzzer.
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
18e96021ed sys: move linux descriptions to sys/linux 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
c34180fca0 pkg/compiler: assign Call.ID statically 2017-09-04 21:06:59 +02:00
Dmitry Vyukov
a29e1be6ff pkg/compiler: fix alignment calculation bug 2017-09-04 20:54:29 +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
94e151ceb5 pkg/ast: prohibit empty strings
This is currently unsupported and unused.
2017-09-04 20:25:22 +02:00
Dmitry Vyukov
b5c5217623 pkg/ifuzz: use serializer
Simplifies code and reduces size of generated code from 820K to 310K.
2017-09-04 20:25:22 +02:00
Dmitry Vyukov
dbb49d0211 pkg/compiler: prohibit arrays of size 0
This is pointless and the only case that can yield 0 static type size.
2017-09-04 20:25:22 +02:00
Dmitry Vyukov
622a1ffd72 pkg/compiler: prohibit bitfields of size 0
They don't work the way C bitfields work.
So this will lead to confusion at least.
2017-09-04 20:25:22 +02:00
Dmitry Vyukov
291192c61b pkg/compiler: don't allow bitfields in unions, args and anon types 2017-09-04 20:25:22 +02:00
Dmitry Vyukov
e707c97f9a pkg/compiler: move bitfield marking from sys 2017-09-04 20:25:22 +02:00
Dmitry Vyukov
54a92e90e0 pkg/compiler: prohibit bitfields in syscall args 2017-09-04 20:25:22 +02:00
Dmitry Vyukov
740662e03a pkg/compiler: reserve in/out/inout/opt names 2017-09-04 20:25:22 +02:00
Dmitry Vyukov
2cf0659df1 sys: don't assume vma size is 8
Use explicit size for vma.
This is the last use of hardcoded ptrSize in sys package.
2017-09-04 20:25:22 +02:00
Dmitry Vyukov
4ee497d22e pkg/compiler: use correct arch ptr size 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
b06c1bd324 pkg/compiler: verify validity of len targets
Update #217
2017-09-04 20:25:22 +02:00
Dmitry Vyukov
8094a4202f pkg/compiler: move checking code to a separate file 2017-09-04 20:25:22 +02:00
Dmitry Vyukov
f29b943c0b pkg/compiler: detect recursive struct declarations
Update #217
2017-09-04 20:25:22 +02:00
Dmitry Vyukov
f400a0da0f pkg/ast: fix struct comment parsing 2017-09-04 20:25:03 +02:00
Dmitry Vyukov
a54dce007d sys: allow custom size for PtrType
This is required to support ptr64 type.
2017-09-02 14:08:30 +02:00
Dmitry Vyukov
08c91ab698 sys: support ptr64 type
ptr64 is like ptr, but always takes 8 bytes of space.
Needed for some APIs. Unfortunately, most of these APIs
use buffer type, so we can't use ptr64 immidiately.
2017-09-02 13:44:28 +02:00
Dmitry Vyukov
2c0b7b7ff3 pkg/compiler: restore generation of unsupported syscalls
Unfortunately this is sitll needed, see the added comment.

Update #191
2017-09-02 13:21:47 +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
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
Victor Chibotaru
1336586b42 executor, fuzzer: change the way Syzkaller opens the KCOV device
We have implemented a new version of KCOV, which is able to dump
comparison operands' data, obtained from Clang's instrumentation hooks
__sanitizer_cov_trace_cmp[1248], __sanitizer_cov_trace_const_cmp[1248]
and __sanitizer_cov_trace_switch.

Current KCOV implementation can work in two modes: "Dump only the PCs"
or "Dump only comparisons' data". Mode selection is done by the
following series of calls:

fd = open(KCOV_PATH, ...); // works as previous
ioctl(fd, KCOV_INIT_TRACE, ...); // works as previous
mmap(fd, ...); // works as previous
ioctl(fd, KCOV_ENABLE, mode);
// mode = KCOV_MODE_TRACE_CMP or mode = KCOV_MODE_TRACE_PC

Note that this new interface is backwards compatible, as old KCOV
devices will just return -EINVAL for the last ioctl. This way we can
distinguish if the KCOV device is able to dump the comparisons.

Main changes in this commit:
    1. Fuzzer now checks at startup which type (new/old) of KCOV device
is running.
    2. Executor now receives an additional flag, which indicates if
executor should read the comparisons data from KCOV. The flag works on
per-call basis, so executor can collect PCs or Comps for each
individual syscall.
2017-08-30 18:40:14 +02:00
Dmitry Vyukov
1d0002255d pkg/report: don't confuse "DEBUG:" with "BUG:"
Android sometimes prints "Boot_DEBUG:" during boot,
which we confuse with "BUG:".
2017-08-30 14:16:27 +02:00
Dmitry Vyukov
be2917712f pkg/compiler: actually tolerate unsupported consts
The previous commit removes errors on unsupported structs/resources,
but their usages still error. Fix that.
2017-08-28 19:00:31 +02:00
Dmitry Vyukov
0b652d7278 pkg/compiler: tolerate unsupported consts everywhere
Currently unsupported consts in structs and resources break build.
However, that can well happen for arch-specific devices (e.g. Android).
Make this non-fatal as it used to be.
2017-08-28 16:04:54 +02:00
Dmitry Vyukov
4074aed7c0 pkg/compiler: more static error checking
Update #217
2017-08-27 20:19:41 +02:00
Dmitry Vyukov
e2ffb4fc91 pkg/compiler: move more const-processing code to compiler 2017-08-27 15:28:49 +02:00
Dmitry Vyukov
a3857c4e90 pkg/compiler, sys/syz-sysgen: move const handling to pkg/compiler
Now pkg/compiler deals with consts.
2017-08-27 11:51:40 +02:00
Dmitry Vyukov
6aad5879f7 sys: support arm arch
Not tested, but const extraction and build works.

Update #324
Update #191
2017-08-19 10:41:24 +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
b19edae954 pkg/kernel: remove unused function 2017-08-18 20:03:52 +02:00
Dmitry Vyukov
4802b0fb74 sys/syz-sysgen: switch to new parser
For now we just generate the old structs from the new AST.
But this allows to delete the old parser entirely.
2017-08-18 18:47:39 +02:00
Dmitry Vyukov
19b893936b sys/syz-extract: switch to the new parser 2017-08-18 17:04:12 +02:00
Dmitry Vyukov
41bbf437e1 Makefile: enforce formatting of sys files in presubmit 2017-08-18 11:26:50 +02:00
Dmitry Vyukov
127a9c2b65 pkg/ast: new parser for sys descriptions
The old parser in sys/sysparser is too hacky, difficult to extend
and drops debug info too early, so that we can't produce proper error messages.

Add a new parser that is build like a proper language parser
and preserves full debug info for every token.
2017-08-18 11:26:50 +02:00
Dmitry Vyukov
172189e955 dashboard/app: heavylifting of email reporting
- save Message-ID and use In-Reply-To in subsequent messages
- remember additional CC entries added manually
- don't mail to maintainers if maintainers list is empty
- improve mail formatting and add a footer
- implement upstream/fix/dup/invalid commands over email
- add tests
2017-08-17 19:42:11 +02:00
Dmitry Vyukov
a0330c0f5e tools/create-gce-image.sh: explicitly specify target for grub
On most distributions default grub target is i386-pc, which works.
However, on some default is x86_64-efi, which fails with:

grub-install: error: cannot find EFI directory.

Explicitly specify i386-pc target.
2017-08-11 20:04:33 +02:00
Dmitry Vyukov
7e288c0531 pkg/repro: minimize fault injection 2017-08-09 15:41:52 +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
a5c7c2c4bd sys: provide list of intersting MSRs for KVM 2017-08-09 11:35:29 +02:00
Dmitry Vyukov
0adfdffa82 pkg/log: fix tests with -count>0 2017-08-09 10:24:34 +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
Dmitry Vyukov
a28999b4c6 vendor: update all packages
google.golang.org/api/compute/v0.beta again changed public interfaces
which causes breakages in other build environments.
Update everything to HEAD.
2017-08-08 10:54:24 +02:00
Dmitry Vyukov
8af91f61b4 syz-manager, syz-hub: share repros between managers via hub
Currently hub allows managers to exchange programs from corpus.
But reproducers are not exchanged and we don't know if a crash
happens on other managers as well or not.

Allow hub to exchange reproducers.

Reproducers are stored in a separate db file with own sequence numbers.
This allows to throttle distribution of reproducers to managers,
so that they are not overloaded with reproducers and don't lose them on restarts.

Based on patch by Andrey Konovalov:
https://github.com/google/syzkaller/pull/325

Fixes #282
2017-08-07 15:28:59 +02:00
Dmitry Vyukov
032fb6f70a syz-ci: send commits to dashboard
Dashboard needs to know when bug fixing commits reach
builders in order to fully close bugs.
Send commits that dashboard is interested in to dashboard.
2017-07-28 20:14:24 +02:00
Andrey Konovalov
bbd1f3487b pkg/repro: fix null-ptr-deref when res is nil
res can become nil if one of the repro routines fails with an error.
2017-07-27 14:48:21 +02:00
Andrey Konovalov
3f5c8df22d pkg/repro: fix simplifying threaded flag 2017-07-26 15:07:07 +02:00
Dmitry Vyukov
68c70116f3 pkg/symbolizer: fix race on inputr in test
Pointed out by race detector.
2017-07-25 10:52:35 +02:00
Andrey Konovalov
c70b8a2cff pkg/report: fix symbolization of old KASAN stack trace format
Which has a tab instead of a space at the beginning of each frame
in alloc and free stack traces.
2017-07-24 20:50:42 +02:00
Andrey Konovalov
0d9ae38d5d pkg/repro: disable Debug flag by default 2017-07-24 14:31:25 +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
Andrey Konovalov
65a2d5fb58 pkg/repro: try extracting C repro before simplifying options
Sometimes C reproducers don't work after the generic prog options were
simplified. This change makes syzkaller to try extracting a C repro before
simplifying prog options and after each simplification step. This gives
us more chance to generate a C reproducer.
2017-07-24 14:22:54 +02:00
Dmitry Vyukov
240b07788c pkg/hash: allow to hash multiple byte slices
Hash/String now allow to hash mutiple byte slices
without copying them into a single slice first.
2017-07-21 10:06:46 +02:00
Andrey Konovalov
56db83c58a pkg/report: replace lines numbers with LINE in report headers 2017-07-19 17:20:19 +02:00
Dmitry Vyukov
0107e4124d pkg/repro: save final crash log
Logs are useful in situations where we mess the report.
Since we try to report crashes with reproducers,
we need logs for reproducers.
2017-07-18 18:00:03 +02:00
Dmitry Vyukov
7c1ee0634b tools/create-gce-image.sh: ignore SIGINT
If the script is aborted at an unfortunate point, it leaves the whole system broken.
E.g. we've seen that fdisk cannot update partition table until the next reboot.
If you really need to kill it, use a different signal. But better wait.
2017-07-17 14:45:41 +02:00
Dmitry Vyukov
8382eb648f pkg/kernel: actually pass cmdline/sysctl files to the build script 2017-07-17 14:45:41 +02:00
Dmitry Vyukov
cc1c342923 syz-ci: allow to specify cmdline/sysctls
Allow to specify per-kernel command line and sysctl values
to more closely mimic the target kernel.
2017-07-17 12:39:11 +02:00
Dmitry Vyukov
76f45d87f2 syz-manager: save proper report for reproducers
We can start reproducing one crash, but end up reproducing another.
Currently we still attribute the resulting repro to the original crash.
This is wrong.
Save the resulting desc/report for reproducers and use that in manager.
2017-07-06 12:17:39 +02:00
Dmitry Vyukov
f68d78b5a8 pkg/email: fix bug in context extraction
Compare email addresses without full name.
2017-07-05 21:29:41 +02:00
Dmitry Vyukov
6fe1bcf384 pkg/email: add AddAddrContext/RemoveAddrContext
Replace extractBugID function with more general AddAddrContext/RemoveAddrContext.
2017-07-05 19:45:56 +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
Andrey Konovalov
918a566afd pkg/repro: return crash report 2017-07-05 15:40:55 +02:00
Dmitry Vyukov
ebabe267cd pkg/email: don't add own email address to CC list
Otherwise we we send each reply to ourselves and receive it again.
2017-07-03 18:24:39 +02:00
Dmitry Vyukov
2181ef35e1 pkg/osutil: don't depend on syscall in appengine build
Dashboard app now depends on osutil through config package.
Reshuffle functions so that the package does not depend
on syscall in appengine build.
2017-07-03 14:43:37 +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
1438a6de81 pkg/report: strip panic message from reports
If panic_on_warn set, then we frequently have 2 stacks:
one for the actual report (or maybe even more than one),
and then one for panic caused by panic_on_warn. This makes
reports unnecessary long and the panic (current) stack
is always present in the actual report. So we strip the
panic message. However, we check that we have enough lines
before the panic, because sometimes we have, for example,
a single WARNING line without a stack and then the panic
with the stack.
2017-07-03 13:18:40 +02:00
Dmitry Vyukov
eb1cda04f3 pkg/email: add function that forms reply to an email 2017-07-02 16:08:04 +02:00
Dmitry Vyukov
233bc790fc pkg/email: add email parsing functionality
Parse extracts all potentially interesting info from an incoming email.
2017-07-02 15:40:24 +02:00
Dmitry Vyukov
1b20342f25 pkg/email: move patch parsing from pkg/kernel
ParsePatch is used by appengine app.
Appengine apps can't depend on syscall/unsafe,
but pkg/kernel currently does.
Move patch parsing to pkg/email which does not
depend on syscall/unsafe.
2017-06-30 16:20:19 +02:00
Dmitry Vyukov
c2028e38d2 pkg/report: change arg of ExtractGuiltyFile to []byte
We usually store reports as []byte, not as string. They can be large.
So change arg type to []byte.
Also rename it from log to report. In our terminology log is
not symblized/processed crash output. What this function wants
is called report in manager.
2017-06-30 15:09:57 +02:00
Dmitry Vyukov
909ccbe28f pkg/config: support time.Time fields 2017-06-30 14:36:34 +02:00