From e30ab5fa4f99091482adf9c9904945c439c1e0aa Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Thu, 28 May 2026 12:02:48 -0400 Subject: [PATCH] FreeBSD: Make it possible to build openzfs.ko with sanitizers Add make options which let one respectively compile the kernel modules with the address sanitizer, memory sanitizer, and undefined behaviour sanitizer enabled. This makes it much easier to run the ZTS with those sanitizers enabled. Reviewed-by: Brian Behlendorf Reviewed-by: Chris Longros Signed-off-by: Mark Johnston Closes #18596 --- module/Makefile.bsd | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/module/Makefile.bsd b/module/Makefile.bsd index 96c3f3b2418..a0ddbeb9ae6 100644 --- a/module/Makefile.bsd +++ b/module/Makefile.bsd @@ -65,6 +65,12 @@ CFLAGS+= -DZFS_DEBUG -g CFLAGS += -DNDEBUG .endif +.for _SAN in KASAN KMSAN KUBSAN +.if defined(WITH_${_SAN}) && ${WITH_${_SAN}} == "true" +KERN_OPTS_EXTRA+= ${_SAN} +.endif +.endfor + .if defined(WITH_GCOV) && ${WITH_GCOV} == "true" CFLAGS+= -fprofile-arcs -ftest-coverage .endif