[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdmMAc5zhLQMr-6WvrJJ4vbzwMpav36Y6V_DBBVjf4i72g@mail.gmail.com>
Date: Mon, 14 Sep 2020 14:17:39 -0700
From: Nick Desaulniers <ndesaulniers@...gle.com>
To: George-Aurelian Popescu <georgepope@...gle.com>
Cc: Marc Zyngier <maz@...nel.org>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>,
Masahiro Yamada <masahiroy@...nel.org>,
Michal Marek <michal.lkml@...kovi.net>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
kvmarm@...ts.cs.columbia.edu, LKML <linux-kernel@...r.kernel.org>,
Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>,
clang-built-linux <clang-built-linux@...glegroups.com>,
James Morse <james.morse@....com>,
Julien Thierry <julien.thierry.kdev@...il.com>,
Suzuki K Poulose <suzuki.poulose@....com>,
Nathan Chancellor <natechancellor@...il.com>,
David Brazdil <dbrazdil@...gle.com>,
Mark Brown <broonie@...nel.org>,
Fangrui Song <maskray@...gle.com>, ascull@...gle.com,
Kees Cook <keescook@...omium.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Dmitry Vyukov <dvyukov@...gle.com>,
Marco Elver <elver@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>,
Arnd Bergmann <arnd@...db.de>,
kernel-dynamic-tools <kernel-dynamic-tools@...gle.com>
Subject: Re: [PATCH 06/14] Fix CFLAGS for UBSAN_BOUNDS on Clang
+ kernel-dynamic-tools to help review.
On Mon, Sep 14, 2020 at 10:28 AM George-Aurelian Popescu
<georgepope@...gle.com> wrote:
>
> From: George Popescu <georgepope@...gle.com>
>
> When the kernel is compiled with Clang, UBSAN_BOUNDS inserts a brk after
> the handler call, preventing it from printing any information processed
> inside the buffer.
> For Clang -fsanitize=bounds expands to -fsanitize=array-bounds and
> -fsanitize=local-bounds, and the latter adds a brk after the handler
> call
>
> Signed-off-by: George Popescu <georgepope@...gle.com>
> ---
> scripts/Makefile.ubsan | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/Makefile.ubsan b/scripts/Makefile.ubsan
> index 27348029b2b8..3d15ac346c97 100644
> --- a/scripts/Makefile.ubsan
> +++ b/scripts/Makefile.ubsan
> @@ -4,7 +4,14 @@ ifdef CONFIG_UBSAN_ALIGNMENT
> endif
>
> ifdef CONFIG_UBSAN_BOUNDS
> - CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds)
> + # For Clang -fsanitize=bounds translates to -fsanitize=array-bounds and
> + # -fsanitize=local-bounds; the latter adds a brk right after the
> + # handler is called.
> + ifdef CONFIG_CC_IS_CLANG
> + CFLAGS_UBSAN += $(call cc-option, -fsanitize=array-bounds)
You can remove the cc-option check above; Clang has supported this
option for many releases. (One less compiler invocation at build
time, FWIW).
You cannot remove the below cc-option; GCC only implemented that
sanitizer in the 5.0+ releases; the kernel still support GCC 4.9.
> + else
> + CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds)
> + endif
> endif
>
> ifdef CONFIG_UBSAN_MISC
> --
> 2.28.0.618.gf4bc123cb7-goog
>
--
Thanks,
~Nick Desaulniers
Powered by blists - more mailing lists