From e1ce3a3d42ecc4cfcddc7b31f20956f87865b860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 19 Dec 2018 09:54:37 +0100 Subject: [PATCH 1/2] Define __ADDRESS_SANITIZER__ if compiling under clang's AddressSanitizer --- lib/isc/include/isc/util.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/isc/include/isc/util.h b/lib/isc/include/isc/util.h index c4f6da8ef1..06530d1cdc 100644 --- a/lib/isc/include/isc/util.h +++ b/lib/isc/include/isc/util.h @@ -206,6 +206,11 @@ #define __has_feature(x) 0 #endif +/* GCC defines __ADDRESS_SANITIZER__, so reuse the macro for clang */ +#if __has_feature(address_sanitizer) +#define __ADDRESS_SANITIZER__ +#endif + #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR >= 6) #define STATIC_ASSERT(cond, msg) _Static_assert(cond, msg) #elif __has_feature(c_static_assert) From cad6b39cabb78d0c0c2ae7201255948ed24766c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 19 Dec 2018 09:59:40 +0100 Subject: [PATCH 2/2] Disable RTLD_DEEPBIND when compiled under AddressSanitizer --- bin/named/unix/dlz_dlopen_driver.c | 2 +- lib/dns/dyndb.c | 2 +- lib/ns/hooks.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/named/unix/dlz_dlopen_driver.c b/bin/named/unix/dlz_dlopen_driver.c index 8f540edb55..016b390862 100644 --- a/bin/named/unix/dlz_dlopen_driver.c +++ b/bin/named/unix/dlz_dlopen_driver.c @@ -257,7 +257,7 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[], /* Open the library */ dlopen_flags = RTLD_NOW|RTLD_GLOBAL; -#ifdef RTLD_DEEPBIND +#if defined(RTLD_DEEPBIND) && !__ADDRESS_SANITIZER__ /* * If RTLD_DEEPBIND is available then use it. This can avoid * issues with a module using a different version of a system diff --git a/lib/dns/dyndb.c b/lib/dns/dyndb.c index 932244a8db..47cb3374a3 100644 --- a/lib/dns/dyndb.c +++ b/lib/dns/dyndb.c @@ -133,7 +133,7 @@ load_library(isc_mem_t *mctx, const char *filename, const char *instname, instname, filename); flags = RTLD_NOW|RTLD_LOCAL; -#ifdef RTLD_DEEPBIND +#if defined(RTLD_DEEPBIND) && !__ADDRESS_SANITIZER__ flags |= RTLD_DEEPBIND; #endif diff --git a/lib/ns/hooks.c b/lib/ns/hooks.c index d79c29f355..c5212428f1 100644 --- a/lib/ns/hooks.c +++ b/lib/ns/hooks.c @@ -109,7 +109,7 @@ load_plugin(isc_mem_t *mctx, const char *modpath, ns_plugin_t **pluginp) { REQUIRE(pluginp != NULL && *pluginp == NULL); flags = RTLD_LAZY | RTLD_LOCAL; -#ifdef RTLD_DEEPBIND +#if defined(RTLD_DEEPBIND) && !__ADDRESS_SANITIZER__ flags |= RTLD_DEEPBIND; #endif