Skip to content

Commit

Permalink
Add use_fuzzing_engine build variable, refactor code to use it and fix
Browse files Browse the repository at this point in the history
code that erroneously only checked "use_libfuzzer"

TBR=dalecurtis@chromium.org,nick@chromium.org,noel@chromium.org,pwnall@chromium.org

Bug: 770974,770968
Change-Id: I16a58edc1a6ef6b7fcb9b779ea9af6c1d2b3320f
Reviewed-on: https://chromium-review.googlesource.com/707189
Reviewed-by: Oliver Chang <ochang@chromium.org>
Commit-Queue: Jonathan Metzman <metzman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#507521}
  • Loading branch information
jonathanmetzman authored and Commit Bot committed Oct 9, 2017
1 parent 81b708d commit d901d1b
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build/config/sanitizers/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ config("ubsan_vptr_flags") {
}

config("fuzzing_build_mode") {
if (use_libfuzzer || use_afl) {
if (use_fuzzing_engine) {
defines = [ "FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION" ]
}
}
Expand Down
5 changes: 5 additions & 0 deletions build/config/sanitizers/sanitizers.gni
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ using_sanitizer =
is_asan || is_lsan || is_tsan || is_msan || is_ubsan || is_ubsan_null ||
is_ubsan_vptr || is_ubsan_security || use_sanitizer_coverage || use_cfi_diag

# Whether we are doing a fuzzer build. Normally this should be checked instead
# of checking "use_libfuzzer || use_afl" because often developers forget to
# check for "use_afl".
use_fuzzing_engine = use_libfuzzer || use_afl

assert(!using_sanitizer || is_clang,
"Sanitizers (is_*san) require setting is_clang = true in 'gn args'")

Expand Down
2 changes: 1 addition & 1 deletion media/media_options.gni
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ declare_args() {
enable_ac3_eac3_audio_demuxing = proprietary_codecs && is_chromecast

enable_mse_mpeg2ts_stream_parser =
(proprietary_codecs && is_chromecast) || use_libfuzzer || use_afl
(proprietary_codecs && is_chromecast) || use_fuzzing_engine

# Enable support for the 'cbcs' encryption scheme added by MPEG Common
# Encryption 3rd Edition (ISO/IEC 23001-7), published 02/15/2016.
Expand Down
3 changes: 1 addition & 2 deletions testing/libfuzzer/fuzzer_test.gni
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ import("//testing/test.gni")
# config (.options file) file would be generated or modified in root output
# dir (next to test).
template("fuzzer_test") {
if (!disable_libfuzzer &&
(use_libfuzzer || use_afl || use_drfuzz || is_linux)) {
if (!disable_libfuzzer && (use_fuzzing_engine || use_drfuzz || is_linux)) {
assert(defined(invoker.sources), "Need sources in $target_name.")

test_deps = [ "//testing/libfuzzer:libfuzzer_main" ]
Expand Down
2 changes: 1 addition & 1 deletion third_party/expat/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import("//testing/libfuzzer/fuzzer_test.gni")
# let's not pull it in twice.
# Chromecast doesn't ship expat as a system library.
# Libfuzzer and AFL need to build library from sources.
if (is_linux && !is_chromecast && !use_libfuzzer && !use_afl) {
if (is_linux && !is_chromecast && !use_fuzzing_engine) {
config("expat_config") {
libs = [ "expat" ]
}
Expand Down
2 changes: 1 addition & 1 deletion third_party/qcms/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static_library("qcms") {
sources += [ "src/transform-sse2.c" ]
}

if (use_libfuzzer) {
if (use_fuzzing_engine) {
defines += [ "USE_LIBFUZZER" ]
}
}
Expand Down
2 changes: 1 addition & 1 deletion third_party/sqlite/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ if (!use_system_sqlite) {
# To avoid hitting those irrelevant OOMs, we limit max number of memory
# pages, so fuzzer will not crash when reaching the limit.
# Apply this for fuzzing builds only, not for all builds with sanitizers.
if (use_libfuzzer || use_afl) {
if (use_fuzzing_engine) {
defines += [ "SQLITE_MAX_PAGE_COUNT=16384" ]
}
}
Expand Down

0 comments on commit d901d1b

Please sign in to comment.