From owner-dev-commits-src-all@freebsd.org Tue Sep 14 18:32:45 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B11DA66E684; Tue, 14 Sep 2021 18:32:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4H8BmF4Ndyz4QyT; Tue, 14 Sep 2021 18:32:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7065F1F5FF; Tue, 14 Sep 2021 18:32:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 18EIWjcU070333; Tue, 14 Sep 2021 18:32:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 18EIWj5I070332; Tue, 14 Sep 2021 18:32:45 GMT (envelope-from git) Date: Tue, 14 Sep 2021 18:32:45 GMT Message-Id: <202109141832.18EIWj5I070332@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: cf4670fe0b10 - main - kcov: Integrate with KMSAN MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cf4670fe0b1049863ed3150a6ffb0b80dad151b2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Sep 2021 18:32:45 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=cf4670fe0b1049863ed3150a6ffb0b80dad151b2 commit cf4670fe0b1049863ed3150a6ffb0b80dad151b2 Author: Mark Johnston AuthorDate: 2021-09-14 18:29:27 +0000 Commit: Mark Johnston 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