]> git.feebdaed.xyz Git - 0xmirror/nftables.git/commit
support for afl++ (american fuzzy lop++) fuzzer
authorFlorian Westphal <fw@strlen.de>
Fri, 17 Oct 2025 11:51:41 +0000 (13:51 +0200)
committerFlorian Westphal <fw@strlen.de>
Tue, 11 Nov 2025 12:00:29 +0000 (13:00 +0100)
commitf2813fb53b00d6edde8bc9409712820c45de4c1e
tree39eacd46307645a8129fe45f7d83f9a7d1032435
parent454f361434522bbeba32e114a14c336e1ebf20a1
support for afl++ (american fuzzy lop++) fuzzer

afl comes with a compiler frontend that can add instrumentation suitable
for running nftables via the "afl-fuzz" fuzzer.

This change adds a "--with-fuzzer" option to configure script and enables
specific handling in nftables and libnftables to speed up the fuzzing process.
It also adds the "--fuzzer" command line option.

afl-fuzz initialisation gets delayed until after the netlink context is set up
and symbol tables such as (e.g. route marks) have been parsed.

When afl-fuzz restarts the process with a new input round, it will
resume *after* this point (see __AFL_INIT macro in main.c).

With --fuzzer <stage>, nft will perform multiple fuzzing rounds per
invocation: this increases processing rate by an order of magnitude.
The argument to '--fuzzer' specifies the last stage to run:

1: 'parser':
    Only run / exercise the flex/bison parser.

2: 'eval': stop after the evaluation phase.
    This attempts to build a complete ruleset in memory, does
    symbol resolution, adds needed shift/masks to payload instructions
    etc.

3: 'netlink-ro':
    'netlink-ro' builds the netlink buffer to send to the kernel,
    without actually doing so.

4: 'netlink-rw':
    Pass generated command/ruleset will be passed to the kernel.
    You can combine it with the '--check' option to send data to the kernel
    but without actually committing any changes.
    This could still end up triggering a kernel crash if there are bugs
    in the valiation / transaction / abort phases.

Use 'netlink-ro' if you want to prevent nft from ever submitting any
changes to the kernel or if you are only interested in fuzzing nftables
and its libraries.

In case a kernel splat is detected, the fuzzing process stops and all further
fuzzer attemps are blocked until reboot.

Signed-off-by: Florian Westphal <fw@strlen.de>
13 files changed:
.gitignore
Makefile.am
configure.ac
include/afl++.h [new file with mode: 0644]
include/nftables.h
src/afl++.c [new file with mode: 0644]
src/libnftables.c
src/main.c
src/preprocess.c
tests/afl++/README [new file with mode: 0644]
tests/afl++/afl-sysctl.conf [new file with mode: 0644]
tests/afl++/check_reproducers.sh [new file with mode: 0755]
tests/afl++/run-afl.sh [new file with mode: 0755]