Skip to content

Commit

Permalink
Add asan-ubsan instrumentation option (#231)
Browse files Browse the repository at this point in the history
This option combines ASan with UBSan, which is very useful for running
the replay tests as well as while iterating on a fuzz test locally.
  • Loading branch information
fmeum authored Sep 10, 2023
1 parent dff339f commit 3b77f15
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ build:ubsan-libfuzzer --//fuzzing:cc_engine=//fuzzing/engines:libfuzzer
build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer
build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=ubsan

# LibFuzzer + ASAN + UBSAN
build:asan-ubsan-libfuzzer --//fuzzing:cc_engine=//fuzzing/engines:libfuzzer
build:asan-ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer
build:asan-ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=asan-ubsan

# Honggfuzz + ASAN
build:asan-honggfuzz --//fuzzing:cc_engine=//fuzzing/engines:honggfuzz
build:asan-honggfuzz --@rules_fuzzing//fuzzing:cc_engine_instrumentation=honggfuzz
Expand All @@ -66,6 +71,11 @@ build:asan-replay --//fuzzing:cc_engine=//fuzzing/engines:replay
build:asan-replay --@rules_fuzzing//fuzzing:cc_engine_instrumentation=none
build:asan-replay --@rules_fuzzing//fuzzing:cc_engine_sanitizer=asan

# Replay + ASAN + UBSAN
build:asan-ubsan-replay --//fuzzing:cc_engine=//fuzzing/engines:replay
build:asan-ubsan-replay --@rules_fuzzing//fuzzing:cc_engine_instrumentation=none
build:asan-ubsan-replay --@rules_fuzzing//fuzzing:cc_engine_sanitizer=asan-ubsan

build:oss-fuzz --//fuzzing:cc_engine=@rules_fuzzing_oss_fuzz//:oss_fuzz_engine
build:oss-fuzz --//fuzzing:java_engine=@rules_fuzzing_oss_fuzz//:oss_fuzz_java_engine
build:oss-fuzz --@rules_fuzzing//fuzzing:cc_engine_instrumentation=oss-fuzz
Expand Down
10 changes: 10 additions & 0 deletions docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzin
build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer
build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=ubsan
# --config=asan-ubsan-libfuzzer
build:asan-ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer
build:asan-ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer
build:asan-ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=asan-ubsan
# --config=asan-honggfuzz
build:asan-honggfuzz --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:honggfuzz
build:asan-honggfuzz --@rules_fuzzing//fuzzing:cc_engine_instrumentation=honggfuzz
Expand All @@ -206,6 +211,11 @@ build:asan-replay --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/en
build:asan-replay --@rules_fuzzing//fuzzing:cc_engine_instrumentation=none
build:asan-replay --@rules_fuzzing//fuzzing:cc_engine_sanitizer=asan
# --config=asan-ubsan-replay
build:asan-ubsan-replay --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:replay
build:asan-ubsan-replay --@rules_fuzzing//fuzzing:cc_engine_instrumentation=none
build:asan-ubsan-replay --@rules_fuzzing//fuzzing:cc_engine_sanitizer=asan-ubsan
# --config=jazzer (Jazzer without sanitizer - Java only)
build:jazzer --@rules_fuzzing//fuzzing:java_engine=@rules_fuzzing//fuzzing/engines:jazzer
build:jazzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=jazzer
Expand Down
2 changes: 2 additions & 0 deletions fuzzing/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ string_flag(
# Undefined Behavior sanitizer (UBSAN).
# See https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
"ubsan",
# ASAN + UBSAN in a single build.
"asan-ubsan",
],
visibility = ["//visibility:public"],
)
Expand Down
1 change: 1 addition & 0 deletions fuzzing/instrum_opts.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ sanitizer_configs = {
"msan": instrum_defaults.msan,
"msan-origin-tracking": instrum_defaults.msan_origin_tracking,
"ubsan": instrum_defaults.ubsan,
"asan-ubsan": instrum_opts.merge(instrum_defaults.asan, instrum_defaults.ubsan),
}

0 comments on commit 3b77f15

Please sign in to comment.