Commit Graph

340 Commits

Author SHA1 Message Date
Dmitry Vyukov
06cecac317 syz-manager: expose function coverage
THe new /funccover end point exposes the CSV function coverage.
2020-09-28 09:41:25 +02:00
Jouni Hogander
6f0ea384b1 pkg/cover: implement function coverage calculation 2020-09-26 17:47:37 +02:00
Dmitry Vyukov
4dc0927070 syz-manager: fix logical races in rpc request handling
It is possible that we already called shutdownInstance,
but have some requests from this instance already in-flight.
Handle this case gracefully.
2020-09-20 15:12:12 +02:00
Cheng-Min Chiang
9eff3337ee dashboard/app: send machine information to dashboard
- Change syz-manager so that it will send machine info the first time a
  crash occurs.
- Add a field in entities.Crash to store machine info.
- Add a field in dashapi.BugReport to store machine info.
- Change the HTML template and struct uiCrash to display machine info.
- Add a test to make sure that the link to machine info appears on the
  webpage.

Update #466
2020-09-14 15:00:02 +02:00
Dmitry Vyukov
dd93b2327c syz-manager: load test programs as candidates
1. Load test programs directly from sys/OS/test.
   Since we have sykaller dir, we don't need separate workdir/seeds.

2. Load test programs into candidates avoiding pulling them into corpus.
   This unbreaks mgr.fresh detection and does not pollute corpus with
   programs that don't give coverage/contain unsupported syscalls, etc.

Follow up to #2053
2020-09-14 10:38:36 +02:00
Jiaheng Hu
3f1d02b23f syz-manager: add test file as corpus
This commit enables the syz-manager to add unit test files as corpus to
accelerate fuzzing. The syz-ci would copy unit tests into the
worker/seeds folder for each manager process, and the manager would add
those tests as seed into the corpus.
2020-09-14 09:52:09 +02:00
Dmitry Vyukov
e5f38ffe77 syz-manager: fix nil defer
Don't leave nil fuzzers in the map.
2020-09-13 13:42:03 +02:00
Dmitry Vyukov
ad54dc7a6d syz-manager: cosmetic refactoring
1. Don't duplicate VM name generation.
2. Always "shutdown" fuzzers to not keep stale machine info.
2020-09-12 17:38:54 +02:00
bobogei81123
7aa6bd6859
syz-manager: collect machine information
* syz-manager: finish a prototype

Extract machine info from /proc/cpuinfo and /sys/kvm*/parameters/* and
send it from syz-fuzzer to syz-manager. Append the machine info after
crash reports.

* syz-manager: refactor the code

- Add kvm parameters machine info.
- Store the machine info in the RPCServer instead of the manager.
- Store the machine info in another field instead of appending it after
  the original report
- Save the machine info locally in machineInfo*.

* syz-manager: fix coding-style problems

* syz-fuzzer: improve the output from /proc/cpuinfo

Improve the machine info extracted from /proc/cpuinfo by grouping lines
with the same key.

* syz-manager: fix race condition in runInstance

* syz-fuzzer: add tests for collecting machine info

- Add some tests to test collecting machine information.
- Split readCPUInfo into scanCPUInfo so that we can test it.

* syz-fuzzer: refactor scanCPUInfo

Refactor scanCPUInfo so that no sorting is needed.

* syz-fuzzer: refactor some code

Fix some issue that was pointed out on Github.
2020-09-12 17:17:22 +02:00
Dmitry Vyukov
67b599d167 syz-manager: better handle errors in HTML templates
I periodically see:
2020/08/23 13:33:21 http: superfluous response.WriteHeader
	call from main.(*Manager).httpSummary (html.go:72)
which suggest that there are some erros during template execution.
But currently we don't seem to show them properly.
Show them properly and also log.
2020-08-24 13:28:22 +02:00
Alexander Egorenkov
70301872e1 syz-manager/cover: support compiler triple for readelf 2020-08-09 14:58:49 +02:00
Pedro Lopes
242b0eb219 pkg: get and store Maintainers data
Create a struct on pkg/vcs to store data of syzkaller email recipients
and update its users. The struct contains default name, email, and a
label to divide user into To and Cc when sending the emails.
2020-07-31 17:18:29 +02:00
Dmitry Vyukov
3940e7a64f all: fix log/error text starting with capital letter
Update #1876
2020-07-05 10:55:16 +02:00
Dmitry Vyukov
fcb219b67e all: don't compare string len with 0
For strings it's more readable to compare the string itself with "",
instead of comparing len with 0. Fix all such cases.

Update #1876
2020-07-04 15:05:30 +02:00
Dmitry Vyukov
2c2b926cb7 .golangci.yml: reduce function line count from 200 to 140
140 lines should be enough for everyone.
2020-06-07 10:41:01 +02:00
Dmitry Vyukov
2fcb2b5c16 .golangci.yml: enable gocognit checker
Finds too complex functions.
Similar to gocyclo, but uses somewhat different metric.
2020-06-05 12:23:19 +02:00
Dmitry Vyukov
2ba71ec506 pkg/repro: don't enable features missing on the target
Manager has already checked what features are present on the target.
But if we detected that, say, USB is missing, we still enabled it
in the starting csource options. This is wrong, increases configuration
minimization time and may lead to some obscure bugs.
2020-06-03 11:35:08 +02:00
Daimeng Wang
f7fbb18cba syz-manager: add detailed coverage logging
Originally, syz-manager confusingly logs corpusSignal as "cover".
Change syz-manager's logging to output corpusSignal, corpusCover
and maxSignal.
Add a field in Stats to store maxSignal.
2020-05-30 08:04:19 +02:00
Dmitry Vyukov
fdf90f622b pkg/cover: add test for report generation
Test various combinations of no debug info,
no coverage instrumentation, no PCs, bad PCs, good PCs,
and what errors we produce for these.
Also implement support for cross-arch reports:
prefix objdump with cross-compile prefix
(e.g. aarch64-linux-gnu-objdump instead of objdump).
2020-05-27 14:38:28 +02:00
Dmitry Vyukov
a44eb8f7ea syz-manager: more consistently check disabled syscalls
We have program "validity" check duplicated 4 times
(initially it was just "does it deserialize?").
Then we added program length and disabled syscall.
But some of the sites have only a subset of checks.
Factor out program checking procedure into a separate function
and use it at all sites.
2020-05-12 15:26:07 +02:00
Dmitry Vyukov
a788005625 dashboard/app: collect BB coverage stats from managers
Fixes #1698
2020-05-08 14:09:35 +02:00
Dmitry Vyukov
413b991c26 syz-fuzzer: add more checks for disabled syscalls
We are seeing some panics that say that some disabled
syscalls somehow get into corpus.
I don't see where/how this can happen.
Add a check to syz-fuzzer to panic whenever we execute
a program with disabled syscall. Hopefull the panic
stack will shed some light.
Also add a check in manager as the last defence line
so that bad programs don't get into the corpus.
2020-05-07 15:41:50 +02:00
Dmitry Vyukov
9f7c6d1294 Revert "syz-manager: if running on GCE use GCE public IP address"
This reverts commit 273e386b71.
The error handling in the function is somewhat unusual,
and the code was correct. GCE address took precedence.
2020-04-19 22:06:23 +02:00
Dmitry Vyukov
273e386b71 syz-manager: if running on GCE use GCE public IP address
Host is not necessary full public address.
So if we are running on GCE, prefer GCE public IP.
2020-04-19 10:26:57 +02:00
Dmitry Vyukov
9b1f3e6653 prog: control program length
We have _some_ limits on program length, but they are really soft.
When we ask to generate a program with 10 calls, sometimes we get
100-150 calls. There are also no checks when we accept external
programs from corpus/hub. Issue #1630 contains an example where
this crashes VM (executor limit on number of 1000 resources is
violated). Larger programs also harm the process overall (slower,
consume more memory, lead to monster reproducers, etc).

Add a set of measure for hard control over program length.
Ensure that generated/mutated programs are not too long;
drop too long programs coming from corpus/hub in manager;
drop too long programs in hub.
As a bonus ensure that mutation don't produce programs with
0 calls (which is currently possible and happens).

Fixes #1630
2020-03-13 13:16:53 +01:00
Dmitry Vyukov
05359321bb all: fix new golangci-lint warnings
Newer version started producing more warnings. Fix them.
2020-03-13 08:26:02 +01:00
Andrei Vagin
f60dc5d243 manager: check mgr.checkResult before accessing it
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0xd5ef14]

goroutine 1 [running]:
main.(*Manager).needLocalRepro(0xc000582780, 0xc000416a40, 0xc00307e274)
	/usr/local/google/home/avagin/git/gopath/src/github.com/google/syzkaller/syz-manager/manager.go:697 +0x74
main.(*Manager).saveCrash(0xc000582780, 0xc000416a40, 0x24)
	/usr/local/google/home/avagin/git/gopath/src/github.com/google/syzkaller/syz-manager/manager.go:688 +0xce5
main.(*Manager).vmLoop(0xc000582780)
	/usr/local/google/home/avagin/git/gopath/src/github.com/google/syzkaller/syz-manager/manager.go:398 +0x174b
main.RunManager(0xc000120f00, 0xc000292000, 0xc00001edc0, 0xc000792000, 0xd11, 0x1000)
	/usr/local/google/home/avagin/git/gopath/src/github.com/google/syzkaller/syz-manager/manager.go:270 +0x7a6
main.main()
	/usr/local/google/home/avagin/git/gopath/src/github.com/google/syzkaller/syz-manager/manager.go:135 +0x365

Signed-off-by: Andrei Vagin <avagin@google.com>
2020-03-04 11:13:09 +01:00
Dmitry Vyukov
b6ed147834 prog: dump orig prog if Deserialize panics
We are seeing some one-off panics during Deserialization
and it's unclear if it's machine memory corrpution or
an actual bug in prog. I leam towards machine memory corruption
but it's impossible to prove without seeing the orig program.

Move git revision to prog and it's more base package
(sys can import prog, prog can't import sys).
2020-02-21 10:22:07 +01:00
Dmitry Vyukov
f9b6950728 syz-manager: don't accept excessive amounts of inputs for a single call
From time to time we get corpus explosion due to different reason:
generic bugs, per-OS bugs, problems with fallback coverage, kcov bugs, etc.
This has bad effect on the instance and especially on instances
connected via hub. Do some per-syscall sanity checking to prevent this.
2020-01-15 18:04:24 +01:00
Dmitry Vyukov
0b7abdf922 syz-manager: don't send more than 100K inputs to hub
Never send more than 100K, this is never healthy but happens episodically
due to various reasons: problems with fallback coverage, bugs in kcov,
fuzzer exploiting our infrastructure, etc.
2020-01-15 18:04:24 +01:00
Dmitry Vyukov
23641f8d17 syz-manager: start VMs with a small delay
If lots of instances are started at the same time,
it slows down boot of every VMs and delays detection
of configuration bugs, etc. Start VMs with 10 sec delay,
so that checking happens faster.
2020-01-14 19:51:25 +01:00
Dmitry Vyukov
6a8d39b1f4 syz-manager: disable corpus rotation
Temporary disable corpus rotation b/c we suspect it negatively affects fuzzing.
But we don't have hard data, and the easiest way to check is to disable
and see what happens.

Update #1348
2020-01-07 16:01:39 +01:00
Dmitry Vyukov
90408076e6 syz-manager: don't show hub stats if hub is not enabled 2020-01-05 11:46:34 +01:00
Dmitry Vyukov
147b97431b syz-manager: show list of all enabled syscalls
1. Show all syscalls even if they don't have coverage yet.
2. Show full syscall names.
3. Show prio/corpus/cover for paticular syscall descrimination.

This allows to check what exactly syscalls are enabled
and see prio/corpus/cover for a single syscall.
2020-01-05 11:46:33 +01:00
Dmitry Vyukov
7e52950696 syz-manager: init coverage without manager mutex
Coverage initialization takes very long time,
if we hold manager mutex we stall all rpc's and everything.
Do it without manager mutex.
2020-01-03 16:11:49 +01:00
Dmitry Vyukov
74da6acb21 syz-manager: add a note about corpus rotation
Update #1348
2019-12-30 18:03:59 +01:00
Dmitry Vyukov
6b36d33868 syz-manager: corpus rotation
Use a random subset of syscalls/corpus/coverage for each individual VM run.
Hypothesis is that this should allow fuzzer to get more coverage
find more bugs in saturated state (stuck in local optimum).
See the issue and comments for details.

Update #1348
2019-12-30 16:37:38 +01:00
Marco Vanotti
607350e438 syz/targets: add SyzExecutorCmd flag
This commit adds a new attribute to syzkaller targets that tells
syzkaller how to invoke the syz-executor command.

Some systems, like Fuchsia, are now building syz-executor as part of the
build, and there is no need to copy it over, or to run it from `/tmp`.
In fact, that might stop working at some time in the future in Fuchsia.

All places that used to copy syz-executor into the target machine will
now check for the SyzExecutorCmd flag, and won't copy it if the flag is
set.
2019-12-09 15:13:49 -08:00
Dmitry Vyukov
587cec15e2 pkg/host: add Features.Supported
To reduce diff in future changes. Currently no-op.
2019-11-16 09:58:54 +01:00
Dmitry Vyukov
aa27601f9e pkg/host: rename some features
Rename some features in preparation for subsequent changes
which will align names across the code base.
2019-11-16 09:58:54 +01:00
Marco Elver
5681358a2a syz-fuzzer, executor: Add support for blacklisting data race frames
This adds support to add frames that have already been in data races, to
the KCSAN report blacklist.
2019-10-22 17:48:18 +02:00
Dmitry Vyukov
c85e1c5be9 pkg/cover: hierarchical coverage reports
Better coverage reports with hierarchical coverage information,
number of programs covering each line,
handling of partially covered lines,
links to programs covering lines.

Fixes #682
2019-07-26 19:32:14 +02:00
Dmitry Vyukov
7bb222f7bc syz-manager: fix argument order in generateCoverHTML 2019-07-18 09:47:33 +02:00
Siddharth M
f613a7c41d pkg/cover: fix prefix computation
* pkg/cover: Modify parsing logic
1. Remove prefix computation
2. Add a mgrconfig for kernel build directory

* pkg/report: shorten reports with kernelBuildSrc instead of kernelSrc

* pkg/report: Fix failing tests

* pkg/report: fix formating issues

* tools/syz-cover: Fix unintended redefinition

* make changes to fix failing ci build

* pkg/report: fix issues
2019-07-17 11:58:23 +02:00
Dmitry Vyukov
2fa06225ad syz-manager: increase initial poll batch size
When the fuzzer starts, it pumps the whole corpus.
If we do it using the final batchSize, it can be very slow
batch of size 6 can take more than 10 mins for 50K corpus and slow kernel).
Use a batch of 30 initially.
2019-06-03 13:13:56 +02:00
Dmitry Vyukov
4adc00e894 syz-manager: reproduce leaks from hub
pkg/repro only enables leak checking when report type is MemoryLeak.
Since repros from hub always have Unknown type, repro won't reproduce leaks.
Always set report type to MemoryLeak on leak instances.
2019-05-21 12:25:10 +02:00
Dmitry Vyukov
7b3084af2e syz-manager: don't repro non-leaks on leak instance
Leak checking is too slow to reproduce other bugs.
2019-05-20 19:40:20 +02:00
Dmitry Vyukov
2c9280d432 pkg/rpctype: use string type for leak frames
We need them as string everywhere.
Not sure why they were []byte to begin with.
2019-05-20 19:40:20 +02:00
Dmitry Vyukov
4d4a4420e7 pkg/report: add Type/Frame to Report
In several places we do special handling for some crash types.
Currently we compare report title with magic strings,
which is error-prone. Add explicit Type to reports.
2019-05-20 19:40:20 +02:00
Dmitry Vyukov
52a20ba400 dashboard/app: properly handle build failures
Separate kernel and syzkaller build failures.
Fix logic to understand when a build is fixed:
look if kernel/syzkaller commit changes to understand
if it's a new good build or re-upload of an old build.

Fixes #1014
2019-03-25 17:00:25 +01:00