From a752abdb7b677534ccead45ee888f69d0f3a6137 Mon Sep 17 00:00:00 2001 From: tb <> Date: Thu, 10 Feb 2022 08:39:32 +0000 Subject: 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. --- src/regress/lib/libc/explicit_bzero/explicit_bzero.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/regress/lib/libc') 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 @@ -/* $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]; -- cgit v1.2.3-55-g6feb