This is the open-source repo for the paper titled "MOAT: Towards Safe BPF Kernel Extension".
moat_linux
: Our modified Linux kernel with MOAT-support, based on Linux 6.1.38libbpf-bootstrap
: The user space facilities for convenient loading & executing BPF programslibbpf-bootstrap/examples/moat_test
: Our test cases used in the paper
sudo make && sudo make modules_install
Please follow the libbpf-bootstrap to get necessary tools ready.
cd libbpf-bootstrap/examples/moat_test/
make
Note that the performance of MOAT could vary depending on your hardware setup.
You need at least two machines for the network experiment; one is the host generating traffic and the other is the tested device with MOAT-hardened BPF programs.
- Install the kernel with MOAT-support on the tested device.
- Ensure that two machines are in the same network.
- Compile the test cases, such as
sockex{1...4}
. - On the tested device, run
iperf3 -s
to process packets. - On the host, run
iperf3
to generate packets.
- Compile the test case,
tracepoints.c
. It loads 11 BPF programs to trace system events like page faults. - Compile the UnixBench.
- Load the BPF programs by
./tracepoints
. - Run the UnixBench with
./Run -c $(nproc) > results
.
Please follow the guide in sysfilter
to use sysfilter
to harden Nginx, then run wrk
to benchmark the hardened
Nginx.
In the paper, we also include two experiments showing that MOAT supports numerous BPF programs.
To reproduce the first experiment, you can find there are
execve_X.c
and execve_X.bpf.c
sources in moat_test
folder. These
programs attach X
BPF programs to the exec
system call. You can then
run ./unix_syscall <duration> e
to obtain the throughput of execl
.
To reproduce the second experiment, you can find there is a syscalls.c
and syscalls.bpf.c
sources in moat_test
folder. These programs attach
all available system call tracepoints in the system. You can then run
UnixBench to obtain an overall system performance score.
Depending on your configuration, the tracepoints available in our system may not be completely the same as yours; in such case, please regenerate the
syscall.bpf.c
withsyscall2bpf.py
@inproceedings{moat,
author = {Lu, Hongyi and Wang, Shuai and Wu, Yechang and He, Wanning and Zhang, Fengwei},
title = {{MOAT}: {Towards} {Safe} {BPF} {Kernel} {Extension}},
booktitle = {33nd USENIX Security Symposium},
year = {2024}
}