Commit a14c45bdb0 for bind
commit a14c45bdb0d43eb04f0bd5e633d8ba84aac2960b
Author: Michal Nowak <mnowak@isc.org>
Date: Tue Aug 11 10:40:31 2026 +0000
Enable unaligned pointer scanning in LeakSanitizer
dns_db_detach() only queues the zone database for destruction with
call_rcu(), so the dns_master_load fuzzer can exit while the database
is still pending. The database is reachable then, but QP's 12-byte
nodes can hold pointers that LeakSanitizer's aligned scan misses, so
the zone nodes are reported as leaked from the very first seed.
Make use_unaligned=1 the default LSan option. This applies to every
ASan/LSan build, not only to the fuzzers, as the false positive can
hit anything that exits with QP memory awaiting reclamation; the
price is a slower end-of-process scan and slightly less sensitive
leak detection.
Assisted-by: Codex:gpt-6
diff --git a/meson.build b/meson.build
index 538721144f..f1c9a72f0f 100644
--- a/meson.build
+++ b/meson.build
@@ -281,6 +281,7 @@ add_project_arguments(sys_defines, language: 'c')
### Sanitizer
asan_options = 'abort_on_error=1:disable_coredump=0:unmap_shadow_on_exit=1:detect_odr_violation=0'
+lsan_options = 'use_unaligned=1'
tsan_options = 'disable_coredump=0:second_deadlock_stack=1:atexit_sleep_ms=1000:history_size=7:log_exe_name=true:log_path=tsan'
ubsan_options = 'halt_on_error=1:abort_on_error=1:disable_coredump=0'
@@ -292,6 +293,7 @@ config_sanitize.set10('BIND_LSAN_ENABLED', sanitizer.contains('leak'))
config_sanitize.set10('BIND_TSAN_ENABLED', sanitizer.contains('thread'))
config_sanitize.set10('BIND_UBSAN_ENABLED', sanitizer.contains('undefined'))
config_sanitize.set('BIND_ASAN_OPTIONS', asan_options)
+config_sanitize.set('BIND_LSAN_OPTIONS', lsan_options)
config_sanitize.set('BIND_TSAN_OPTIONS', tsan_options)
config_sanitize.set('BIND_UBSAN_OPTIONS', ubsan_options)
diff --git a/sanitize.c.in b/sanitize.c.in
index 8b5a9fcefe..932824896b 100644
--- a/sanitize.c.in
+++ b/sanitize.c.in
@@ -26,6 +26,17 @@
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+/*
+ * QP trie nodes contain pointers that are not always naturally aligned.
+ * Always provide these defaults: OSS-Fuzz can enable sanitizers through
+ * compiler flags without setting Meson's b_sanitize option.
+ */
+__attribute__((no_sanitize("address", "leak", "thread", "undefined")))
+const char *
+__lsan_default_options(void) {
+ return "@BIND_LSAN_OPTIONS@";
+}
+
#if @BIND_ASAN_ENABLED@
__attribute__((no_sanitize("address", "leak", "thread", "undefined")))
const char *