Commit Graph

117 Commits

Author SHA1 Message Date
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
Andrey Konovalov
889d63a6a7 vm: don't leak tty fds in adb 2017-03-10 17:10:58 +01:00
Andrey Konovalov
91ea49ce25 vm: add Odroid support
This commit adds Odroid C2 support to syzkaller.
It's now possible to specify "type": "odroid" in manager config.

Documentation on how to setup fuzzing with Odroid C2 board is here:
https://github.com/google/syzkaller/wiki/Setup:-Odroid-C2

Note, that after this change libusb-1.0-0-dev package should be
installed to build syzkaller.
2017-03-10 17:10:52 +01:00
Dmitry Vyukov
13051717b5 vm/adb: fix ppc64le build 2017-03-02 15:21:26 +01:00
Dmitry Vyukov
c81cc207a6 vm/adb: support fuzzing without console
If no console found, fall back to 'adb shell dmesg -w'.
This is not reliable, and lots of bugs are detected as 'lost connection'
without any kernel output. But users want this.
2017-02-06 16:01:45 +01:00
Dmitry Vyukov
3558653771 vm: properly detect when a program exits
syz-fuzzer never exits (normally) so this does not affect syz-manager.
But during reproduction we can run a short running program (no repeat mode)
and currently VMs treat premature exit as an error.

Properly detect when a program exits and let callers decide what to do with it.
2017-02-02 20:23:40 +01:00
Dmitry Vyukov
86c334f459 vm/qemu: use static network config in 9p mode
Static config is faster than dhcp.
2017-01-27 20:46:09 +01:00
Billy Lau
a0a4a8ed95 adb: executor: Revert to adb reboot
Using `adb shell syz-executor reboot` to reboot devices has stopped
working with the recent Android update, probably due to the intro
of seccomp. I have reverted the device reboot logic to use `adb
shell reboot` although it can be flaky at times so that we can
continue to fuzz on devices, until a more reliable solution can be
sought out.
2017-01-26 13:19:22 +00:00
Dmitry Vyukov
83a8f430c9 vm/qemu: add some kvm-related kernel cmd line flags
In particular it is useful to enable nested.
Enable a bunch of others as well.
2017-01-09 20:20:49 +01:00
Dmitry Vyukov
40a8b2f8e1 vm/adb: increase battery check timeout
Battery info is provided by some OS services.
With KASAN/KCOV these services take long to startup.
This causes episodic timeouts during battery check.
Increase the timeout.
2017-01-09 20:20:49 +01:00
Dmitry Vyukov
3f9152d9e2 vm/qemu: enable more kvm features in test kernel 2017-01-09 20:19:44 +01:00
Dmitry Vyukov
80b6c954f8 manager: add ability to ignore bugs
Add new config parameter "ignores" which contains list of regexp expressions.
If one of the expressions is matched against oops line,
crash report is not saved and VM is not restarted.
2016-12-19 17:39:03 +01:00
Dmitry Vyukov
a074da17a4 vm/adb: support BeagleBone console
BeagleBone console requires some special tty-ism to work.
Fortunately, this code also works with Suzy-Q.
2016-12-19 15:56:10 +01:00
Dmitry Vyukov
a59452c4b2 vm/gce: handle graceful preemption
In case of graceful preemption fuzzer should be terminated by SIGTERM.
Catch it and propagate to manager.
2016-12-16 16:11:18 +01:00
Dmitry Vyukov
d105629ea2 vm/qemu: use panic=86400 instead of panic=-1
panic=-1 causes instant reboot, which is bad for crash logs.
panic=86400 makes it hang. Use panic=86400 as create-gce-image.sh does.
2016-12-06 20:06:45 +01:00
Dmitry Vyukov
3e53602346 vm/gce: use preemptible instances
Preemptible instances are cheaper, try to use them.
Also try to enable vmx support.
2016-12-02 16:58:09 +01:00
Alexander Popov
3a5ae29218 vm/qemu: prevent eth0 renaming
create-image.sh tries to enable eth0 network interface of the virtual machine,
but there is no eth0 in a fresh debian-wheezy, since biosdevname renames interfaces.
VM log quotation:
  e1000 0000:00:03.0 eth0: (PCI:33MHz:32-bit) 52:54:00:12:34:56
  e1000 0000:00:03.0 eth0: Intel(R) PRO/1000 Network Connection
  e1000 0000:00:03.0 ens3: renamed from eth0
  ...
  Cannot find device "eth0"
  Bind socket to interface: No such device
  Failed to bring up eth0.

The simplest fix is disabling biosdevname by adding "net.ifnames=0 biosdevname=0"
to the kernel command line.

Signed-off-by: Alexander Popov <alex.popov@linux.com>
2016-11-28 16:11:24 +03:00
Dmitry Vyukov
3356f68f1a vm/qemu: support non-native mode
Add config bin_args parameter that contains additional arguments for qemu binary.
This allows to specify e.g. "bin_args": "-machine virt -cpu cortex-a57".
Also restore qemu debugging output when -debug flag is specified.
2016-11-22 17:00:47 +01:00
Dmitry Vyukov
c9ae0f69d8 vm: add ability to interrupt commands
This is required for crash reproduction in manager.
2016-11-19 11:14:11 +01:00
Dmitry Vyukov
3ad1f7a214 vm/gce: don't require ssh key for GCE-compatible images
If an image supports all GCE fanciness, we don't need a separate ssh key for it.
It should accept the instance private key that we specify during VM creation.
2016-11-17 09:24:54 +01:00
Dmitry Vyukov
1d5ba315b4 vm/gce: actually append name to instance names 2016-11-16 13:35:43 +01:00
Dmitry Vyukov
128816142c syz-gce,syz-manager: add name config parameter
Name is used for identification on web ui
and included in gce instance names (so that
several managers can coexist in a single project).
2016-11-16 13:19:33 +01:00
Dmitry Vyukov
4e20245f4d Merge pull request #88 from billy-lau/hotfix/check-battery-level
Added a retry clause when doing battery check in adb.go
2016-11-15 14:12:55 +01:00
Billy Lau
e246add2ca Added a retry clause when doing battery check in adb.go
Some devices may not boot up fast enough when battery check
is done as it currently is in adb.go. Therefore,
getBatteryLevel() is modified to take in a parameter to determine
the number of times to retry before giving up.
2016-11-15 11:53:00 +00:00
Dmitry Vyukov
d7f6556505 vm/adb: print device<->console association 2016-11-15 12:09:40 +01:00
Dmitry Vyukov
85f78e771d vm/adb: support separate serial console cable
For Suzy-Q we matched usb bus/port between adb and console device.
This is not possible for separate serial cables: bus/port are unrelated.
So switch to a different algorithm that supports both Suzy-Q and separate cables.
The overall idea is as follows. We use 'adb shell' to write a unique string onto console,
then we read from all console devices and see on what console the unique string appears.
2016-11-11 14:02:03 -08:00
Dmitry Vyukov
e3653a25ed vm/adb: switch adb to root
Userdebug builds have adb under 'shell' user by default.
Switch to root user before starting fuzzing.
2016-11-11 13:51:23 -08:00
Dmitry Vyukov
6f057a2c04 vm/qemu: remove debug, add rodata=n to kernel cmd line
Debug leads to too verbose output in some cases.
Rodata is very slow with KASAN.
2016-10-16 08:15:24 +02:00