$ wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-8.2.0/gcc-8.2.0.tar.gz $ tar xzvf gcc-8.2.0.tar.gz $ cd gcc-8.2.0/ $ ./contrib/download_prerequisites $ sudo apt install texinfo bison flex $ mkdir build $ cd build $ ../configure --prefix=/usr/local/gcc --enable-bootstrap --enable-checking=release --enable-languages=c,c++ --disable-multilib $ make -j8 $ sudo make install $ vim ~/.bashrc export PATH=/usr/local/gcc/bin:$PATH $ source ~/.bashrc $ gcc -v ... gcc version 8.2.0 (GCC)
编译新版linux内核
linux kernel也需要coverage support,KCOV在linux kernel 4.6以后加入,可以用CONFIG_KCOV=y配置。 编译内核的大体步骤如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
$ wget http://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.1.tar.gz $ tar zxvf linux-5.1.tar.gz $ cd linux-5.1 $ make defconfig $ make kvmconfig $ vim .config CONFIG_KCOV=y CONFIG_DEBUG_INFO=y CONFIG_KASAN=y CONFIG_KASAN_INLINE=y CONFIG_CONFIGFS_FS=y CONFIG_SECURITYFS=y $ make oldconfig # 使能这些选项使得一些子选项可用,一路回车即可 $ make -j8
这样启动的qemu可能存在[FAILED] Failed to start Raise network interfaces.的错误,原因是虚拟机启动后网卡名称为enp0s3(ip a s命令可以查看),而/etc/network/interfaces里的默认配置为eth0,网卡名称配置错误,启动不了网络接口,需要在虚拟机里修改interfaces文件。
$ vim ~/.bashrc export GOROOT=/usr/local/go export GOPATH=/home/fanrong/gopath export PATH=$GOROOT/bin:$PATH
编译syzkaller
下载编译syzkaller源码:
1 2 3 4 5
$ go get -u -d github.com/google/syzkaller/... $ cd $GOPATH/src/github.com/google/syzkaller $ make $ ls bin linux_amd64 syz-db syz-manager syz-mutate syz-prog2c syz-repro syz-runtest syz-upgrade