2020-06-05 08:31:44

by Marco Elver

[permalink] [raw]
Subject: [PATCH -tip v3 2/2] kcov: Unconditionally add -fno-stack-protector to compiler options

Unconditionally add -fno-stack-protector to KCOV's compiler options, as
all supported compilers support the option. This saves a compiler
invocation to determine if the option is supported.

Because Clang does not support -fno-conserve-stack, and
-fno-stack-protector was wrapped in the same cc-option, we were missing
-fno-stack-protector with Clang. Unconditionally adding this option
fixes this for Clang.

Suggested-by: Nick Desaulniers <[email protected]>
Signed-off-by: Marco Elver <[email protected]>
---
v3:
* Do not wrap -fno-stack-protector in cc-option, since all KCOV-supported
compilers support the option as pointed out by Nick.
---
kernel/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/Makefile b/kernel/Makefile
index ce8716a04d0e..71971eb39ee7 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -35,7 +35,7 @@ KCOV_INSTRUMENT_stacktrace.o := n
KCOV_INSTRUMENT_kcov.o := n
KASAN_SANITIZE_kcov.o := n
KCSAN_SANITIZE_kcov.o := n
-CFLAGS_kcov.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector)
+CFLAGS_kcov.o := $(call cc-option, -fno-conserve-stack) -fno-stack-protector

# cond_syscall is currently not LTO compatible
CFLAGS_sys_ni.o = $(DISABLE_LTO)
--
2.27.0.278.ge193c7cf3a9-goog


2020-06-05 16:53:06

by Nick Desaulniers

[permalink] [raw]
Subject: Re: [PATCH -tip v3 2/2] kcov: Unconditionally add -fno-stack-protector to compiler options

On Fri, Jun 5, 2020 at 1:28 AM Marco Elver <[email protected]> wrote:
>
> Unconditionally add -fno-stack-protector to KCOV's compiler options, as
> all supported compilers support the option. This saves a compiler
> invocation to determine if the option is supported.
>
> Because Clang does not support -fno-conserve-stack, and
> -fno-stack-protector was wrapped in the same cc-option, we were missing
> -fno-stack-protector with Clang. Unconditionally adding this option
> fixes this for Clang.
>
> Suggested-by: Nick Desaulniers <[email protected]>
> Signed-off-by: Marco Elver <[email protected]>

Thanks for considering the suggestion.
Reviewed-by: Nick Desaulniers <[email protected]>

> ---
> v3:
> * Do not wrap -fno-stack-protector in cc-option, since all KCOV-supported
> compilers support the option as pointed out by Nick.
> ---
> kernel/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/Makefile b/kernel/Makefile
> index ce8716a04d0e..71971eb39ee7 100644
> --- a/kernel/Makefile
> +++ b/kernel/Makefile
> @@ -35,7 +35,7 @@ KCOV_INSTRUMENT_stacktrace.o := n
> KCOV_INSTRUMENT_kcov.o := n
> KASAN_SANITIZE_kcov.o := n
> KCSAN_SANITIZE_kcov.o := n
> -CFLAGS_kcov.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector)
> +CFLAGS_kcov.o := $(call cc-option, -fno-conserve-stack) -fno-stack-protector
>
> # cond_syscall is currently not LTO compatible
> CFLAGS_sys_ni.o = $(DISABLE_LTO)
> --
> 2.27.0.278.ge193c7cf3a9-goog
>


--
Thanks,
~Nick Desaulniers