summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2022-02-10 08:39:32 +0000
committertb <>2022-02-10 08:39:32 +0000
commita752abdb7b677534ccead45ee888f69d0f3a6137 (patch)
treec21847c8a31f311b570a841effa488d87e064536
parentc4d44cc10c18e9c8ea39e5baa19d51f58af7f3ff (diff)
downloadopenbsd-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.c17
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. */
30static const char secret[16] = { 41static 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
141static char * 152ATTRIBUTE_NO_SANITIZE_ADDRESS static char *
142test_without_bzero(void) 153test_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
152static char * 163ATTRIBUTE_NO_SANITIZE_ADDRESS static char *
153test_with_bzero(void) 164test_with_bzero(void)
154{ 165{
155 char buf[SECRETBYTES]; 166 char buf[SECRETBYTES];