commit 53ee764: [Minor] Disable asan for specific bad parts of the code

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Sep 25 15:00:07 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-09-25 15:57:17 +0100
URL: https://github.com/rspamd/rspamd/commit/53ee76478db9ef0ce457773b8b158fb30c381a39 (HEAD -> master)

[Minor] Disable asan for specific bad parts of the code

---
 config.h.in              | 22 ++++++++++++++++++++++
 contrib/lc-btrie/btrie.c |  2 +-
 contrib/t1ha/t1ha_bits.h |  4 ----
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/config.h.in b/config.h.in
index 57b887b85..f36a3a474 100644
--- a/config.h.in
+++ b/config.h.in
@@ -370,6 +370,28 @@ typedef off_t goffset;
 #endif
 #endif
 
+/* Address sanitizer */
+#ifdef __clang__
+#  if __has_feature(address_sanitizer)
+/* emulate gcc's __SANITIZE_ADDRESS__ flag */
+#    define __SANITIZE_ADDRESS__
+#    define RSPAMD_NO_SANITIZE \
+      __attribute__((no_sanitize("address", "hwaddress")))
+#  else
+#    define RSPAMD_NO_SANITIZE
+#  endif
+#elif defined(__GNUC__)
+/* GCC based */
+#  if __has_attribute(__no_sanitize_address__)
+#    define RSPAMD_NO_SANITIZE __attribute__((no_sanitize_address))
+#  else
+#    define RSPAMD_NO_SANITIZE
+#  endif
+#else
+#  define RSPAMD_NO_SANITIZE
+#endif
+
+
 #ifndef BITSPERBYTE
 # define BITSPERBYTE (NBBY * sizeof (char))
 #endif
diff --git a/contrib/lc-btrie/btrie.c b/contrib/lc-btrie/btrie.c
index 8b598b09b..6e529db90 100644
--- a/contrib/lc-btrie/btrie.c
+++ b/contrib/lc-btrie/btrie.c
@@ -632,7 +632,7 @@ static inline unsigned count_bits_from(tbm_bitmap_t bm, int b)
 
 /* extracts a few bits from bitstring, returning them as an integer */
 static inline btrie_oct_t extract_bits(const btrie_oct_t *prefix, unsigned pos,
-		unsigned nbits)
+		unsigned nbits) RSPAMD_NO_SANITIZE
 {
 	if (nbits == 0)
 		return 0;
diff --git a/contrib/t1ha/t1ha_bits.h b/contrib/t1ha/t1ha_bits.h
index 799737d5f..5710d2dbf 100644
--- a/contrib/t1ha/t1ha_bits.h
+++ b/contrib/t1ha/t1ha_bits.h
@@ -120,10 +120,6 @@
 #define __has_extension(x) (0)
 #endif
 
-#if __has_feature(address_sanitizer)
-#define __SANITIZE_ADDRESS__ 1
-#endif
-
 #if __GNUC_PREREQ(4, 4) || defined(__clang__)
 
 #if defined(__ia32__) || defined(__e2k__)


More information about the Commits mailing list