From: Changbin Du <changbin.du@gmail.com>
To: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Alexander Potapenko <glider@google.com>,
Jonathan Corbet <corbet@lwn.net>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
hpa@zytor.com, x86@kernel.org, Andy Lutomirski <luto@kernel.org>,
Masahiro Yamada <masahiroy@kernel.org>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kbuild@vger.kernel.org, Changbin Du <changbin.du@gmail.com>
Subject: [PATCH 1/2] sanitize: Add SANITIZE_xx.o and SANITIZE to disable all sanitizers for specific files
Date: Sat, 1 Feb 2020 14:24:58 +0800 [thread overview]
Message-ID: <20200201062459.7150-2-changbin.du@gmail.com> (raw)
In-Reply-To: <20200201062459.7150-1-changbin.du@gmail.com>
This patch add two new flags to disable all sanitizers (UBSAN and KASAN):
o SANITIZE_xx.o - disable all sanitizers for a single file.
o SANITIZE - disable all sanitizers for current directory.
Signed-off-by: Changbin Du <changbin.du@gmail.com>
---
Documentation/dev-tools/kasan.rst | 12 ++++++++++++
scripts/Makefile.lib | 4 ++--
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst
index e4d66e7c50de..f59fc5fb2cd8 100644
--- a/Documentation/dev-tools/kasan.rst
+++ b/Documentation/dev-tools/kasan.rst
@@ -55,6 +55,18 @@ similar to the following to the respective kernel Makefile:
KASAN_SANITIZE := n
+Similarly, to disable all sanitizers (KASAN, UBSAN) for specific files or
+directories, add a line similar to the following to the respective kernel
+Makefile:
+
+- For a single file (e.g. main.o)::
+
+ SANITIZE_main.o := n
+
+- For all files in one directory::
+
+ SANITIZE := n
+
Error reports
~~~~~~~~~~~~~
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 3fa32f83b2d7..9b7d784e3252 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -122,13 +122,13 @@ endif
#
ifeq ($(CONFIG_KASAN),y)
_c_flags += $(if $(patsubst n%,, \
- $(KASAN_SANITIZE_$(basetarget).o)$(KASAN_SANITIZE)y), \
+ $(SANITIZE_$(basetarget).o)$(SANITIZE)$(KASAN_SANITIZE_$(basetarget).o)$(KASAN_SANITIZE)y), \
$(CFLAGS_KASAN), $(CFLAGS_KASAN_NOSANITIZE))
endif
ifeq ($(CONFIG_UBSAN),y)
_c_flags += $(if $(patsubst n%,, \
- $(UBSAN_SANITIZE_$(basetarget).o)$(UBSAN_SANITIZE)$(CONFIG_UBSAN_SANITIZE_ALL)), \
+ $(SANITIZE_$(basetarget).o)$(SANITIZE)$(UBSAN_SANITIZE_$(basetarget).o)$(UBSAN_SANITIZE)$(CONFIG_UBSAN_SANITIZE_ALL)), \
$(CFLAGS_UBSAN))
endif
--
2.24.0
next prev parent reply other threads:[~2020-02-01 6:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-01 6:24 [PATCH 0/2] Add SANITIZE_xx.o & SANITIZE and apply them to x86 Changbin Du
2020-02-01 6:24 ` Changbin Du [this message]
2020-02-16 4:46 ` [PATCH 1/2] sanitize: Add SANITIZE_xx.o and SANITIZE to disable all sanitizers for specific files Masahiro Yamada
2020-02-01 6:24 ` [PATCH 2/2] x86: Disable both KASAN and UBSAN for some booting code Changbin Du
2020-02-12 12:28 ` [PATCH 0/2] Add SANITIZE_xx.o & SANITIZE and apply them to x86 Changbin Du
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200201062459.7150-2-changbin.du@gmail.com \
--to=changbin.du@gmail.com \
--cc=aryabinin@virtuozzo.com \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=glider@google.com \
--cc=hpa@zytor.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=masahiroy@kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).