Skip to content

Commit 5aa218f

Browse files
committed
ci: Add simple fuzz-target to CI
Running it for 10 minutes is a good tradeoff to check for regression and not waste too much of CI resources
1 parent 4e4191b commit 5aa218f

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

.github/workflows/fuzzer.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "fuzzing lwip with afl++"
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: '*'
8+
9+
jobs:
10+
fuzz_test:
11+
name: Fuzzer tests for lwip
12+
13+
runs-on: ubuntu-22.04
14+
container: aflplusplus/aflplusplus
15+
steps:
16+
- name: Checkout lwip
17+
uses: actions/checkout@v4
18+
19+
- name: Run AFL++
20+
shell: bash
21+
run: |
22+
cd test/fuzz
23+
CC=afl-gcc-fast CCDEP=gcc make -j 4
24+
timeout 10m afl-fuzz -i inputs -o out -- ./lwip_fuzz || \
25+
if [ $? -eq 124 ]; then # timeout exit code
26+
if [ -n "$(find out/default/crashes -type f 2>/dev/null)" ]; then
27+
echo "Crashes found!";
28+
tar -czf out/default/crashes.tar.gz -C out/default crashes;
29+
exit 1;
30+
fi
31+
else
32+
exit 1;
33+
fi
34+
35+
- name: Upload Crash Artifacts
36+
if: failure()
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: fuzz-crashes
40+
path: test/fuzz/out/default/crashes.tar.gz
41+
if-no-files-found: ignore

test/fuzz/README

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
Fuzzing the lwIP stack (afl-fuzz requires linux/unix or similar)
32

43
This directory contains small apps that read Ethernet frames from stdin and
@@ -32,3 +31,15 @@ file to simplify viewing in wireshark.
3231
The lwipopts.h file needs to have checksum checking off, otherwise almost every
3332
packet will be discarded because of that. The other options can be tuned to
3433
expose different parts of the code.
34+
35+
To reproduce crashes or hangs, it's useful to build the fuzz targets locally
36+
(without AFL) and feed them with the saved output files (supplied as command
37+
line arguments), for example:
38+
39+
make clean && CC=gcc make
40+
./lwip_fuzz output/default/crashes/id:000001,sig:11,src:000254,time:13211,execs:374294,op:havoc,rep:3
41+
42+
Note: It's convenient to run AFL++ in a container:
43+
44+
docker pull aflplusplus/aflplusplus:latest
45+
docker run -ti -v /your-local-lwip-repo/:/lwip aflplusplus/aflplusplus

0 commit comments

Comments
 (0)