Date: Tue, 14 Sep 2021 18:32:45 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: cf4670fe0b10 - main - kcov: Integrate with KMSAN Message-ID: <202109141832.18EIWj5I070332@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=cf4670fe0b1049863ed3150a6ffb0b80dad151b2 commit cf4670fe0b1049863ed3150a6ffb0b80dad151b2 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2021-09-14 18:29:27 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2021-09-14 18:29:27 +0000 kcov: Integrate with KMSAN - kern_kcov.c needs to be compiled with -fsanitize=kernel-memory when KMSAN is configured since it calls into various other subsystems. - Disable address and memory sanitizers in kcov(4)'s coverage sanitizer callbacks, as they do not provide useful checking. Moreover, with KMSAN we may otherwise get false positives since the caller (coverage sanitizer runtime) is not instrumented. - Disable KASAN and KMSAN interceptors in subr_coverage.c, as they do not provide any benefit but do introduce overhead when fuzzing. Sponsored by: The FreeBSD Foundation --- sys/conf/files | 2 +- sys/kern/kern_kcov.c | 7 ++++--- sys/kern/subr_coverage.c | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sys/conf/files b/sys/conf/files index a5690ec1df75..eb0c489b7833 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -3826,7 +3826,7 @@ kern/kern_idle.c standard kern/kern_intr.c standard kern/kern_jail.c standard kern/kern_kcov.c optional kcov \ - compile-with "${NORMAL_C:N-fsanitize*}" + compile-with "${NORMAL_C:N-fsanitize*} ${NORMAL_C:M-fsanitize=kernel-memory}" kern/kern_khelp.c standard kern/kern_kthread.c standard kern/kern_ktr.c optional ktr diff --git a/sys/kern/kern_kcov.c b/sys/kern/kern_kcov.c index 23e0da4cdb79..7a11f800c7ce 100644 --- a/sys/kern/kern_kcov.c +++ b/sys/kern/kern_kcov.c @@ -35,7 +35,8 @@ * $FreeBSD$ */ -#ifdef KCSAN +/* Interceptors are required for KMSAN. */ +#if defined(KASAN) || defined(KCSAN) #define SAN_RUNTIME #endif @@ -191,7 +192,7 @@ get_kinfo(struct thread *td) return (info); } -static void +static void __nosanitizeaddress __nosanitizememory trace_pc(uintptr_t ret) { struct thread *td; @@ -223,7 +224,7 @@ trace_pc(uintptr_t ret) buf[0] = index + 1; } -static bool +static bool __nosanitizeaddress __nosanitizememory trace_cmp(uint64_t type, uint64_t arg1, uint64_t arg2, uint64_t ret) { struct thread *td; diff --git a/sys/kern/subr_coverage.c b/sys/kern/subr_coverage.c index 9a719bcaecad..28467af6a8d0 100644 --- a/sys/kern/subr_coverage.c +++ b/sys/kern/subr_coverage.c @@ -35,7 +35,7 @@ * $FreeBSD$ */ -#ifdef KCSAN +#ifdef SAN_NEEDS_INTERCEPTORS #define SAN_RUNTIME #endif
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202109141832.18EIWj5I070332>