Skip to content

Commit

Permalink
Merge pull request #1813 from kevinbackhouse/FuzzWithASAN
Browse files Browse the repository at this point in the history
Add sanitizer flags when fuzzing
  • Loading branch information
kevinbackhouse authored Aug 8, 2021
2 parents 4bcccaa + 89abcad commit ee3016c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/on_PR_linux_fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
run: |
cd build
mkdir corpus
./bin/fuzz-read-print-write corpus ../test/data/ -dict=../fuzz/exiv2.dict -jobs=$(nproc) -workers=$(nproc) -max_total_time=120 -max_len=4096
LSAN_OPTIONS=suppressions=../fuzz/knownleaks.txt ./bin/fuzz-read-print-write corpus ../test/data/ -dict=../fuzz/exiv2.dict -jobs=$(nproc) -workers=$(nproc) -max_len=4096 -max_total_time=120
2 changes: 1 addition & 1 deletion cmake/compilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ if ( MINGW OR UNIX OR MSYS ) # MINGW, Linux, APPLE, CYGWIN
endif()
elseif( COMPILER_IS_CLANG )
if ( EXIV2_BUILD_FUZZ_TESTS )
set(SANITIZER_FLAGS "-fsanitize=fuzzer-no-link")
set(SANITIZER_FLAGS "-fsanitize=fuzzer-no-link,address,undefined")
elseif ( CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9 )
set(SANITIZER_FLAGS "-fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=all")
elseif ( CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.4 )
Expand Down
2 changes: 1 addition & 1 deletion fuzz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This is the command to run the fuzzer for 2 minutes:
```bash
cd <exiv2dir>/build-fuzz
mkdir corpus
./bin/fuzz-read-print-write corpus ../test/data/ -dict=../fuzz/exiv2.dict -jobs=$(nproc) -workers=$(nproc) -max_total_time=120
LSAN_OPTIONS=suppressions=../fuzz/knownleaks.txt ./bin/fuzz-read-print-write corpus ../test/data/ -dict=../fuzz/exiv2.dict -jobs=$(nproc) -workers=$(nproc) -max_len=20480 -max_total_time=120
```

Alternatively, a simple script is provided for running the fuzzer in a continuous loop:
Expand Down
4 changes: 2 additions & 2 deletions fuzz/fuzzloop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ do
mv corpus/ corpus2
mkdir corpus
echo minimizing corpus
./bin/fuzz-read-print-write -merge=1 corpus ../test/data/ corpus2/
LSAN_OPTIONS=suppressions=../fuzz/knownleaks.txt ./bin/fuzz-read-print-write -merge=1 corpus ../test/data/ corpus2/ -max_len=20480
rm -r corpus2

# Run the fuzzer for 4 hours
date
echo start fuzzer
./bin/fuzz-read-print-write corpus -dict=../fuzz/exiv2.dict -jobs=$(nproc) -workers=$(nproc) -max_total_time=14400
LSAN_OPTIONS=suppressions=../fuzz/knownleaks.txt ./bin/fuzz-read-print-write corpus -dict=../fuzz/exiv2.dict -jobs=$(nproc) -workers=$(nproc) -max_len=20480 -max_total_time=14400
done
4 changes: 4 additions & 0 deletions fuzz/knownleaks.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Known memory leak in expat, caused by xmpsdk throwing an exception.
# See https://github.com/Exiv2/exiv2/issues/1821
leak:libexpat.so

0 comments on commit ee3016c

Please sign in to comment.