git: c89523d1c4be - stable/14 - kmsan: Set -fno-sanitize-memory-param-retval for now

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Fri, 20 Oct 2023 16:02:27 UTC
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=c89523d1c4be8f3408fb591261f3093b65dbb675

commit c89523d1c4be8f3408fb591261f3093b65dbb675
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-10-16 19:45:42 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-10-20 16:02:05 +0000

    kmsan: Set -fno-sanitize-memory-param-retval for now
    
    As of LLVM 16, -fsanitize-memory-param-retval is the default.  It yields
    significantly smaller code, but the KMSAN runtime interceptors need to
    be updated to stop checking shadow state of parameters.  Apply a minimal
    workaround for now.
    
    MFC after:      3 days
    Sponsored by:   Klara, Inc.
    Sponsored by:   Juniper Networks, Inc.
    
    (cherry picked from commit b6c653c9746342b373af01979319b3cb123b2872)
---
 sys/conf/files       | 2 +-
 sys/conf/kern.pre.mk | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/sys/conf/files b/sys/conf/files
index f2a31eb24f25..62eb54a0b765 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -3872,7 +3872,7 @@ kern/subr_mchain.c		optional libmchain
 kern/subr_memdesc.c		standard
 kern/subr_module.c		standard
 kern/subr_msan.c		optional kmsan \
-	compile-with "${NORMAL_C:N-fsanitize*:N-fstack-protector*}"
+	compile-with "${NORMAL_C:N-fsanitize*:N-fno-sanitize*:N-fstack-protector*}"
 kern/subr_msgbuf.c		standard
 kern/subr_param.c		standard
 kern/subr_pcpu.c		standard
diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk
index 4d37cd4156f0..158175eb6899 100644
--- a/sys/conf/kern.pre.mk
+++ b/sys/conf/kern.pre.mk
@@ -122,8 +122,11 @@ SAN_CFLAGS+=	-DSAN_NEEDS_INTERCEPTORS -DSAN_INTERCEPTOR_PREFIX=kcsan \
 
 KMSAN_ENABLED!= grep KMSAN opt_global.h || true ; echo
 .if !empty(KMSAN_ENABLED)
+# Disable -fno-sanitize-memory-param-retval until interceptors have been
+# updated to work properly with it.
 SAN_CFLAGS+=	-DSAN_NEEDS_INTERCEPTORS -DSAN_INTERCEPTOR_PREFIX=kmsan \
-		-fsanitize=kernel-memory
+		-fsanitize=kernel-memory \
+		-fno-sanitize-memory-param-retval
 .endif
 
 KUBSAN_ENABLED!=	grep KUBSAN opt_global.h || true ; echo