Commit Graph

144 Commits

Author SHA1 Message Date
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
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
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
Dmitry Vyukov
e0a2b1953b vm: merge "not executing programs" into "no output"
Frequently it's the same condition.
In one case there is just a stray error message on console
that turns the crash into "not executing programs".
While in another case there is no stray message,
and then it's detected as "no output".
2017-11-08 18:01:43 +01:00
Dmitry Vyukov
c1c91039f7 vm/gce: fix error formatting
This is detected with newer Go toolchain:

vm/gce/gce.go:376: Errorf format %v reads arg #1, but call has only 0 args
vm/gce/gce.go:381: Errorf format %v reads arg #1, but call has only 0 args
2017-11-07 13:25:27 +01:00
Dmitry Vyukov
6fd57ceb7d vm/vmimpl: add netbsd console stub 2017-10-26 11:53:10 +02:00
Dmitry Vyukov
da63ec6526 vm/qemu: support netbsd 2017-10-23 10:19:38 +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
038cff25e2 vm/qemu: update error message for newer qemu
Newer qemu prints "Could" instead of "could".
2017-10-17 14:09:37 +02:00
Dmitry Vyukov
5ac303b525 vm/qemu: add freebsd support 2017-10-02 13:57:04 +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
e0e6908d3f vm/gce: fix GCE image check 2017-09-28 16:53:58 +02:00
Dmitry Vyukov
9fc15c7ea3 vm/gce: windows support
Support custom pre-created images.
Support non-root user.
Use dir instead of pwd on windows.
Don't use sudo on windows.
2017-09-27 18:59:50 +02:00
Dmitry Vyukov
187270ea83 vm/qemu: fix typo 2017-09-25 13:14:32 +02:00
Dmitry Vyukov
a0fdd2e758 vm/qemu: initial multi-OS support 2017-09-25 08:47:48 +02:00
Dmitry Vyukov
25f4fe0662 vm/qemu: tune some qemu arguments based on target arch 2017-09-15 16:02:37 +02:00
Dmitry Vyukov
c6d248ce95 vm/vmimpl: add target OS/arch to env
Allows future VM tuning based on target OS/arch.
2017-09-15 16:02:37 +02:00
Thomas Garnier
ed7f95981b Fix reboot support for VM isolated
Do not fail a reboot if the reboot command returns an error. Reduces the
wait time per ssh commands to 30 seconds.

Signed-off-by: Thomas Garnier <thgarnie@google.com>
2017-08-30 19:30:38 +02:00
Dmitry Vyukov
f238fbd42d all: support i386 arch
Update #191
2017-08-19 19:17:27 +02:00
Dmitry Vyukov
13fd8fda08 vm/vmimpl: support linux/arm
Update #324
2017-08-18 19:24:26 +02:00
Dmitry Vyukov
a48e1ead61 vm/gce: work around GCE console bug
Sometimes connects to serial console spuriously fail with:
Permission denied (publickey)
2017-08-08 11:45:25 +02:00
Dmitry Vyukov
75f1e83f8b vm/gce: another attempt to fix trimmed console output
We still see trimmed reports even with the "serialport" grep.
Add a 5 second sleep in an attempt to fix it.
2017-08-01 18:25:18 +02:00
Dmitry Vyukov
da1dd22e48 vm/gce: fix truncated console output
Sometimes we get truncated console output during repro.
The problem is that we start the console reading ssh command,
but do not wait for it to actually connect and start piping console.
Wait while the command actually starts piping console before
starting the target command.
2017-07-25 20:32:31 +02:00
Dmitry Vyukov
9e1407a678 vm/isolated: reformat 2017-07-18 09:58:53 +02:00
Thomas Garnier
3fd92b9694 Add Isolated VM
Add a new isolated VM for machines that you cannot easily manage. It
assumes the machine is only available through SSH and create a reverse
proxy to ensure the machine can connect back to syz-manager.

Signed-off-by: Thomas Garnier <thgarnie@google.com>
2017-07-18 09:57: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
ed1e09a88a vm/gce: support debug mode
Print ssh/console output to stdout in debug mode.
2017-06-30 14:32:17 +02:00
Andrey Konovalov
d832fd391a vm: increase stored log size to 1 MB 2017-06-27 11:59:12 +02:00
Dmitry Vyukov
274bfdcec9 vm/adb: add an option to disable battery check
Add a new VM option:

	// Ensure that a device battery level is at 20+% before fuzzing.
	// Sometimes we observe that a device can't charge during heavy fuzzing
	// and eventually powers down (which then requires manual intervention).
	// This option is enabled by default. Turn it off if your devices
	// don't have battery service, or it causes problems otherwise.
	Battery_Check bool

Fixes #258
2017-06-27 10:28:22 +02:00
Dmitry Vyukov
7cacd94aa6 vm/vmimpl: fix linux/ppc64le build 2017-06-27 10:21:43 +02:00
Zach Riggle
4e580472f4 Restore TCGETS2 (#256) 2017-06-27 10:03:24 +02:00
Dmitry Vyukov
0fd3577a0a vm/vmimple: fix build and reformat 2017-06-26 15:36:54 +02:00
Zach Riggle
2420edb02e Port console to Darwin (#253)
* Port console to Darwin

* Get syz-executor to build correctly

* Do not export unix and syscall constants

* Add presubmit test

* Add myself to contributors
2017-06-26 15:32:38 +02:00
Dmitry Vyukov
98877a11dd vm/gce: fix image archive creation
See the added comment.
2017-06-17 18:30:12 +02:00
Dmitry Vyukov
e130d95518 vm/gce: accept un-tar-ed image
vm/gce differs from other VM types in that it accepts image
in a weird, GCE-specific format (namely, image named disk.raw
is put into .tar.gz file). This makes it impossible to write
generic code that creates images for any VM types.

Make vm/gce accept just image like e.g. vm/qemu
and handle own specifics internally.
2017-06-17 17:06:29 +02:00
Dmitry Vyukov
97b58e7eae syz-manager/mgrconfig: move sshkey from vm config to manager config
Sshkey is a property of image, which is in manager config.
Move sshkey to the same location as image.

The motivation for the move is as follows.
Continuous build produces an image and the key,
both need to be passed manager instance.
Continuous build system should not distinguish
different VM types and mess with their configs.

NOTE FOR USERS: this breaks manager configs again.
Hopefully the last time for now. Docs are updated.
2017-06-17 15:02:58 +02:00
Dmitry Vyukov
68621900a3 pkg/report: move from report 2017-06-17 14:41:15 +02:00
Dmitry Vyukov
4cc7e08628 all: use osutil.IsExist instead of os.Stat 2017-06-17 12:23:52 +02:00
Dmitry Vyukov
429ff326c3 vm/qemu: update kernel command line
+nmi_watchdog=panic
-slub_debug=UZ

Also refactor cmd line generation code to make it more resilent to bugs.
2017-06-15 18:29:47 +02:00
Dmitry Vyukov
b68d01eea0 vm/gce: accept local image
Currently gce accepts precreated GCE image name as image config param,
while all other VM types accept local file path as image.
This makes it impossible to write generic code that works with all VM types,
i.e. after building a new image it's unclear if it needs to be uploaded
to GCE or not, and what needs to be passed as image in config.

Eliminate this difference by making gce accept local image file as well.
2017-06-03 11:48:19 +02:00
Dmitry Vyukov
af643baa32 vm: overhaul
VM infrastructure currently has several problems:
 - Config struct is complete mess with a superset of params for all VM types
 - verification of Config is mess spread across several places
 - there is no place where VM code could do global initialization
   like creating GCE connection, uploading GCE image to GCS,
   matching adb devices with consoles, etc
 - it hard to add private VM implementations
   such impl would need to add code to config package
   which would lead to constant merge conflicts
 - interface for VM implementation is mixed with interface for VM users
   this does not allow to provide best interface for both of them
 - there is no way to add common code for all VM implementations

This change solves these problems by:
 - splitting VM interface for users (vm package) and VM interface
   for VM implementations (vmimpl pacakge), this in turn allows
   to add common code
 - adding Pool concept that allows to do global initialization
   and config checking at the right time
 - decoupling manager config from VM-specific config
   each VM type now defines own config

Note: manager configs need to be changed after this change:
VM-specific parts are moved to own "vm" subobject.

Note: this change also drops "local" VM type.
Its story was long unclear and there is now syz-stress which solves the same problem.
2017-06-03 11:31:42 +02:00
Dmitry Vyukov
a6bed21731 pkg/gce: move from gce 2017-06-03 10:41:09 +02:00
Dmitry Vyukov
23b94422d3 pkg/log: move from log 2017-06-03 10:41:09 +02:00
Dmitry Vyukov
66fd442d48 pkg/fileutil: move from fileutil 2017-06-03 10:41:09 +02:00
Dmitry Vyukov
d1d3a5e702 fileutil: remove unused CopyFile arg 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
baishuai
118ec7aea5 vm: validate if cfg.Bin is in $PATH for kvm,adb,qemu 2017-05-21 12:47:51 +08:00
Andrey Konovalov
fc93e6ec57 vm: build odroid vm only if odroid build tag is present 2017-03-10 19:40:05 +01:00