diff --git a/build/autoconf/sanitize.m4 b/build/autoconf/sanitize.m4 index 07dc86bc41e2..becdf0295d9d 100644 --- a/build/autoconf/sanitize.m4 +++ b/build/autoconf/sanitize.m4 @@ -40,7 +40,10 @@ if test -n "$MOZ_ASAN"; then if test -z "$CLANG_CL"; then LDFLAGS="-fsanitize=address -rdynamic $LDFLAGS" fi + AC_DEFINE(MOZ_ASAN) + MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer) fi +AC_SUBST(MOZ_ASAN) dnl ======================================================== dnl = Use Memory Sanitizer @@ -51,7 +54,10 @@ if test -n "$MOZ_MSAN"; then if test -z "$CLANG_CL"; then LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins -rdynamic $LDFLAGS" fi + AC_DEFINE(MOZ_MSAN) + MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer) fi +AC_SUBST(MOZ_MSAN) dnl ======================================================== dnl = Use Thread Sanitizer @@ -62,12 +68,16 @@ if test -n "$MOZ_TSAN"; then if test -z "$CLANG_CL"; then LDFLAGS="-fsanitize=thread -rdynamic $LDFLAGS" fi + AC_DEFINE(MOZ_TSAN) + MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer) fi +AC_SUBST(MOZ_TSAN) dnl ======================================================== dnl = Use UndefinedBehavior Sanitizer (with custom checks) dnl ======================================================== if test -n "$MOZ_UBSAN_CHECKS"; then + MOZ_UBSAN=1 UBSAN_TXT="$_objdir/ubsan_blacklist.txt" cat $_topsrcdir/build/sanitizers/ubsan_*_blacklist.txt > $UBSAN_TXT UBSAN_FLAGS="-fsanitize=$MOZ_UBSAN_CHECKS -fno-sanitize-recover=$MOZ_UBSAN_CHECKS -fsanitize-blacklist=$UBSAN_TXT" @@ -76,12 +86,16 @@ if test -n "$MOZ_UBSAN_CHECKS"; then if test -z "$CLANG_CL"; then LDFLAGS="-fsanitize=undefined -rdynamic $LDFLAGS" fi + AC_DEFINE(MOZ_UBSAN) + MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer) fi +AC_SUBST(MOZ_UBSAN) dnl ======================================================== dnl = Use UndefinedBehavior Sanitizer to find integer overflows dnl ======================================================== if test -n "$MOZ_SIGNED_OVERFLOW_SANITIZE$MOZ_UNSIGNED_OVERFLOW_SANITIZE"; then + MOZ_UBSAN=1 SANITIZER_BLACKLISTS="" if test -n "$MOZ_SIGNED_OVERFLOW_SANITIZE"; then SANITIZER_BLACKLISTS="-fsanitize-blacklist=$_topsrcdir/build/sanitizers/ubsan_signed_overflow_blacklist.txt $SANITIZER_BLACKLISTS" @@ -90,6 +104,7 @@ if test -n "$MOZ_SIGNED_OVERFLOW_SANITIZE$MOZ_UNSIGNED_OVERFLOW_SANITIZE"; then if test -z "$CLANG_CL"; then LDFLAGS="-fsanitize=signed-integer-overflow -rdynamic $LDFLAGS" fi + AC_DEFINE(MOZ_SIGNED_OVERFLOW_SANITIZE) fi if test -n "$MOZ_UNSIGNED_OVERFLOW_SANITIZE"; then SANITIZER_BLACKLISTS="-fsanitize-blacklist=$_topsrcdir/build/sanitizers/ubsan_unsigned_overflow_blacklist.txt $SANITIZER_BLACKLISTS" @@ -98,10 +113,16 @@ if test -n "$MOZ_SIGNED_OVERFLOW_SANITIZE$MOZ_UNSIGNED_OVERFLOW_SANITIZE"; then if test -z "$CLANG_CL"; then LDFLAGS="-fsanitize=unsigned-integer-overflow -rdynamic $LDFLAGS" fi + AC_DEFINE(MOZ_UNSIGNED_OVERFLOW_SANITIZE) fi CFLAGS="$SANITIZER_BLACKLISTS $CFLAGS" CXXFLAGS="$SANITIZER_BLACKLISTS $CXXFLAGS" + AC_DEFINE(MOZ_UBSAN) + MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer) fi +AC_SUBST(MOZ_SIGNED_OVERFLOW_SANITIZE) +AC_SUBST(MOZ_UNSIGNED_OVERFLOW_SANITIZE) +AC_SUBST(MOZ_UBSAN) dnl ======================================================= dnl = Required for stand-alone (sanitizer-less) libFuzzer. @@ -110,6 +131,9 @@ if test -n "$LIBFUZZER"; then LDFLAGS="$LIBFUZZER_FLAGS -rdynamic $LDFLAGS" fi +# The LLVM symbolizer is used by all sanitizers +AC_SUBST(LLVM_SYMBOLIZER) + dnl ======================================================== dnl = Test for whether the compiler is compatible with the dnl = given sanitize options. diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure index c39a1bcfca97..9e9ae2657803 100644 --- a/build/moz.configure/toolchain.configure +++ b/build/moz.configure/toolchain.configure @@ -2429,8 +2429,6 @@ def asan(): add_old_configure_assignment("MOZ_ASAN", asan) -set_define("MOZ_ASAN", True, when=asan) -set_config("MOZ_ASAN", True, when=asan) # MSAN # ============================================================== @@ -2444,8 +2442,6 @@ def msan(): add_old_configure_assignment("MOZ_MSAN", msan) -set_define("MOZ_MSAN", True, when=msan) -set_config("MOZ_MSAN", True, when=msan) # TSAN # ============================================================== @@ -2459,8 +2455,6 @@ def tsan(): add_old_configure_assignment("MOZ_TSAN", tsan) -set_define("MOZ_TSAN", True, when=tsan) -set_config("MOZ_TSAN", True, when=tsan) # UBSAN # ============================================================== @@ -2497,6 +2491,7 @@ def ubsan(options, optimize): add_old_configure_assignment("MOZ_UBSAN_CHECKS", ubsan) + option( "--enable-signed-overflow-sanitizer", help="Enable UndefinedBehavior Sanitizer (Signed Integer Overflow Parts)", @@ -2509,8 +2504,6 @@ def ub_signed_overflow_san(): add_old_configure_assignment("MOZ_SIGNED_OVERFLOW_SANITIZE", ub_signed_overflow_san) -set_define("MOZ_SIGNED_OVERFLOW_SANITIZE", True, when=ub_signed_overflow_san) -set_config("MOZ_SIGNED_OVERFLOW_SANITIZE", True, when=ub_signed_overflow_san) option( @@ -2525,14 +2518,7 @@ def ub_unsigned_overflow_san(): add_old_configure_assignment("MOZ_UNSIGNED_OVERFLOW_SANITIZE", ub_unsigned_overflow_san) -set_define("MOZ_UNSIGNED_OVERFLOW_SANITIZE", True, when=ub_unsigned_overflow_san) -set_config("MOZ_UNSIGNED_OVERFLOW_SANITIZE", True, when=ub_unsigned_overflow_san) -# - -any_ubsan = ubsan | ub_signed_overflow_san | ub_unsigned_overflow_san -set_define("MOZ_UBSAN", True, when=any_ubsan) -set_config("MOZ_UBSAN", any_ubsan) # Security Hardening # ============================================================== @@ -3136,16 +3122,6 @@ set_config("HAVE_LIBFUZZER_FLAG_FUZZER_NO_LINK", libfuzzer_flags.no_link_flag_su set_config("LIBFUZZER_FLAGS", libfuzzer_flags.use_flags) add_old_configure_assignment("LIBFUZZER_FLAGS", libfuzzer_flags.use_flags) -# The LLVM symbolizer is used by all sanitizers -check_prog( - "LLVM_SYMBOLIZER", - ("llvm-symbolizer",), - allow_missing=True, - paths=clang_search_path, - when=asan | msan | tsan | any_ubsan, -) - - # Shared library building # ============================================================== diff --git a/mobile/android/config/mozconfigs/android-x86_64/nightly-fuzzing-asan b/mobile/android/config/mozconfigs/android-x86_64/nightly-fuzzing-asan index 6d00e50a0ba3..63467dafb210 100644 --- a/mobile/android/config/mozconfigs/android-x86_64/nightly-fuzzing-asan +++ b/mobile/android/config/mozconfigs/android-x86_64/nightly-fuzzing-asan @@ -15,9 +15,6 @@ ac_add_options --enable-fuzzing unset MOZ_STDCXX_COMPAT unset ENABLE_CLANG_PLUGIN -# We don't have a native LLVM_SYMBOLIZER yet -unset LLVM_SYMBOLIZER - # Add the path to the clang_rt used, so it can be packaged with the build. if [ -d "$MOZ_FETCHES_DIR/clang" ]; then CLANG_LIB_DIR="$(cd $MOZ_FETCHES_DIR/clang/lib/clang/*/lib/linux && pwd)"