Re: [PATCH v3 2/5] kasan/Makefile: Support LLVM style asan parameters.

From: Andrey Ryabinin
Date: Mon Dec 04 2017 - 11:11:45 EST



On 12/02/2017 12:36 AM, Paul Lawrence wrote:
>

Missing:
From: Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx>

Please, don't change authorship of the patches.

> LLVM doesn't understand GCC-style paramters ("--param asan-foo=bar"),
> thus we currently we don't use inline/globals/stack instrumentation
> when building the kernel with clang.
>
> Add support for LLVM-style parameters ("-mllvm -asan-foo=bar") to
> enable all KASAN features.
>
> Signed-off-by: Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx>
> ---
> scripts/Makefile.kasan | 29 ++++++++++++++++++-----------
> 1 file changed, 18 insertions(+), 11 deletions(-)
>
> diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan
> index 1ce7115aa499..7c00be9216f4 100644
> --- a/scripts/Makefile.kasan
> +++ b/scripts/Makefile.kasan
> @@ -10,10 +10,7 @@ KASAN_SHADOW_OFFSET ?= $(CONFIG_KASAN_SHADOW_OFFSET)
>



> + # -fasan-shadow-offset fails without -fsanitize
> + CFLAGS_KASAN_SHADOW := $(call cc-option, -fsanitize=kernel-address \
> + -fasan-shadow-offset=$(KASAN_SHADOW_OFFSET), \
> + $(call cc-option, -fsanitize=kernel-address \
> + -mllvm -asan-mapping-offset=$(KASAN_SHADOW_OFFSET)))
> +
> + ifeq ("$(CFLAGS_KASAN_SHADOW)"," ")

This not how it was in my original patch. Why you changed this?
Condition is always false now, so it breaks kasan with 4.9.x gcc.

> + CFLAGS_KASAN := $(CFLAGS_KASAN_MINIMAL)
> + else
> + # Now add all the compiler specific options that are valid standalone
> + CFLAGS_KASAN := $(CFLAGS_KASAN_SHADOW) \
> + $(call cc-param,asan-globals=1) \