User Tools

Site Tools


syzkaller_with_ubuntu_host_and_freebsd_guest

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
syzkaller_with_ubuntu_host_and_freebsd_guest [2019/01/30 08:18] – msvoelkersyzkaller_with_ubuntu_host_and_freebsd_guest [2019/01/30 09:10] (current) – [Run syzkaller] msvoelker
Line 8: Line 8:
  
 The first task is to create VM with target OS. The second one is to build syzkaller (requires go) and the third and last one is to create a config in order to run syzkaller. The first task is to create VM with target OS. The second one is to build syzkaller (requires go) and the third and last one is to create a config in order to run syzkaller.
 +
 +My environment:
 +  * Host: Ubuntu 18.04.1 LTS (amd64) 
 +  * Target: FreeBSD-13.0-CURRENT-amd64-20190110
 +  * QEMU emulator version 2.11.1
  
 ===== Create FreeBSD VM ===== ===== Create FreeBSD VM =====
  
-create directory on host for vm +==== Create VM and install FreeBSD ====
-  mkdir -p ~/qemu/freebsd+
  
-create qemu hard disk image +create directory and qemu hard disk image 
-  sudo qemu-img create freebsd.img 8G+  mkdir -p ~/qemu/freebsd 
 +  cd ~/qemu/freebsd 
 +  sudo qemu-img create freebsd.img 16G
  
-start vm and install FreeBSD (download iso from freebsd.org) +start vm and install FreeBSD (download iso from freebsd.org). Make sure FreeBSD source files are copied to /usr/src during installation. 
-  sudo qemu-system-x86_64 -enable-kvm -hda freebsd.img -m 2G -net user,hostfwd=tcp::10021-:22 -net nic -curses -cdrom FreeBSD iso -boot d+  sudo qemu-system-x86_64 -enable-kvm -hda freebsd.img -m 2G -net user,hostfwd=tcp::10021-:22 -net nic -curses -cdrom FreeBSD.iso -boot d
  
 after installation let vm print to console -> add in /boot/loader.conf after installation let vm print to console -> add in /boot/loader.conf
Line 24: Line 30:
  
 start vm without graphic and with network start vm without graphic and with network
-sudo qemu-system-x86_64 -hda freebsd.img -enable-kvm -m 2G -net user,hostfwd=tcp::10021-:22 -net nic -nographic+  sudo qemu-system-x86_64 -hda freebsd.img -enable-kvm -m 2G -net user,hostfwd=tcp::10021-:22 -net nic -nographic 
   * -net user let the vm uses a user mode network stack. Since hostfwd=tcp::10021-:22 is added, a connection to localhost:10021 (on host) is forwarded to the vm.   * -net user let the vm uses a user mode network stack. Since hostfwd=tcp::10021-:22 is added, a connection to localhost:10021 (on host) is forwarded to the vm.
 <code> <code>
Line 34: Line 41:
                            ---->  SMB server (10.0.2.4)</code>                            ---->  SMB server (10.0.2.4)</code>
   * -nographic prints the console output of the vm directly into the console on the host   * -nographic prints the console output of the vm directly into the console on the host
 +
 +==== Enable KCOV support for FreeBSD ====
 +
 +By now, KCOV support is not enabled by default. Create a own kernel config file in the VM (/usr/src should contain the FreeBSD source files).
 +  cd /usr/src/sys/amd64/conf
 +  cp GENERIC KCOV
 +  
 +In file KCOV, uncomment the lines
 +  options        COVERAGE
 +  options        KCOV
 +
 +Build and install FreeBSD kernel as root, and restart
 +  cd /usr/src
 +  make -j4 kernel KERNCONF=KCOV
 +  shutdown -r now
 +
 +==== Allow SSH root access to FreeBSD ====
  
 syzkaller needs root access to the OS in the VM via SSH. syzkaller needs root access to the OS in the VM via SSH.
Line 40: Line 64:
   ssh-keygen -f freebsd_id_rsa   ssh-keygen -f freebsd_id_rsa
  
-add public key on the host (from freebsd_id_rsa.pub) into /root/.ssh/authorized_keys in the vm+add public key of the host (freebsd_id_rsa.pub) into /root/.ssh/authorized_keys in the vm
  
 allow ssh as root in vm. In /etc/ssh/sshd_config set allow ssh as root in vm. In /etc/ssh/sshd_config set
Line 95: Line 119:
  
 ===== Run syzkaller ===== ===== Run syzkaller =====
 +
 +To present code coverage, syzkaller needs FreeBSD source and object files. Start the VM with qemu and use scp on host to copy source and object files from target to host.
 +  mkdir -p ~/freebsd/usr
 +  scp -r -o "StrictHostKeyChecking no" -P 10021 localhost:/usr/src ~/freebsd/usr/
 +  scp -r -o "StrictHostKeyChecking no" -P 10021 localhost:/usr/obj ~/freebsd/usr/
  
 create syz-manager config file (on host) ~/gopath/src/github.com/google/syzkaller/freebsd.cfg create syz-manager config file (on host) ~/gopath/src/github.com/google/syzkaller/freebsd.cfg
Line 101: Line 130:
     "http": "127.0.0.1:56741",     "http": "127.0.0.1:56741",
     "workdir": "/home/msvoelker/gopath/src/github.com/google/syzkaller/workdir",     "workdir": "/home/msvoelker/gopath/src/github.com/google/syzkaller/workdir",
-    "image": "/home/msvoelker/qemu/freebsd2/freebsd.img", +    "image": "/home/msvoelker/qemu/freebsd/freebsd.img", 
-    "sshkey": "/home/msvoelker/qemu/freebsd2/freebsd_id_rsa",+    "sshkey": "/home/msvoelker/qemu/freebsd/freebsd_id_rsa",
     "syzkaller": "/home/msvoelker/gopath/src/github.com/google/syzkaller",     "syzkaller": "/home/msvoelker/gopath/src/github.com/google/syzkaller",
 +    "kernel_obj": "/home/msvoelker/freebsd/usr/obj/usr/src/amd64.amd64/sys/KCOV",
 +    "kernel_src": "/home/msvoelker/freebsd",
     "enable_syscalls": [     "enable_syscalls": [
       "socket$inet_sctp",       "socket$inet_sctp",
Line 114: Line 145:
       "close"       "close"
     ],     ],
-    "procs": 4,+    "procs": 1,
     "type": "qemu",     "type": "qemu",
     "cover": true,     "cover": true,
     "vm": {     "vm": {
-      "count": 4,+      "count": 16,
       "cpu": 1,       "cpu": 1,
-      "mem": 2048+      "mem": 1024
     }     }
   }   }
Line 128: Line 159:
   sudo bin/syz-manager -config freebsd.cfg   sudo bin/syz-manager -config freebsd.cfg
      
 +For a status page, open http://localhost:56741 in a browser.
 ===== Links ===== ===== Links =====
  
-Documentation for syzkaller: https://github.com/google/syzkaller+github repository for syzkaller (contains documentation): https://github.com/google/syzkaller
  
  
syzkaller_with_ubuntu_host_and_freebsd_guest.1548836324.txt.gz · Last modified: by msvoelker