[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAeHK+z-cWhLGv4qV20_4Ddacw9wSJTsAWoodEJ_L0rohR5p9g@mail.gmail.com>
Date: Wed, 9 Dec 2020 14:51:43 +0100
From: Andrey Konovalov <andreyknvl@...gle.com>
To: Dmitry Vyukov <dvyukov@...gle.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
kasan-dev <kasan-dev@...glegroups.com>,
LKML <linux-kernel@...r.kernel.org>,
Linux Memory Management List <linux-mm@...ck.org>,
Stephen Rothwell <sfr@...b.auug.org.au>,
Marco Elver <elver@...gle.com>
Subject: Re: [PATCH] kcov: don't instrument with UBSAN
On Wed, Dec 9, 2020 at 11:01 AM Dmitry Vyukov <dvyukov@...gle.com> wrote:
>
> Both KCOV and UBSAN use compiler instrumentation. If UBSAN detects a bug
> in KCOV, it may cause infinite recursion via printk and other common
> functions. We already don't instrument KCOV with KASAN/KCSAN for this
> reason, don't instrument it with UBSAN as well.
>
> As a side effect this also resolves the following gcc warning:
>
> conflicting types for built-in function '__sanitizer_cov_trace_switch';
> expected 'void(long unsigned int, void *)' [-Wbuiltin-declaration-mismatch]
>
> It's only reported when kcov.c is compiled with any of the sanitizers
> enabled. Size of the arguments is correct, it's just that gcc uses 'long'
> on 64-bit arches and 'long long' on 32-bit arches, while kernel type is
> always 'long long'.
>
> Reported-by: Stephen Rothwell <sfr@...b.auug.org.au>
> Suggested-by: Marco Elver <elver@...gle.com>
> Signed-off-by: Dmitry Vyukov <dvyukov@...gle.com>
> ---
> kernel/Makefile | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/kernel/Makefile b/kernel/Makefile
> index aac15aeb9d69..efa42857532b 100644
> --- a/kernel/Makefile
> +++ b/kernel/Makefile
> @@ -34,8 +34,11 @@ KCOV_INSTRUMENT_extable.o := n
> KCOV_INSTRUMENT_stacktrace.o := n
> # Don't self-instrument.
> KCOV_INSTRUMENT_kcov.o := n
> +# If sanitizers detect any issues in kcov, it may lead to recursion
> +# via printk, etc.
> KASAN_SANITIZE_kcov.o := n
> KCSAN_SANITIZE_kcov.o := n
> +UBSAN_SANITIZE_kcov.o := n
> CFLAGS_kcov.o := $(call cc-option, -fno-conserve-stack) -fno-stack-protector
>
> obj-y += sched/
> --
> 2.29.2.576.ga3fc446d84-goog
>
Reviewed-by: Andrey Konovalov <andreyknvl@...gle.com>
Powered by blists - more mailing lists