Commit Graph

241 Commits

Author SHA1 Message Date
Andrew Donnellan
c7d8a8c07b vm/qemu: Enable KVM on ppc64le
ppc64le supports KVM, let's use it.

This obviously won't work on an x86 host, but at present there are issues
using syzkaller on ppc64le with qemu in TCG mode anyway.

Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
2019-01-15 16:45:20 +01:00
Dmitry Vyukov
88f5934633 vm: allow fine-grained control over program exit conditions
Currently we only support canExit flag.
However there are actually 3 separate conditions:
 - program can exit normally
 - program can timeout (e.g. fuzzer test or runtest can't)
 - program can exit with error (e.g. C test can)
Allow to specify these 3 conditions separately.
2018-12-24 09:59:56 +01:00
Michael Pratt
603b512405 vm/gvisor: use runsc debug --stacks to diagnose
This feature has been around longer than -trace-signal. It returns the
stacks directly, which we then append to the kernel log.
2018-12-21 18:08:49 +01:00
Michael Pratt
2fc01104d0 vm: allow Diagnose to directly return diagnosis
Rather than writing the diagnosis to the kernel console, Diagnose can
now directly return the extra debugging info, which will be appended ot
the kernel console log.
2018-12-21 18:08:49 +01:00
Dmitry Vyukov
a9cc88c19f pkg/osutil: provide better Rename
os.Rename fails for cross-device renaming (e.g. to/from tmpfs).
This is quite unpleasant. Provide own version that falls back to copying.
2018-12-17 19:09:10 +01:00
Dmitry Vyukov
527230f1d9 vm: fix string duplication
gometalinter says:

vm/vm.go:295:1⚠️ fuzzerPreemptedStr is unused (deadcode)
2018-12-17 10:46:08 +01:00
Dmitry Vyukov
c7e64e2b4f vm: don't call Diagnose when VM hasn't crashed
Fixes #875
2018-12-16 13:54:07 +01:00
Dmitry Vyukov
4bc415c230 vm: add tests for MonitorExecution
This gives almost 100% coverage for MonitorExecution.
Test all corner cases like lost connection, no output,
diagnose, exiting/non-exiting programs, etc.

Update #875
2018-12-16 13:54:03 +01:00
Michael Pratt
d5cf08b04e vm/gvisor: don't close conn on error
If net.Dial returns an error, conn is nil and closing it will panic.
2018-12-13 09:38:49 +01:00
Michael Pratt
c9d6aae44b Merge pull request #872 from prattmic/patch-2
vm/gvisor: support forwarding on IPv6
2018-12-13 09:38:36 +01:00
Dmitry Vyukov
7ed11ab916 vm: respect Shutdown signal in waitForOutput 2018-12-12 13:05:51 +01:00
Michael Pratt
c3b10a5d6a vm/gvisor: replace signal panic with log
Diagnose currently sends the panic signal to generate a traceback for
additional context.

However, Diagnose is also called in otherwise successful scenarios
(vm.Instance.MonitorExecution -> vm.monitor.extractError). Triggering a
panic will make this successful scenario look like a failure.

We could simply suppress this panic, but 1) that means we never shutdown
cleanly (not important, but ugly), and 2) we're less likely to detect
delayed crashes since we kill the sandbox immediately (that's what
MonitorExecution is checking for).

Instead, switch from -panic-signal to -trace-signal, which simply logs a
traceback without exiting. This option was added to runsc in
24c1158b9c.

The other uses of Diagnose will always generate a report regardless of
an additional panic, so we're not losing any reports.
2018-12-12 10:12:35 +01:00
Dmitry Vyukov
7dcaeaf322 vm/gce: close old consolew in Run
Run can be executed several times on a VM.
2018-12-02 13:23:51 +00:00
Greg Steuck
7a0edfbe7c vm/gce: use openbsd console diagnostic code for both vmm and gce
* openbsd: use console diagnostic code for both vmm and gce.

* gometalinter wants less indentation and more stuff in scope

* Comment no longer applies
2018-12-02 13:22:10 +00:00
Michael Tüxen
271b354c51 vm/qemu: improve debug output
* vm/qemu: Improve debug output.

When running in debug mode, the number of VMs is reduced to 1.
State this in the debug output.

* vm/qemu: Don't start debug output with a capital letter.

As requested by Dimitry.

* vm: Provide debug message when reduing number of VMs.

Apply this change to all affected platforms for consistency.
Suggested by Dmitry.

* Add myself to AUTHORS/CONTRIBUTORS files.

* vm: Fix compilation issues missed in earlier commit.

* vm: Use logging to write debug message.
2018-11-30 17:12:03 +00:00
Michael Tuexen
ade12e9162 vm/qemu: Allow empty qemu-args.
Allow setting qemu_args to "" in the config file. This is needed
when running qemu from the qemu-devel package on FreeBSD, which
does not support the -enable-kvm option.
Without this patch, an entry "" is added to the list of command
line parameters, which breaks the starting of the qemu instances.
2018-11-30 13:12:57 +00:00
Greg Steuck
6419afbb77 openbsd: run on gce
* build/openbsd: minor cleanup (use tuples instead of maps)

* Grammar nits in comments.

* Simplify openbsd.Create, will defer when there's more than one error exit.

* pkg/build: Support copying kernel into GCE image

* Simple test for openbsd image copy build.

* Cleanup in case something failed before.

* Support multi-processor VMs on GCE.

* More debug

* Reformat

* OpenBSD gce image needs to be raw.

* GC

* Force format to GNU directly on Go 1.10 or newer.

* Use vmType passed as a parameter inside openbsd.go

* gofmt

* more fmt

* Can't use GENERIC.mp just yet.

* capitalize

* Copyright
2018-11-27 13:14:06 +01:00
Greg Steuck
5bb36a9ef8 openbsd: include process information into crashes 2018-11-21 05:52:48 +01:00
Anton Lindqvist
f5e275d1d9 vm/vmm: make sure to always end ddb commands with a newline
Missed one in my previous commit.
2018-11-15 14:28:30 -08:00
Anton Lindqvist
74dbb80644 vm/vmm: disable pagination and show panic in Diagnose()
The ddb(4) debugger defaults to showing 24 lines at a time, the next chunk of
lines will be displayed only after receiving keyboard input. Setting maxlines to
0 disables pagination completely.
2018-11-12 12:03:13 -08:00
Dmitry Vyukov
6d8b3311b9 vm/qemu: don't use e1000 on arm64
arm64 uses virtio net by default and does not support e1000.
So don't override the default and use e1000 only for 386/amd64.
2018-10-28 19:07:22 +01:00
Dmitry Vyukov
75f4f60336 vm/qemu: use -cpu host,migratable=off
This exposes the maximum amount of features to the guest.
migratable=off exposes features that qemu does not know about too.
2018-10-28 19:07:22 +01:00
Nicolas Lacasse
d257b2d2d8 Pass -debug flag to runsc.
As of commit 3f053259, gVisor sentry panics are no longer sent to the
stderr for "runsc run" by default, as that stderr belongs exclusively to
the application.

As a result, syzbot never sees the gVisor panic stack trace, and is only
reporting errors that occur when waiting for a dead sandbox.

Passing the "-debug" flag to runsc will make the sentry panics visible
to syzbot again.
2018-10-17 21:43:37 +02:00
Anton Lindqvist
4b94574dd4 vm/vmm: use derived disks for VMs
As a result, the boot time is significantly improved since there's no longer any
need to copy the complete disk.

This feature was recently committed to OpenBSD-current. Any existing base image
used must be recreated, this time using the qcow2 disk format.
2018-10-11 19:47:20 +02:00
Dmitry Vyukov
2d41b5d964 vm/vmm: recover from vmctl errors faster
vmctl start periodically fails with:
	vmctl: start vm command failed: Operation already in progress

So try to sleep for a bit after vmctl stop.
And detect when vmctl start terminates prematurely
to avoid 10 minute timeout for ip extraction.
2018-09-20 19:44:50 +02:00
Dmitry Vyukov
565a5452a1 vm/vmm: don't start separate process for console
vmctl console fails from time to time with:

vmctl: console not found

Probably there is some race (most of these things assume
that there is a human typing commands with delays).

Also, vmctl start can connect to console itself with -c flag.
So use that because it both solves the console race and
also makes code much more similar to other VM implementations (qemu, gvisor).
This also eliminates 3 additional goroutines per VM.
2018-09-20 14:54:07 +02:00
Dmitry Vyukov
23db2ea6f9 vm/vmm: fix fd leaks
Close pipe fd's on failure paths.
Don't close outr because OutputMerger closes all passed in fd's.
2018-09-20 14:54:03 +02:00
Dmitry Vyukov
88f20b7bcc vm/vmm: increase timeouts
A dozen of vmm's running on a GCE machine can be really slow to boot.
Timeouts have only single goal: preventing complete system stalls
when/if external commands episodically hang. There is no value
in keeping them as close as possible to expected durations.
This can only lead to various flakes. Increase timeouts by an
order of magnitude.
2018-09-20 14:53:59 +02:00
Dmitry Vyukov
d1086008f6 vm/vmm: properly shutdown output reading goroutine
The goroutine sends on bootOutputStop to notify about its completion,
but the main goroutine is not receiving from the chan on success
and since the chan in unbuffered, the output reading goroutine
hangs on the send forever.
2018-09-20 14:53:56 +02:00
Dmitry Vyukov
3af0330c9e vm/vmm: make more robust after restarts
Instances from the previous run can still be running,
so always stop the previous instances before starting new ones.
2018-09-20 14:53:52 +02:00
Dmitry Vyukov
1c10e8337a vm/vmm: don't prefix vm name with syzkaller
I am getting:
failed to run vmctl -name syzkaller-ci-openbsd-main-test-0
vmctl: name too long

The name is auto-generated from parts which ensure that it is unique.
We can't easily name it shorter. So strip the syzkaller prefix,
which is not strictly necessary.
2018-09-20 14:53:48 +02:00
Dmitry Vyukov
845e8c5895 vm/vmm: remove cpu parameter, make template optional
CPU is not used. Remove it.
Template is not strictly necessary. Make it optional.
2018-09-20 14:53:44 +02:00
Dmitry Vyukov
a6a09fb2a0 vm/vmm: increase maximum number of VMs
8 is way too low. A modern beefy machine can host a hundred of VMs freely.
Make the limit consistent for all of qemu/kvm/gvisor/vmm and set it to 128.
2018-09-20 14:53:40 +02:00
Dmitry Vyukov
7819680a0b vm/vmm: enable network
Without -L local interface vio0 is not enabled
and we can't connect to the machine.

Update #712
2018-09-17 10:51:00 +02:00
Dmitry Vyukov
a54c2b7b92 syz-ci: de-hardcode list of VMs that support overcommit
We currently have this list in multiple places (somewhat diverged).
Specify this "overcommit" property in VM implementations.
In particular, we also want to allow overcommit for "vmm" type.

Update #712
2018-09-11 15:33:45 +02:00
Dmitry Vyukov
ec887defaf vm/gvisor: use new signal-based diagnose
Presumably "debug -stacks" sometimes fails to actually dump stacks (some runtime hangs?).
Use new mechanism that just sends a signal.
2018-08-29 18:32:26 -07:00
Anton Lindqvist
14b78b9701 vm/vmm: fix IP address detection
The IP address of a VM is calculated based on the formula 100.64.X.3 where X
being the ID of the VM, starting from 0. After starting 256 VMs 64 will flip
over to 65 and so on. A more robust solution to calculating the IP is to simply
read it from output during boot.

While here, stop using the VM ID as the identifier since the VM name also works.
2018-08-29 13:31:38 -07:00
Anton Lindqvist
de20bcbb68 vm/vmm: support for vmm found on OpenBSD (#678)
vm/vmm: add vmm implementation found on OpenBSD
2018-08-18 13:06:44 -07:00
Dmitry Vyukov
f557fcdfa6 vm/gvisor: fix current binary lookup
os.Args[0] can be just binary name which was looked up using $PATH.
In such case copy will fail because the path does not exist.
Lookup binary name using $PATH.
2018-08-03 21:08:11 +02:00
Dmitry Vyukov
28e60b2339 vm/gce: move console check into separate function
Update #538
2018-08-02 16:57:32 +02:00
Dmitry Vyukov
fbedd425b5 pkg/mgrconfig: move from syz-manager/mgrconfig
mgrconfig was used only by syz-manager initially,
but now it's used by a dozen of packages and it's
weird to import from under a binary dir.
pkg/ is much more reasonable dir for a widely used
helper package.
2018-08-02 16:57:32 +02:00
Dmitry Vyukov
2e17e2c0ad vm: refactor MonitorExecution
Too complex. Split into several functions.

Update #538
2018-08-02 16:57:31 +02:00
Dmitry Vyukov
c67a9331a4 gometalinter: clean up some errcheck warnings
Check some errors where relevant.
Unfortunately enabling errcheck does not look feasible, too many warnings.

Update #538
2018-08-02 16:57:31 +02:00
Dmitry Vyukov
0824d7a1bf vm/gce: fix build
fail
2018-07-29 10:16:20 +02:00
Dmitry Vyukov
419000cc0a vm: fix "kill fuzzer on first kernel bug"
The problem with that commit is that for GCE implementation
we immidiately kill console connection too when receive diagnose signal.
This leads to truncated output.
2018-07-29 10:07:30 +02:00
Zach Riggle
0889ba7a79 adb: Add console logic for ttyUSB.serial
By using UDEV rules, we can create device nodes which exist at

	/dev/ttyUSB.{android device serial}

Which makes it easier to determine which console belongs to a device.

While this is non-standard behavior, it's an inexpensive path check
and makes the lookup faster and deterministic.
2018-07-26 20:13:37 +02:00
Dmitry Vyukov
beb957b793 vm/qemu, vm/gce: kill fuzzer on first kernel bug
Some kernel bugs don't stop kernel.
For such bugs whiel vm.MonitorExecution waits for kernel output for 10 secs,
fuzzer continues running programs and produces tons of output
after the kernel bug message. Kill fuzzer once MonitorExecution
detects a kernel bug.
2018-07-24 13:44:48 +02:00
Dmitry Vyukov
a0512a53a3 vm/qemu: use e1000 instead of e1000e
e1000e fails on recent Debian distros with:
Initialization of device e1000e failed: failed to find romfile "efi-e1000e.rom
2018-07-23 20:28:18 +02:00
Dmitry Vyukov
e9da9436ad vm: fix "no output" detection
We obviously need ticker instead of timer in MonitorExecution.
2018-07-08 22:52:24 +02:00
Dmitry Vyukov
8c2335a205 vm/vmimpl: factor out common code for ssh args and waiting for ssh
Move common code from 4 vm implementations to vmimpl.
2018-07-06 14:02:06 +02:00