lazymio de2bc166f0
Implementation of SAND: Decoupling Sanitization from Fuzzing for Low Overhead (#3037)
* Reference implementation of SAND: Decoupling Sanitization from Fuzzing for Low Overhead

* Format code

* make clippy happy

* Update docs

* clean output

* fmt

* Fix for nostd

* Update docs

* use use alloc::vec::Vec;

* Docs updates

* Update docs

* Format toml

* Format again

* Add CI

* Rename run_targets to run_target_all

* Update docs

* Update justfile to test fuzzer

* left out justfile

* Format

* Corner case when bitmap size is as small as 1

* Add comments

* clippy

* Format vuln.c

* Format toml

* Fix doc

* Fix justfile

* Move ExecutorsTuple to executors/mod.rs

* Fix

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-03-06 14:15:22 +01:00

74 lines
1.9 KiB
Makefile

FUZZER_NAME := 'fuzzbench_forkserver_sand'
FORKSERVER_NAME := 'fuzzbench_forkserver_sand'
CARGO_TARGET_DIR := env("CARGO_TARGET_DIR", "target")
PROFILE := env("PROFILE", "release")
PROFILE_DIR := if PROFILE == "release" { "release" } else if PROFILE == "dev" { "debug" } else { "debug" }
LIBAFL_CC := PROJECT_DIR / CARGO_TARGET_DIR / PROFILE_DIR / "sand_cc"
LIBAFL_CXX := PROJECT_DIR / CARGO_TARGET_DIR / PROFILE_DIR / "sand_cxx"
FUZZER := PROJECT_DIR / CARGO_TARGET_DIR / PROFILE_DIR / FUZZER_NAME
FORKSERVER := PROJECT_DIR / CARGO_TARGET_DIR / PROFILE_DIR / FORKSERVER_NAME
PROJECT_DIR := absolute_path(".")
alias cc := cxx
[linux]
[macos]
cxx:
cargo build --profile {{PROFILE}}
[windows]
cxx:
echo "Unsupported on this platform"
[linux]
[macos]
fuzzer: cxx
{{LIBAFL_CC}} {{PROJECT_DIR}}/src/vuln.c -o vuln_native -lm -lz
[windows]
fuzzer:
echo "Unsupported on this platform"
[linux]
[macos]
fuzzer_asan: cxx
AFL_SAN_NO_INST=1 {{LIBAFL_CC}} {{PROJECT_DIR}}/src/vuln.c -fsanitize=address -o vuln_asan -lm -lz
[windows]
fuzzer_asan:
echo "Unsupported on this platform"
[linux]
[macos]
run: fuzzer fuzzer_asan
#!/bin/bash
mkdir -p input && echo "a" >> input/a
taskset -c 1 {{FUZZER}} -i input -o /tmp/out -a ./vuln_asan -t 1000 ./vuln_native
[windows]
run: fuzzer fuzzer_asan
echo "Unsupported on this platform"
[linux]
[macos]
test: fuzzer fuzzer_asan
#!/bin/bash
mkdir -p input && echo "a" >> input/a
timeout 10s {{FUZZER}} -i input -o /tmp/out -a ./vuln_asan -t 1000 ./vuln_native | tee fuzz_stdout.log || true
if grep -qa "objectives: 1" fuzz_stdout.log; then
echo "Fuzzer is working"
else
echo "Fuzzer does not generate any testcases or any crashes"
exit 1
fi
[windows]
test: fuzzer fuzzer_asan
echo "Unsupported on this platform"
clean:
rm -rf {{FUZZER}}
rm -rf vuln_native vuln_asan
cargo clean