From owner-dev-commits-src-all@freebsd.org Tue Apr 13 21:42:31 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 190A65ED1B2; Tue, 13 Apr 2021 21:42:31 +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 4FKfGH0G7wz3PtS; Tue, 13 Apr 2021 21:42:31 +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 F08C01264C; Tue, 13 Apr 2021 21:42:30 +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 13DLgUkL099077; Tue, 13 Apr 2021 21:42:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13DLgUcO099076; Tue, 13 Apr 2021 21:42:30 GMT (envelope-from git) Date: Tue, 13 Apr 2021 21:42:30 GMT Message-Id: <202104132142.13DLgUcO099076@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: 01028c736cbc - main - Add a KASAN option to the kernel build 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: 01028c736cbcdba079967c787bee1551fc8439aa 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, 13 Apr 2021 21:42:31 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=01028c736cbcdba079967c787bee1551fc8439aa commit 01028c736cbcdba079967c787bee1551fc8439aa Author: Mark Johnston AuthorDate: 2021-04-13 20:29:47 +0000 Commit: Mark Johnston CommitDate: 2021-04-13 21:42:20 +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 MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29454 --- 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 bb27969d6eca..539605f60ca0 100644 --- a/sys/conf/kern.pre.mk +++ b/sys/conf/kern.pre.mk @@ -92,6 +92,16 @@ CFLAGS+= -fno-common # XXX LOCORE means "don't declare C stuff" not "for locore.s". ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} ${ASM_CFLAGS.${.IMPSRC:T}} +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 b6956193d841..882460fbf35b 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