diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2022-02-10 08:39:33 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2022-02-10 08:39:33 +0000 |
commit | 74e71b7ed589d1c6d413f9be6f774b35eab595cc (patch) | |
tree | 7ef71128f21bd3b920174c750dd69545841e7540 | |
parent | 4bea054be298c41ba53b202d2c0e4058206e2b52 (diff) |
If running with ASAN, mark test_with{,out}_bzero() with the
no_sanitize_address attribute. ASAN doesn't seem to be able
to understand these lowlevel gymnastics with sigaltstack()
and segfaults in __intercept_memem().
This allows LibreSSL and other portable projects that use this
test run tests with ASAN enabled.
Issue reported and workaround suggested by Ilya Shipitsin
Paraphrasing millert: it's a little ugly but it's only a regress.
-rw-r--r-- | regress/lib/libc/explicit_bzero/explicit_bzero.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/regress/lib/libc/explicit_bzero/explicit_bzero.c b/regress/lib/libc/explicit_bzero/explicit_bzero.c index 65d7b04813f..496bafb208c 100644 --- a/regress/lib/libc/explicit_bzero/explicit_bzero.c +++ b/regress/lib/libc/explicit_bzero/explicit_bzero.c @@ -1,4 +1,4 @@ -/* $OpenBSD: explicit_bzero.c,v 1.8 2022/02/09 07:48:15 tb Exp $ */ +/* $OpenBSD: explicit_bzero.c,v 1.9 2022/02/10 08:39:32 tb Exp $ */ /* * Copyright (c) 2014 Google Inc. * @@ -26,6 +26,17 @@ #define ASSERT_NE(a, b) assert((a) != (b)) #define ASSERT_GE(a, b) assert((a) >= (b)) +#if defined(__has_feature) +#if __has_feature(address_sanitizer) +#define __SANITIZE_ADDRESS__ +#endif +#endif +#ifdef __SANITIZE_ADDRESS__ +#define ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address)) +#else +#define ATTRIBUTE_NO_SANITIZE_ADDRESS +#endif + /* 128 bits of random data. */ static const char secret[16] = { 0xa0, 0x6c, 0x0c, 0x81, 0xba, 0xd8, 0x5b, 0x0c, @@ -138,7 +149,7 @@ count_secrets(const char *buf) return (res); } -static char * +ATTRIBUTE_NO_SANITIZE_ADDRESS static char * test_without_bzero(void) { char buf[SECRETBYTES]; @@ -149,7 +160,7 @@ test_without_bzero(void) return (res); } -static char * +ATTRIBUTE_NO_SANITIZE_ADDRESS static char * test_with_bzero(void) { char buf[SECRETBYTES]; |