lkml.org 
[lkml]   [2020]   [Feb]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 1/2] sanitize: Add SANITIZE_xx.o and SANITIZE to disable all sanitizers for specific files
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

\
 
 \ /
  Last update: 2020-02-16 05:47    [W:0.043 / U:2.292 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site