In libressl-portable we run the explicit_bzero tests as part of the
builds. If we enable ASAN on linux, this test segfaults in
__interceptor_memmem() in the two test_with{,out}_bzero() functions,
presumably because the sigaltstack magic is too low level for ASAN to
grok.

Would the patch below that disables ASAN for these functions be
acceptable or shold we maintain it in the libressl-portable repo?

https://github.com/google/sanitizers/wiki/AddressSanitizer#turning-off-instrumentation

Index: explicit_bzero.c
===================================================================
RCS file: /cvs/src/regress/lib/libc/explicit_bzero/explicit_bzero.c,v
retrieving revision 1.8
diff -u -p -r1.8 explicit_bzero.c
--- explicit_bzero.c    9 Feb 2022 07:48:15 -0000       1.8
+++ explicit_bzero.c    9 Feb 2022 07:56:43 -0000
@@ -26,6 +26,12 @@
 #define ASSERT_NE(a, b) assert((a) != (b))
 #define ASSERT_GE(a, b) assert((a) >= (b))
 
+#if defined(__clang__) || defined (__GNUC__)
+#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 +144,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 +155,7 @@ test_without_bzero(void)
        return (res);
 }
 
-static char *
+ATTRIBUTE_NO_SANITIZE_ADDRESS static char *
 test_with_bzero(void)
 {
        char buf[SECRETBYTES];

Reply via email to