141 lines
3.0 KiB
Markdown
Raw Normal View History

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).
Defaults to `/sys/arch/amd64/compile/SYZKALLER/obj/bsd` if the
2018-08-28 20:15:25 +02:00
instructions are honored.
- `$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.
- `$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
```
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
$ 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)
enabled:
2018-08-28 20:15:25 +02:00
```sh
$ 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
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
$ vmctl create "qcow2:$VMIMG" -s 4G
2018-08-28 20:15:25 +02:00
```
3. Install VM:
```sh
$ 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
$ vmctl start syzkaller-1 -c -t syzkaller -d "$VMIMG"
$ ssh "root@100.64.${VMID}.3" 'cat >~/.ssh/authorized_keys' <$SSHKEY.pub
```
5. Optionally, library ASLR can be disabled in order to improve boot time:
```sh
$ ssh "root@100.64.${VMID}.3" 'echo library_aslr=NO >>/etc/rc.conf.local'
```
6. Finally, stop the VM:
```sh
$ 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",
"kernel_obj": "/sys/arch/amd64/compile/SYZKALLER/obj",
"kernel_src": "/",
2018-08-28 20:15:25 +02:00
"syzkaller": "$HOME/go/src/github.com/google/syzkaller",
"image": "$VMIMG",
"sshkey": "$SSHKEY",
2018-08-28 20:15:25 +02:00
"sandbox": "none",
"procs": 2,
"type": "vmm",
"vm": {
"count": 4,
"mem": 512,
"kernel": "$KERNEL",
"template": "syzkaller"
2018-08-28 20:15:25 +02:00
}
}
$ ./bin/syz-manager -config openbsd.cfg
```