2018-08-28 20:15:25 +02:00
|
|
|
# Setup
|
|
|
|
|
|
|
|
Instructions for running OpenBSD host, OpenBSD vm, amd64 kernel.
|
|
|
|
In addition, the host must be running `-current`.
|
|
|
|
|
|
|
|
Variables used throughout the instructions:
|
|
|
|
|
|
|
|
- `$KERNEL` - Custom built kernel, see [Compile Kernel](#compile-kernel).
|
2018-09-11 22:10:40 +02:00
|
|
|
Defaults to `/sys/arch/amd64/compile/SYZKALLER/obj/bsd` if the
|
2018-08-28 20:15:25 +02:00
|
|
|
instructions are honored.
|
2018-09-30 10:58:42 +02:00
|
|
|
- `$SSHKEY` - SSH key ***without a passphrase*** used to connect to the VMs,
|
|
|
|
it's advised to use a dedicated key.
|
2018-08-28 20:15:25 +02:00
|
|
|
- `$USER` - The name of the user intended to run syzkaller.
|
2018-09-30 10:58:42 +02:00
|
|
|
- `$VMIMG` - VM disk image.
|
2018-08-28 20:15:25 +02:00
|
|
|
- `$VMID` - The numeric ID of last started VM.
|
|
|
|
|
|
|
|
## Install syzkaller
|
|
|
|
|
|
|
|
1. Install dependencies:
|
|
|
|
|
|
|
|
```sh
|
2018-11-11 17:30:51 +01:00
|
|
|
# pkg_add git gmake go
|
2018-08-28 20:15:25 +02:00
|
|
|
```
|
|
|
|
|
2018-11-17 19:32:19 +01:00
|
|
|
In order for reproducers to work, GCC from ports is also required:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
# pkg_add gcc
|
|
|
|
```
|
|
|
|
|
2018-08-28 20:15:25 +02:00
|
|
|
2. Clone repository:
|
|
|
|
|
|
|
|
```sh
|
2018-09-30 10:58:42 +02:00
|
|
|
$ go get github.com/google/syzkaller
|
|
|
|
$ cd ~/go/src/github.com/google/syzkaller
|
2018-08-28 20:15:25 +02:00
|
|
|
$ gmake all
|
|
|
|
```
|
|
|
|
|
|
|
|
## Compile Kernel
|
|
|
|
|
|
|
|
A `GENERIC` kernel must be compiled with
|
|
|
|
[kcov(4)](https://man.openbsd.org/kcov.4)
|
2018-09-30 10:58:42 +02:00
|
|
|
enabled:
|
2018-08-28 20:15:25 +02:00
|
|
|
|
|
|
|
```sh
|
2018-09-11 22:10:40 +02:00
|
|
|
$ cd /sys/arch/amd64
|
|
|
|
$ cat <<EOF >conf/SYZKALLER
|
|
|
|
include "arch/amd64/conf/GENERIC"
|
|
|
|
pseudo-device kcov 1
|
|
|
|
EOF
|
|
|
|
$ cp -R compile/GENERIC compile/SYZKALLER
|
|
|
|
$ make -C compile/SYZKALLER obj
|
|
|
|
$ make -C compile/SYZKALLER config
|
|
|
|
$ make -C compile/SYZKALLER
|
2018-08-28 20:15:25 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
## Create VM
|
|
|
|
|
|
|
|
1. [vmd(8)](https://man.openbsd.org/vmd.8)
|
|
|
|
must be configured to allow non-root users to create VMs since it removes the
|
|
|
|
need to run syzkaller as root:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
$ cat /etc/vm.conf
|
|
|
|
vm "syzkaller" {
|
|
|
|
disable
|
2018-09-30 10:58:42 +02:00
|
|
|
disk "/dev/null"
|
2018-08-28 20:15:25 +02:00
|
|
|
local interface
|
|
|
|
owner $USER
|
|
|
|
allow instance { boot, disk, memory }
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
2. Create disk image:
|
|
|
|
|
|
|
|
```sh
|
2018-10-01 13:53:47 +02:00
|
|
|
$ vmctl create "qcow2:$VMIMG" -s 4G
|
2018-08-28 20:15:25 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
3. Install VM:
|
|
|
|
|
|
|
|
```sh
|
2018-09-30 10:58:42 +02:00
|
|
|
$ vmctl start syzkaller-1 -c -t syzkaller -b /bsd.rd -d "$VMIMG"
|
2018-08-28 20:15:25 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
Answers to questions that deviates from the defaults:
|
|
|
|
|
|
|
|
```
|
|
|
|
Password for root account? ******
|
|
|
|
Allow root ssh login? yes
|
|
|
|
```
|
|
|
|
|
|
|
|
4. Restart the newly created VM and copy the SSH-key:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
$ vmctl stop syzkaller-1 -w
|
2018-09-30 10:58:42 +02:00
|
|
|
$ vmctl start syzkaller-1 -c -t syzkaller -d "$VMIMG"
|
|
|
|
$ ssh "root@100.64.${VMID}.3" 'cat >~/.ssh/authorized_keys' <$SSHKEY.pub
|
2018-11-20 21:23:27 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
5. Optionally, library ASLR can be disabled in order to improve boot time:
|
|
|
|
|
|
|
|
```sh
|
2018-12-13 10:57:31 -08:00
|
|
|
$ ssh "root@100.64.${VMID}.3" 'echo library_aslr=NO >>/etc/rc.conf.local'
|
2018-11-20 21:23:27 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
6. Finally, stop the VM:
|
|
|
|
|
|
|
|
```sh
|
2018-09-30 10:58:42 +02:00
|
|
|
$ vmctl stop syzkaller-1 -w
|
2018-08-28 20:15:25 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
## Configure and run syzkaller
|
|
|
|
|
|
|
|
```sh
|
|
|
|
$ pwd
|
|
|
|
~/go/src/github.com/google/syzkaller
|
|
|
|
$ cat openbsd.cfg
|
|
|
|
{
|
|
|
|
"name": "openbsd",
|
|
|
|
"target": "openbsd/amd64",
|
|
|
|
"http": ":10000",
|
|
|
|
"workdir": "$HOME/go/src/github.com/google/syzkaller/workdir",
|
2018-09-11 22:10:40 +02:00
|
|
|
"kernel_obj": "/sys/arch/amd64/compile/SYZKALLER/obj",
|
2018-08-31 21:31:33 +02:00
|
|
|
"kernel_src": "/",
|
2018-08-28 20:15:25 +02:00
|
|
|
"syzkaller": "$HOME/go/src/github.com/google/syzkaller",
|
2018-09-30 10:58:42 +02:00
|
|
|
"image": "$VMIMG",
|
|
|
|
"sshkey": "$SSHKEY",
|
2018-08-28 20:15:25 +02:00
|
|
|
"sandbox": "none",
|
|
|
|
"procs": 2,
|
|
|
|
"type": "vmm",
|
|
|
|
"vm": {
|
|
|
|
"count": 4,
|
|
|
|
"mem": 512,
|
2018-09-19 07:21:00 +02:00
|
|
|
"kernel": "$KERNEL",
|
|
|
|
"template": "syzkaller"
|
2018-08-28 20:15:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$ ./bin/syz-manager -config openbsd.cfg
|
|
|
|
```
|