From: Masahiro Yamada <masahiroy@kernel.org>
To: Changbin Du <changbin.du@gmail.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>,
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>,
"H. Peter Anvin" <hpa@zytor.com>, X86 ML <x86@kernel.org>,
Andy Lutomirski <luto@kernel.org>,
"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>
Subject: Re: [PATCH 1/2] sanitize: Add SANITIZE_xx.o and SANITIZE to disable all sanitizers for specific files
Date: Sun, 16 Feb 2020 13:46:13 +0900 [thread overview]
Message-ID: <CAK7LNATvWpic8r6J6eUnKtLYMnF3bhKA17x9DNYwSK66me9LtA@mail.gmail.com> (raw)
In-Reply-To: <20200201062459.7150-2-changbin.du@gmail.com>
Hi Changbin,
On Sat, Feb 1, 2020 at 3:25 PM Changbin Du <changbin.du@gmail.com> wrote:
>
> 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), \
I think this would be very unlikely to happen, but
if both SANITIZE and KASAN_SANITIZE existed,
KASAN_SANITIZE should take precedence over SANITIZE, maybe?
Perhaps, like this?
$(KASAN_SANITIZE_$(basetarget).o)$(SANITIZE_$(basetarget).o)$(KASAN_SANITIZE)$(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
>
--
Best Regards
Masahiro Yamada
next prev parent reply other threads:[~2020-02-16 4:46 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 ` [PATCH 1/2] sanitize: Add SANITIZE_xx.o and SANITIZE to disable all sanitizers for specific files Changbin Du
2020-02-16 4:46 ` Masahiro Yamada [this message]
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=CAK7LNATvWpic8r6J6eUnKtLYMnF3bhKA17x9DNYwSK66me9LtA@mail.gmail.com \
--to=masahiroy@kernel.org \
--cc=aryabinin@virtuozzo.com \
--cc=bp@alien8.de \
--cc=changbin.du@gmail.com \
--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=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).