diff options
author | tb <> | 2022-02-10 08:39:32 +0000 |
---|---|---|
committer | tb <> | 2022-02-10 08:39:32 +0000 |
commit | a752abdb7b677534ccead45ee888f69d0f3a6137 (patch) | |
tree | c21847c8a31f311b570a841effa488d87e064536 | |
parent | c4d44cc10c18e9c8ea39e5baa19d51f58af7f3ff (diff) | |
download | openbsd-a752abdb7b677534ccead45ee888f69d0f3a6137.tar.gz openbsd-a752abdb7b677534ccead45ee888f69d0f3a6137.tar.bz2 openbsd-a752abdb7b677534ccead45ee888f69d0f3a6137.zip |
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-- | src/regress/lib/libc/explicit_bzero/explicit_bzero.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/regress/lib/libc/explicit_bzero/explicit_bzero.c b/src/regress/lib/libc/explicit_bzero/explicit_bzero.c index 65d7b04813..496bafb208 100644 --- a/src/regress/lib/libc/explicit_bzero/explicit_bzero.c +++ b/src/regress/lib/libc/explicit_bzero/explicit_bzero.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: explicit_bzero.c,v 1.8 2022/02/09 07:48:15 tb Exp $ */ | 1 | /* $OpenBSD: explicit_bzero.c,v 1.9 2022/02/10 08:39:32 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Google Inc. | 3 | * Copyright (c) 2014 Google Inc. |
4 | * | 4 | * |
@@ -26,6 +26,17 @@ | |||
26 | #define ASSERT_NE(a, b) assert((a) != (b)) | 26 | #define ASSERT_NE(a, b) assert((a) != (b)) |
27 | #define ASSERT_GE(a, b) assert((a) >= (b)) | 27 | #define ASSERT_GE(a, b) assert((a) >= (b)) |
28 | 28 | ||
29 | #if defined(__has_feature) | ||
30 | #if __has_feature(address_sanitizer) | ||
31 | #define __SANITIZE_ADDRESS__ | ||
32 | #endif | ||
33 | #endif | ||
34 | #ifdef __SANITIZE_ADDRESS__ | ||
35 | #define ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address)) | ||
36 | #else | ||
37 | #define ATTRIBUTE_NO_SANITIZE_ADDRESS | ||
38 | #endif | ||
39 | |||
29 | /* 128 bits of random data. */ | 40 | /* 128 bits of random data. */ |
30 | static const char secret[16] = { | 41 | static const char secret[16] = { |
31 | 0xa0, 0x6c, 0x0c, 0x81, 0xba, 0xd8, 0x5b, 0x0c, | 42 | 0xa0, 0x6c, 0x0c, 0x81, 0xba, 0xd8, 0x5b, 0x0c, |
@@ -138,7 +149,7 @@ count_secrets(const char *buf) | |||
138 | return (res); | 149 | return (res); |
139 | } | 150 | } |
140 | 151 | ||
141 | static char * | 152 | ATTRIBUTE_NO_SANITIZE_ADDRESS static char * |
142 | test_without_bzero(void) | 153 | test_without_bzero(void) |
143 | { | 154 | { |
144 | char buf[SECRETBYTES]; | 155 | char buf[SECRETBYTES]; |
@@ -149,7 +160,7 @@ test_without_bzero(void) | |||
149 | return (res); | 160 | return (res); |
150 | } | 161 | } |
151 | 162 | ||
152 | static char * | 163 | ATTRIBUTE_NO_SANITIZE_ADDRESS static char * |
153 | test_with_bzero(void) | 164 | test_with_bzero(void) |
154 | { | 165 | { |
155 | char buf[SECRETBYTES]; | 166 | char buf[SECRETBYTES]; |