]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Enforce disabling internal memory allocator for AddressSanitizer
authorOndřej Surý <ondrej@sury.org>
Thu, 25 Feb 2021 12:07:49 +0000 (13:07 +0100)
committerEvan Hunt <each@isc.org>
Fri, 26 Feb 2021 18:13:56 +0000 (10:13 -0800)
Disable the internal memory allocator when AddressSanitizer is in use.
The basic blocks in the internal memory allocator prevents
AddressSanitizer from properly tracking the allocations and
deallocations, so we need to ensure it has been disabled for any build
that has AddressSanitizer enabled.

lib/isc/include/isc/mem.h
lib/isc/mem.c

index 97b249cc6539b6447ece9566d40e03a6d8e2f08b..f155fb0a2be7aab2f75f519a869f9b9ffc762920 100644 (file)
@@ -21,6 +21,7 @@
 #include <isc/mutex.h>
 #include <isc/platform.h>
 #include <isc/types.h>
+#include <isc/util.h>
 
 ISC_LANG_BEGINDECLS
 
@@ -115,7 +116,7 @@ LIBISC_EXTERNAL_DATA extern unsigned int isc_mem_defaultflags;
  * by carefully separating memory contexts.
  */
 
-#ifndef ISC_MEM_USE_INTERNAL_MALLOC
+#if !defined(ISC_MEM_USE_INTERNAL_MALLOC) && !__SANITIZE_ADDRESS__
 #define ISC_MEM_USE_INTERNAL_MALLOC 1
 #endif /* ifndef ISC_MEM_USE_INTERNAL_MALLOC */
 
index ba634662effcf40a84e4b87d7713b4087407397a..fc4640a24752b415bbd975529ec68f29f9171df3 100644 (file)
@@ -770,6 +770,9 @@ isc__mem_shutdown(void) {
 static void
 mem_create(isc_mem_t **ctxp, unsigned int flags) {
        REQUIRE(ctxp != NULL && *ctxp == NULL);
+#if __SANITIZE_ADDRESS__
+       REQUIRE((flags & ISC_MEMFLAG_INTERNAL) == 0);
+#endif
 
        isc__mem_t *ctx;