diff --git a/crypto/fipsmodule/bcm.c b/crypto/fipsmodule/bcm.c index 4dbaef912..62abd7087 100644 --- a/crypto/fipsmodule/bcm.c +++ b/crypto/fipsmodule/bcm.c @@ -95,14 +95,6 @@ #if defined(BORINGSSL_FIPS) -#if defined(__has_feature) -#if __has_feature(address_sanitizer) -/* Integrity tests cannot run under ASAN because it involves reading the full - * .text section, which triggers the global-buffer overflow detection. */ -#define OPENSSL_ASAN -#endif -#endif - static void hexdump(const uint8_t *in, size_t len) { for (size_t i = 0; i < len; i++) { printf("%02x", in[i]); @@ -296,7 +288,7 @@ static EC_KEY *self_test_ecdsa_key(void) { return ec_key; } -#ifndef OPENSSL_ASAN +#if !defined(OPENSSL_ASAN) /* These symbols are filled in by delocate.go. They point to the start and end * of the module, and the location of the integrity hash, respectively. */ extern const uint8_t BORINGSSL_bcm_text_start[]; @@ -309,7 +301,9 @@ static void BORINGSSL_bcm_power_on_self_test(void) __attribute__((constructor)); static void BORINGSSL_bcm_power_on_self_test(void) { CRYPTO_library_init(); -#ifndef OPENSSL_ASAN +#if !defined(OPENSSL_ASAN) + /* Integrity tests cannot run under ASAN because it involves reading the full + * .text section, which triggers the global-buffer overflow detection. */ const uint8_t *const start = BORINGSSL_bcm_text_start; const uint8_t *const end = BORINGSSL_bcm_text_end; diff --git a/crypto/fipsmodule/is_fips.c b/crypto/fipsmodule/is_fips.c index 9af0dd2b7..bff1a058e 100644 --- a/crypto/fipsmodule/is_fips.c +++ b/crypto/fipsmodule/is_fips.c @@ -18,12 +18,6 @@ /* This file exists in order to give the fipsmodule target, in non-FIPS mode, * something to compile. */ -#if defined(__has_feature) -#if __has_feature(address_sanitizer) -#define OPENSSL_ASAN -#endif -#endif - int FIPS_mode(void) { #if defined(BORINGSSL_FIPS) && !defined(OPENSSL_ASAN) return 1; diff --git a/crypto/test/malloc.cc b/crypto/test/malloc.cc index 33f09721e..bb1a6a645 100644 --- a/crypto/test/malloc.cc +++ b/crypto/test/malloc.cc @@ -16,7 +16,7 @@ #if defined(__has_feature) #if __has_feature(address_sanitizer) || __has_feature(memory_sanitizer) -#define OPENSSL_ASAN +#define OPENSSL_ASAN_OR_MSAN #endif #endif @@ -32,7 +32,7 @@ // TODO(davidben): See if this and ASan's and MSan's interceptors can be made to // coexist. #if defined(__linux__) && defined(OPENSSL_GLIBC) && !defined(OPENSSL_ARM) && \ - !defined(OPENSSL_AARCH64) && !defined(OPENSSL_ASAN) + !defined(OPENSSL_AARCH64) && !defined(OPENSSL_ASAN_OR_MSAN) #include #include diff --git a/include/openssl/base.h b/include/openssl/base.h index c8ebee82a..6ea950164 100644 --- a/include/openssl/base.h +++ b/include/openssl/base.h @@ -202,6 +202,12 @@ extern "C" { #define BORINGSSL_UNSAFE_DETERMINISTIC_MODE #endif +#if defined(__has_feature) +#if __has_feature(address_sanitizer) +#define OPENSSL_ASAN +#endif +#endif + /* CRYPTO_THREADID is a dummy value. */ typedef int CRYPTO_THREADID;