git: 01028c736cbc - main - Add a KASAN option to the kernel build
Mark Johnston
markj at FreeBSD.org
Tue Apr 13 21:42:31 UTC 2021
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=01028c736cbcdba079967c787bee1551fc8439aa
commit 01028c736cbcdba079967c787bee1551fc8439aa
Author: Mark Johnston <markj at FreeBSD.org>
AuthorDate: 2021-04-13 20:29:47 +0000
Commit: Mark Johnston <markj at FreeBSD.org>
CommitDate: 2021-04-13 21:42:20 +0000
Add a KASAN option to the kernel build
LLVM support for enabling KASAN has not yet landed so the option is not
yet usable, but hopefully this will change soon.
Reviewed by: imp, andrew
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29454
---
sys/conf/kern.pre.mk | 10 ++++++++++
sys/conf/options | 1 +
2 files changed, 11 insertions(+)
diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk
index bb27969d6eca..539605f60ca0 100644
--- a/sys/conf/kern.pre.mk
+++ b/sys/conf/kern.pre.mk
@@ -92,6 +92,16 @@ CFLAGS+= -fno-common
# XXX LOCORE means "don't declare C stuff" not "for locore.s".
ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} ${ASM_CFLAGS.${.IMPSRC:T}}
+KASAN_ENABLED!= grep KASAN opt_global.h || true ; echo
+.if !empty(KASAN_ENABLED)
+SAN_CFLAGS+= -fsanitize=kernel-address \
+ -mllvm -asan-stack=true \
+ -mllvm -asan-instrument-dynamic-allocas=true \
+ -mllvm -asan-globals=true \
+ -mllvm -asan-use-after-scope=true \
+ -mllvm -asan-instrumentation-with-call-threshold=0
+.endif
+
KCSAN_ENABLED!= grep KCSAN opt_global.h || true ; echo
.if !empty(KCSAN_ENABLED)
SAN_CFLAGS+= -fsanitize=thread
diff --git a/sys/conf/options b/sys/conf/options
index b6956193d841..882460fbf35b 100644
--- a/sys/conf/options
+++ b/sys/conf/options
@@ -229,6 +229,7 @@ ZSTDIO opt_zstdio.h
# Sanitizers
COVERAGE opt_global.h
+KASAN opt_global.h
KCOV
KCSAN opt_global.h
KUBSAN opt_global.h
More information about the dev-commits-src-main
mailing list