Sign inSign up

qgrain/kernel-fuzz

By qgrain

Updated 8 months ago

Environments for kernel fuzzing based on Ubuntu 22.04, including llvm-17, gcc-12 and syzkaller.

Image
Security
Operating systems
0

344

qgrain/kernel-fuzz repository overview

kernel-fuzz

Environments for kernel fuzzing based on Ubuntu 22.04, including llvm-17, gcc-12 and syzkaller.

1 Usage

Pull or Create contrainer directly

# simple
docker run -itd --name NAME --ipc=host --privileged=true qgrain/kernel-fuzz:2204_v2

# full
docker run -itd -p XXXXX:22 -v /HOST/PATH/KERNELS:/root/kernels --name NAME --ipc=host --privileged=true qgrain/kernel-fuzz:2204_v2

Notice: every tag version is usable

Parameter Explanation:

  • set -p for ssh port mapping, easy for login
  • set -v for kernels, which is convenient for common files sharing in multiple containers (/HOST/PATH/KERNELS is where you compile the kernels)
  • set --priviledged to ensure the KVM module permmision

Compile the kernels

Since the installed llvm-16 and gcc-12 are not included in PATH, so you should use them through CC= like:

cd ~/kernels/linux-x.y.z
# modify the .config if needed
make CC=~/software/llvm-project-16.0.6.install/bin/clang olddefconfig
make CC=~/software/llvm-project-16.0.6.install/bin/clang -j8

2 What is done?

notice: http_proxy has been set in ~/.bashrc,please check it in your environment first

2.1 Based on Ubuntu 20.04
v1 (rebased on qgrain/ubuntu20-kernel:v1) (2024-05-05) Deprecated
# installed from apt
unzip sudo bc git tmux python3-dev python3-pip
binutils build-essential flex bison cmake(3.20.6) ninja-build
debootstrap qemu qemu-kvm
libssl-dev libelf-dev libc6-dev libc6-dev-i386 linux-libc-dev libgmp3-dev libmpfr-dev libmpc-dev

# installed from source
syzkaller go1.21.8 gcc12 llvm-project-16.0.6

# configurations
screen is beautified
http_proxy now works for sudo
directory structure:
| - software
    | - go1.21.8
    | - gopath1.21.8
    | - llvm-project-16.0.6.install
| - fuzzers
    | - syzkaller-f1b6b00
| - images
    | - image-template (created by syzkaller's create-image.sh)
    | - boot.sh (to boot qemu vm)
    | - debug.sh (to boot qemu vm for debug)
2004_base

Built for qgrain/syzgpt

2004_v1 (based on 2004_base)
go1.24.8 gcc-12.3.0 llvm-project-15.0.6
cmake-3.22.2
2.2 Based on Ubuntu 22.04
2204_v1
# configs
allow root login
allow sudo proxy
support CPU view in ~/.config/btop/btoprc
screen/vim are beautified
# installed from apt
ca-certificates vim nano unzip sudo bc git python3-dev python3-pip
screen tmux htop net-tools openssh-server curl inetutils-ping wget
binutils build-essential flex bison ninja-build cmake
debootstrap qemu qemu-kvm debian-archive-keyring
libssl-dev libelf-dev libc6-dev libc6-dev-i386 linux-libc-dev libgmp3-dev libmpfr-dev libmpc-dev
libgmp-dev libmpfr-dev libmpc-dev gcc-multilib g++-multilib

# installed from source
llvm-project-17.0.6 gdb-12.1(with pwndbg) gcc-12.3
go1.22.9 syzkaller-
2204_v2
# We need to install libdw-dev to support compiling linux kernel 6.14-rcX+
# or we will see fatal error: dwarf.h No such file or directory
apt install libdw-dev libelf-dev elfutils
apt install libzstd-dev zlib1g-dev

# to make extract with bluetooth support
apt install libbluetooth-dev

# support build llvm-project-20.1.2
apt install libunwind-dev

apt install libboost-all-dev

# upgrade go to 1.24.8 to support newer syzkaller
# checkout syzkaller to 6e83b42-20250630
# comment the http_proxy(s) in ~/.bashrc

3 TODO

sudo apt install -y build-essential autoconf libtool pkg-config
sudo apt install protobuf-compiler libprotobuf-dev netcat iproute2

# go package
# syzkaller project has grpc already, we only need the followings:
# go install google.golang.org/protobuf/cmd/[email protected]
# go install google.golang.org/grpc/cmd/[email protected]
# Not needed anymore, these dependencies should be resolved by the Makefiles of the fuzzers

# make sure $GOPATH/bin is added to PATH

# IMPORTANT
# replace images by images-auto managed by syzqemuctl
# fix a booting bug in the params of boot-vm.sh / debug.sh
# add '-cpu host,migratable=off \' and '-no-reboot \'

Tag summary

Content type

Image

Digest

sha256:cfd9fb1a3

Size

3.9 GB

Last updated

8 months ago

docker pull qgrain/kernel-fuzz:2004_v1