This repository has been archived by the owner on May 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
137 lines (108 loc) · 3.68 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
###
# This dockerfile follows the instructions at https://github.com/google/syzkaller/blob/master/docs/linux/setup_ubuntu-host_qemu-vm_x86-64-kernel.md
###
###
# Set up build dependencies
###
FROM ubuntu:20.04 as build_dependencies
ENV SYZKALLER_DIR /syzkaller
ENV GCC $SYZKALLER_DIR/gcc
ENV KERNEL $SYZKALLER_DIR/kernel
ENV IMAGE $SYZKALLER_DIR/image
RUN mkdir $SYZKALLER_DIR
RUN mkdir $GCC
RUN mkdir $KERNEL
RUN mkdir $IMAGE
ENV DEBIAN_FRONTEND noninteractive
# Install additional packages
RUN apt update && apt install -y \
git \
build-essential \
libncurses-dev \
flex \
bison \
openssl \
libssl-dev \
dkms \
libelf-dev \
libudev-dev \
libpci-dev \
libiberty-dev \
autoconf \
wget \
qemu-kvm \
qemu-system-x86 \
bridge-utils \
gcc-9 g++-9 \
cmake
###
# Set up compilers
###
FROM build_dependencies as compiler_setup
#TODO - allow other compilers to be downloaded and built if necessary
# Get a supported version of gcc: https://github.com/google/syzkaller/blob/master/docs/syzbot.md#crash-does-not-reproduce
WORKDIR $SYZKALLER_DIR
RUN wget https://storage.googleapis.com/syzkaller/gcc-9.0.0-20181231.tar.gz
RUN tar xzvf gcc-9.0.0-20181231.tar.gz
RUN apt install -y clang
# Uncomment the following blocks to build clang from source, using same commit as syzbot
# RUN mkdir llvm-project
# WORKDIR $SYZKALLER_DIR/llvm-project
# RUN git init && git remote add origin https://github.com/llvm/llvm-project.git
# RUN git fetch --depth=1 origin c2443155a0fb245c8f17f2c1c72b6ea391e86e81 && git checkout FETCH_HEAD
# RUN mkdir build
# WORKDIR $SYZKALLER_DIR/llvm-project/build
# RUN cmake -G "Unix Makefiles" \
# -DLLVM_ENABLE_PROJECTS='clang' \
# -DCMAKE_BUILD_TYPE=Release \
# -DCMAKE_INSTALL_PREFIX=/tmp/clang_install \
# ../llvm
# RUN cmake --build . -- -j8
# RUN cmake --build . --target install
###
# Get the qemu image setup
###
FROM build_dependencies as container_setup
WORKDIR $SYZKALLER_DIR
# copy in clang binaries from previous stages
#COPY --from=compiler_setup /tmp/clang_install /usr/local
# additional utilities
RUN apt update && apt install -y iproute2 \
net-tools \
vim \
tmux \
python3 python3-pip
# Enable deb-srcs
RUN sed -i '/^#\sdeb-src /s/^#//' "/etc/apt/sources.list"
# install kernel build dependencies
RUN apt update && apt-get build-dep -y linux
# get the kernel sources
# RUN git clone https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git $KERNEL
# using image from syzkaller project
COPY ./bootstrap_img/stretch.img $IMAGE
COPY ./bootstrap_img/stretch.id_rsa $IMAGE
# copy scripts and give them execute privs
WORKDIR $SYZKALLER_DIR/bin
COPY bin/* ./
RUN chmod +x *
# disable the ssh key checking
RUN echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config
WORKDIR $SYZKALLER_DIR
ENV CRASHERS $SYZKALLER_DIR/crashers
RUN mkdir meta && mkdir crashers
COPY crashers/build_crashers.sh crashers/
RUN chmod +x crashers/build_crashers.sh
# setup scrapy scraper
RUN pip3 install scrapy
RUN pip3 install --upgrade attrs
COPY syzbot_scraper .
COPY scrape_syzbot.py .
COPY run_repro.sh .
RUN chmod +x run_repro.sh
# configure some environment variables
ENV PATH=$PATH:/syzkaller/bin
###
# Boot qemu image
###
FROM container_setup as run
CMD ["bash"]