From nobody Mon Nov 01 14:32:54 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1C491182D5A0; Mon, 1 Nov 2021 14:32:55 +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 4Hjb9M06nDz3sD7; Mon, 1 Nov 2021 14:32:54 +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 CA4C613419; Mon, 1 Nov 2021 14:32:54 +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 1A1EWsNb021220; Mon, 1 Nov 2021 14:32:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A1EWsuk021219; Mon, 1 Nov 2021 14:32:54 GMT (envelope-from git) Date: Mon, 1 Nov 2021 14:32:54 GMT Message-Id: <202111011432.1A1EWsuk021219@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 8b3c771fc62a - stable/13 - Add a KASAN option to the kernel build List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 8b3c771fc62af7d0d9e5b36e835892924e44b144 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=8b3c771fc62af7d0d9e5b36e835892924e44b144 commit 8b3c771fc62af7d0d9e5b36e835892924e44b144 Author: Mark Johnston AuthorDate: 2021-04-13 20:29:47 +0000 Commit: Mark Johnston CommitDate: 2021-11-01 13:56:14 +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 Sponsored by: The FreeBSD Foundation (cherry picked from commit 01028c736cbcdba079967c787bee1551fc8439aa) --- 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 bb52d1b9fbc4..8cab54d0763a 100644 --- a/sys/conf/kern.pre.mk +++ b/sys/conf/kern.pre.mk @@ -107,6 +107,16 @@ PROF= -pg .endif DEFINED_PROF= ${PROF} +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 121a23ed876c..774850158221 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