git: 41d1dc7005f0 - releng/14.0 - kmsan: Set -fno-sanitize-memory-param-retval for now

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Sun, 22 Oct 2023 15:04:47 UTC
The branch releng/14.0 has been updated by markj:

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

commit 41d1dc7005f010074c1e6f7fc8adf44dcbd473cf
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-10-16 19:45:42 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-10-22 15:01:26 +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.
    
    Approved by:    re (gjb)
    MFC after:      3 days
    Sponsored by:   Klara, Inc.
    Sponsored by:   Juniper Networks, Inc.
    
    (cherry picked from commit b6c653c9746342b373af01979319b3cb123b2872)
    (cherry picked from commit c89523d1c4be8f3408fb591261f3093b65dbb675)
---
 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 8d38b9cc8a2e..b9763d167812 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -3871,7 +3871,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