github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/docs/openbsd/setup.md (about) 1 # Setup 2 3 Instructions for running OpenBSD host, OpenBSD vm, amd64 kernel. 4 In addition, the host must be running `-current`. 5 6 Variables used throughout the instructions: 7 8 - `$KERNEL` - Custom built kernel, see [Compile Kernel](#compile-kernel). 9 Defaults to `/sys/arch/amd64/compile/SYZKALLER/obj/bsd` if the 10 instructions are honored. 11 - `$SSHKEY` - SSH key ***without a passphrase*** used to connect to the VMs, 12 it's advised to use a dedicated key. 13 - `$USER` - The name of the user intended to run syzkaller. 14 - `$VMIMG` - VM disk image. 15 - `$VMID` - The numeric ID of last started VM. 16 17 ## Install syzkaller 18 19 1. Install dependencies: 20 21 ```sh 22 # pkg_add git gmake go 23 ``` 24 25 In order for reproducers to work, GCC from ports is also required: 26 27 ```sh 28 # pkg_add gcc 29 ``` 30 31 2. Clone repository: 32 33 ```sh 34 $ git clone https://github.com/google/syzkaller 35 $ cd syzkaller 36 $ gmake all 37 ``` 38 39 ## Compile Kernel 40 41 A `GENERIC` kernel must be compiled with 42 [kcov(4)](https://man.openbsd.org/kcov.4) 43 enabled: 44 45 ```sh 46 $ cd /sys/arch/amd64 47 $ cat <<EOF >conf/SYZKALLER 48 include "arch/amd64/conf/GENERIC" 49 pseudo-device kcov 1 50 EOF 51 $ cp -R compile/GENERIC compile/SYZKALLER 52 $ make -C compile/SYZKALLER obj 53 $ make -C compile/SYZKALLER config 54 $ make -C compile/SYZKALLER 55 ``` 56 57 ## Create VM 58 59 1. [vmd(8)](https://man.openbsd.org/vmd.8) 60 must be configured to allow non-root users to create VMs since it removes the 61 need to run syzkaller as root: 62 63 ```sh 64 $ cat /etc/vm.conf 65 vm "syzkaller" { 66 disable 67 disk "/dev/null" 68 local interface 69 owner $USER 70 allow instance { boot, disk, memory } 71 } 72 ``` 73 74 2. Create disk image: 75 76 ```sh 77 $ vmctl create -s 4G "qcow2:$VMIMG" 78 ``` 79 80 3. Install VM: 81 82 ```sh 83 $ vmctl start -c -t syzkaller -b /bsd.rd -d "$VMIMG" syzkaller-1 84 ``` 85 86 Answers to questions that deviates from the defaults: 87 88 ``` 89 Password for root account? ****** 90 Allow root ssh login? yes 91 ``` 92 93 4. Restart the newly created VM and copy the SSH-key: 94 95 ```sh 96 $ vmctl stop -w syzkaller-1 97 $ vmctl start -c -t syzkaller -d "$VMIMG" syzkaller-1 98 $ ssh "root@100.64.${VMID}.3" 'cat >~/.ssh/authorized_keys' <$SSHKEY.pub 99 ``` 100 101 5. Optionally, library ASLR can be disabled in order to improve boot time: 102 103 ```sh 104 $ ssh "root@100.64.${VMID}.3" 'echo library_aslr=NO >>/etc/rc.conf.local' 105 ``` 106 107 6. Finally, stop the VM: 108 109 ```sh 110 $ vmctl stop -w syzkaller-1 111 ``` 112 113 ## Configure and run syzkaller 114 115 ```sh 116 $ pwd 117 ~/go/src/github.com/google/syzkaller 118 $ cat openbsd.cfg 119 { 120 "name": "openbsd", 121 "target": "openbsd/amd64", 122 "http": ":10000", 123 "workdir": "$HOME/go/src/github.com/google/syzkaller/workdir", 124 "kernel_obj": "/sys/arch/amd64/compile/SYZKALLER/obj", 125 "kernel_src": "/", 126 "syzkaller": "$HOME/go/src/github.com/google/syzkaller", 127 "image": "$VMIMG", 128 "sshkey": "$SSHKEY", 129 "sandbox": "none", 130 "procs": 2, 131 "type": "vmm", 132 "vm": { 133 "count": 4, 134 "mem": 512, 135 "kernel": "$KERNEL", 136 "template": "syzkaller" 137 } 138 } 139 $ ./bin/syz-manager -config openbsd.cfg 140 ```