linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] compiler-clang: add build check for clang 10.0.1
@ 2020-08-26 20:14 Nick Desaulniers
  2020-08-26 21:01 ` Kees Cook
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Nick Desaulniers @ 2020-08-26 20:14 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Nick Desaulniers, Sedat Dilek, Nathan Chancellor, Miguel Ojeda,
	Kees Cook, Marco Elver, Paul E. McKenney, Peter Zijlstra (Intel),
	Randy Dunlap, Ingo Molnar, Sami Tolvanen, linux-kernel,
	clang-built-linux

During Plumbers 2020, we voted to just support the latest release of
Clang for now.  Add a compile time check for this.

Older clang's may work, but we will likely drop workarounds for older
versions.

Link: https://github.com/ClangBuiltLinux/linux/issues/9
Link: https://github.com/ClangBuiltLinux/linux/issues/941
Suggested-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 include/linux/compiler-clang.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
index cee0c728d39a..7338d3ffd240 100644
--- a/include/linux/compiler-clang.h
+++ b/include/linux/compiler-clang.h
@@ -3,6 +3,14 @@
 #error "Please don't include <linux/compiler-clang.h> directly, include <linux/compiler.h> instead."
 #endif
 
+#define CLANG_VERSION (__clang_major__ * 10000	\
+		     + __clang_minor__ * 100	\
+		     + __clang_patchlevel__)
+
+#if CLANG_VERSION < 100001
+# error Sorry, your compiler is too old - please upgrade it.
+#endif
+
 /* Compiler specific definitions for Clang compiler */
 
 /* same as gcc, this was present in clang-2.6 so we can assume it works
-- 
2.28.0.297.g1956fa8f8d-goog


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] compiler-clang: add build check for clang 10.0.1
  2020-08-26 20:14 [PATCH] compiler-clang: add build check for clang 10.0.1 Nick Desaulniers
@ 2020-08-26 21:01 ` Kees Cook
  2020-08-27  7:16   ` Sedat Dilek
  2020-08-26 21:17 ` Miguel Ojeda
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Kees Cook @ 2020-08-26 21:01 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Andrew Morton, Sedat Dilek, Nathan Chancellor, Miguel Ojeda,
	Marco Elver, Paul E. McKenney, Peter Zijlstra (Intel),
	Randy Dunlap, Ingo Molnar, Sami Tolvanen, linux-kernel,
	clang-built-linux

On Wed, Aug 26, 2020 at 01:14:19PM -0700, Nick Desaulniers wrote:
> During Plumbers 2020, we voted to just support the latest release of
> Clang for now.  Add a compile time check for this.
> 
> Older clang's may work, but we will likely drop workarounds for older
> versions.
> 
> Link: https://github.com/ClangBuiltLinux/linux/issues/9
> Link: https://github.com/ClangBuiltLinux/linux/issues/941
> Suggested-by: Sedat Dilek <sedat.dilek@gmail.com>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
>  include/linux/compiler-clang.h | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
> index cee0c728d39a..7338d3ffd240 100644
> --- a/include/linux/compiler-clang.h
> +++ b/include/linux/compiler-clang.h
> @@ -3,6 +3,14 @@
>  #error "Please don't include <linux/compiler-clang.h> directly, include <linux/compiler.h> instead."
>  #endif
>  
> +#define CLANG_VERSION (__clang_major__ * 10000	\
> +		     + __clang_minor__ * 100	\
> +		     + __clang_patchlevel__)
> +
> +#if CLANG_VERSION < 100001
> +# error Sorry, your compiler is too old - please upgrade it.

Perhaps a bike-shed suggestion, but I think we should make this message
as specific (and helpful) as possible:

# error Sorry, your version of Clang is too old - please use 10.0.1 or newer.

Then anyone seeing this has several pieces of information:

- the kernel build was attempting to use Clang
	(maybe they accidentally poked the wrong configs in a CI)
- they need 10.0.1 or better
	("upgrade to what version?" doesn't need to be dug out of documentation,
         headers, etc)

With that, yes, let's do it. :)

Reviewed-by: Kees Cook <keescook@chromium.org>

(And likely we should improve the GCC message at the same time...)

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] compiler-clang: add build check for clang 10.0.1
  2020-08-26 20:14 [PATCH] compiler-clang: add build check for clang 10.0.1 Nick Desaulniers
  2020-08-26 21:01 ` Kees Cook
@ 2020-08-26 21:17 ` Miguel Ojeda
  2020-08-26 21:26   ` Nathan Chancellor
  2020-08-26 21:42 ` Nathan Chancellor
  2020-08-27  7:22 ` Sedat Dilek
  3 siblings, 1 reply; 12+ messages in thread
From: Miguel Ojeda @ 2020-08-26 21:17 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Andrew Morton, Sedat Dilek, Nathan Chancellor, Kees Cook,
	Marco Elver, Paul E. McKenney, Peter Zijlstra (Intel),
	Randy Dunlap, Ingo Molnar, Sami Tolvanen, linux-kernel,
	clang-built-linux

On Wed, Aug 26, 2020 at 10:14 PM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> During Plumbers 2020, we voted to just support the latest release of
> Clang for now.  Add a compile time check for this.

Since this effectively enforces a minimum version for Clang, I'd
also update `Documentation/process/changes.rst` and
`Documentation/admin-guide/README.rst` to mention this, and perhaps
use that as a commit title ("implement minimum version for Clang")
since that is the important change, not the implementation so much!

[Actually, I'd remove the particular GCC version from the
`admin-guide/README.rst` to avoid having the version in 2 places (that
doc already links to the other one), but that should be another
patch.]

Reviewed-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] compiler-clang: add build check for clang 10.0.1
  2020-08-26 21:17 ` Miguel Ojeda
@ 2020-08-26 21:26   ` Nathan Chancellor
  2020-08-27  7:19     ` Sedat Dilek
  0 siblings, 1 reply; 12+ messages in thread
From: Nathan Chancellor @ 2020-08-26 21:26 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Nick Desaulniers, Andrew Morton, Sedat Dilek, Kees Cook,
	Marco Elver, Paul E. McKenney, Peter Zijlstra (Intel),
	Randy Dunlap, Ingo Molnar, Sami Tolvanen, linux-kernel,
	clang-built-linux

On Wed, Aug 26, 2020 at 11:17:34PM +0200, Miguel Ojeda wrote:
> On Wed, Aug 26, 2020 at 10:14 PM Nick Desaulniers
> <ndesaulniers@google.com> wrote:
> >
> > During Plumbers 2020, we voted to just support the latest release of
> > Clang for now.  Add a compile time check for this.
> 
> Since this effectively enforces a minimum version for Clang, I'd
> also update `Documentation/process/changes.rst` and
> `Documentation/admin-guide/README.rst` to mention this, and perhaps
> use that as a commit title ("implement minimum version for Clang")
> since that is the important change, not the implementation so much!

I was actually going to comment on this separately but you beat me to it
:) this patch probably should have been sent as a series with the
Documentation update to avoid confusion for the reviewers:

https://lore.kernel.org/lkml/20200826191555.3350406-1-ndesaulniers@google.com/

Cheers,
Nathan

> [Actually, I'd remove the particular GCC version from the
> `admin-guide/README.rst` to avoid having the version in 2 places (that
> doc already links to the other one), but that should be another
> patch.]
> 
> Reviewed-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
> 
> Cheers,
> Miguel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] compiler-clang: add build check for clang 10.0.1
  2020-08-26 20:14 [PATCH] compiler-clang: add build check for clang 10.0.1 Nick Desaulniers
  2020-08-26 21:01 ` Kees Cook
  2020-08-26 21:17 ` Miguel Ojeda
@ 2020-08-26 21:42 ` Nathan Chancellor
  2020-08-27 19:02   ` Marco Elver
  2020-08-31 23:32   ` Nick Desaulniers
  2020-08-27  7:22 ` Sedat Dilek
  3 siblings, 2 replies; 12+ messages in thread
From: Nathan Chancellor @ 2020-08-26 21:42 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Andrew Morton, Sedat Dilek, Miguel Ojeda, Kees Cook, Marco Elver,
	Paul E. McKenney, Peter Zijlstra (Intel),
	Randy Dunlap, Ingo Molnar, Sami Tolvanen, linux-kernel,
	clang-built-linux

On Wed, Aug 26, 2020 at 01:14:19PM -0700, Nick Desaulniers wrote:
> During Plumbers 2020, we voted to just support the latest release of
> Clang for now.  Add a compile time check for this.
> 
> Older clang's may work, but we will likely drop workarounds for older
> versions.

I think this part of the commit message is a little wishy-washy. If we
are breaking the build for clang < 10.0.1, we are not saying "may work",
we are saying "won't work". Because of this, we should take the
opportunity to clean up behind us and revert/remove parts of:

87e0d4f0f37f ("kbuild: disable clang's default use of -fmerge-all-constants")
b0fe66cf0950 ("ARM: 8905/1: Emit __gnu_mcount_nc when using Clang 10.0.0 or newer")
b9249cba25a5 ("arm64: bti: Require clang >= 10.0.1 for in-kernel BTI support")
3acf4be23528 ("arm64: vdso: Fix compilation with clang older than 8")

This could be a series or a part of this commit, I do not have a
strong preference. If we are not going to clean up behind us, this
should be a warning and not an error.

> Link: https://github.com/ClangBuiltLinux/linux/issues/9
> Link: https://github.com/ClangBuiltLinux/linux/issues/941
> Suggested-by: Sedat Dilek <sedat.dilek@gmail.com>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

Otherwise, I agree with Kees's comments. With them addressed, feel free
to add:

Acked-by: Nathan Chancellor <natechancellor@gmail.com>

> ---
>  include/linux/compiler-clang.h | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
> index cee0c728d39a..7338d3ffd240 100644
> --- a/include/linux/compiler-clang.h
> +++ b/include/linux/compiler-clang.h
> @@ -3,6 +3,14 @@
>  #error "Please don't include <linux/compiler-clang.h> directly, include <linux/compiler.h> instead."
>  #endif
>  
> +#define CLANG_VERSION (__clang_major__ * 10000	\
> +		     + __clang_minor__ * 100	\
> +		     + __clang_patchlevel__)
> +
> +#if CLANG_VERSION < 100001
> +# error Sorry, your compiler is too old - please upgrade it.
> +#endif
> +
>  /* Compiler specific definitions for Clang compiler */
>  
>  /* same as gcc, this was present in clang-2.6 so we can assume it works
> -- 
> 2.28.0.297.g1956fa8f8d-goog
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] compiler-clang: add build check for clang 10.0.1
  2020-08-26 21:01 ` Kees Cook
@ 2020-08-27  7:16   ` Sedat Dilek
  0 siblings, 0 replies; 12+ messages in thread
From: Sedat Dilek @ 2020-08-27  7:16 UTC (permalink / raw)
  To: Kees Cook
  Cc: Nick Desaulniers, Andrew Morton, Nathan Chancellor, Miguel Ojeda,
	Marco Elver, Paul E. McKenney, Peter Zijlstra (Intel),
	Randy Dunlap, Ingo Molnar, Sami Tolvanen, linux-kernel,
	Clang-Built-Linux ML

On Wed, Aug 26, 2020 at 11:01 PM Kees Cook <keescook@chromium.org> wrote:
>
> On Wed, Aug 26, 2020 at 01:14:19PM -0700, Nick Desaulniers wrote:
> > During Plumbers 2020, we voted to just support the latest release of
> > Clang for now.  Add a compile time check for this.
> >
> > Older clang's may work, but we will likely drop workarounds for older
> > versions.
> >
> > Link: https://github.com/ClangBuiltLinux/linux/issues/9
> > Link: https://github.com/ClangBuiltLinux/linux/issues/941
> > Suggested-by: Sedat Dilek <sedat.dilek@gmail.com>
> > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> > ---
> >  include/linux/compiler-clang.h | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
> > index cee0c728d39a..7338d3ffd240 100644
> > --- a/include/linux/compiler-clang.h
> > +++ b/include/linux/compiler-clang.h
> > @@ -3,6 +3,14 @@
> >  #error "Please don't include <linux/compiler-clang.h> directly, include <linux/compiler.h> instead."
> >  #endif
> >
> > +#define CLANG_VERSION (__clang_major__ * 10000       \
> > +                  + __clang_minor__ * 100    \
> > +                  + __clang_patchlevel__)
> > +
> > +#if CLANG_VERSION < 100001
> > +# error Sorry, your compiler is too old - please upgrade it.
>
> Perhaps a bike-shed suggestion, but I think we should make this message
> as specific (and helpful) as possible:
>
> # error Sorry, your version of Clang is too old - please use 10.0.1 or newer.
>

Agreed... Information about the required minimum version is user-friendly.

- Sedat -

> Then anyone seeing this has several pieces of information:
>
> - the kernel build was attempting to use Clang
>         (maybe they accidentally poked the wrong configs in a CI)
> - they need 10.0.1 or better
>         ("upgrade to what version?" doesn't need to be dug out of documentation,
>          headers, etc)
>
> With that, yes, let's do it. :)
>
> Reviewed-by: Kees Cook <keescook@chromium.org>
>
> (And likely we should improve the GCC message at the same time...)
>
> --
> Kees Cook

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] compiler-clang: add build check for clang 10.0.1
  2020-08-26 21:26   ` Nathan Chancellor
@ 2020-08-27  7:19     ` Sedat Dilek
  0 siblings, 0 replies; 12+ messages in thread
From: Sedat Dilek @ 2020-08-27  7:19 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Miguel Ojeda, Nick Desaulniers, Andrew Morton, Kees Cook,
	Marco Elver, Paul E. McKenney, Peter Zijlstra (Intel),
	Randy Dunlap, Ingo Molnar, Sami Tolvanen, linux-kernel,
	clang-built-linux

On Wed, Aug 26, 2020 at 11:26 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> On Wed, Aug 26, 2020 at 11:17:34PM +0200, Miguel Ojeda wrote:
> > On Wed, Aug 26, 2020 at 10:14 PM Nick Desaulniers
> > <ndesaulniers@google.com> wrote:
> > >
> > > During Plumbers 2020, we voted to just support the latest release of
> > > Clang for now.  Add a compile time check for this.
> >
> > Since this effectively enforces a minimum version for Clang, I'd
> > also update `Documentation/process/changes.rst` and
> > `Documentation/admin-guide/README.rst` to mention this, and perhaps
> > use that as a commit title ("implement minimum version for Clang")
> > since that is the important change, not the implementation so much!
>
> I was actually going to comment on this separately but you beat me to it
> :) this patch probably should have been sent as a series with the
> Documentation update to avoid confusion for the reviewers:
>

Agreed... This patch should be combined with the other one and sent as
a patch-series.

- Sedat -

> https://lore.kernel.org/lkml/20200826191555.3350406-1-ndesaulniers@google.com/
>
> Cheers,
> Nathan
>
> > [Actually, I'd remove the particular GCC version from the
> > `admin-guide/README.rst` to avoid having the version in 2 places (that
> > doc already links to the other one), but that should be another
> > patch.]
> >
> > Reviewed-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
> >
> > Cheers,
> > Miguel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] compiler-clang: add build check for clang 10.0.1
  2020-08-26 20:14 [PATCH] compiler-clang: add build check for clang 10.0.1 Nick Desaulniers
                   ` (2 preceding siblings ...)
  2020-08-26 21:42 ` Nathan Chancellor
@ 2020-08-27  7:22 ` Sedat Dilek
  3 siblings, 0 replies; 12+ messages in thread
From: Sedat Dilek @ 2020-08-27  7:22 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Andrew Morton, Nathan Chancellor, Miguel Ojeda, Kees Cook,
	Marco Elver, Paul E. McKenney, Peter Zijlstra (Intel),
	Randy Dunlap, Ingo Molnar, Sami Tolvanen, linux-kernel,
	Clang-Built-Linux ML

On Wed, Aug 26, 2020 at 10:14 PM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> During Plumbers 2020, we voted to just support the latest release of
> Clang for now.  Add a compile time check for this.
>
> Older clang's may work, but we will likely drop workarounds for older
> versions.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/9
> Link: https://github.com/ClangBuiltLinux/linux/issues/941
> Suggested-by: Sedat Dilek <sedat.dilek@gmail.com>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

Nice to see This Is Happening!

See also my other replies to Kees and Nathan comments.

Acked-by: Sedat Dilek <sedat.dilek@gmail.com>

- Sedat -

> ---
>  include/linux/compiler-clang.h | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
> index cee0c728d39a..7338d3ffd240 100644
> --- a/include/linux/compiler-clang.h
> +++ b/include/linux/compiler-clang.h
> @@ -3,6 +3,14 @@
>  #error "Please don't include <linux/compiler-clang.h> directly, include <linux/compiler.h> instead."
>  #endif
>
> +#define CLANG_VERSION (__clang_major__ * 10000 \
> +                    + __clang_minor__ * 100    \
> +                    + __clang_patchlevel__)
> +
> +#if CLANG_VERSION < 100001
> +# error Sorry, your compiler is too old - please upgrade it.
> +#endif
> +
>  /* Compiler specific definitions for Clang compiler */
>
>  /* same as gcc, this was present in clang-2.6 so we can assume it works
> --
> 2.28.0.297.g1956fa8f8d-goog
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] compiler-clang: add build check for clang 10.0.1
  2020-08-26 21:42 ` Nathan Chancellor
@ 2020-08-27 19:02   ` Marco Elver
  2020-08-28 10:54     ` Andrey Konovalov
  2020-08-31 23:32   ` Nick Desaulniers
  1 sibling, 1 reply; 12+ messages in thread
From: Marco Elver @ 2020-08-27 19:02 UTC (permalink / raw)
  To: Nick Desaulniers, Nathan Chancellor
  Cc: Andrew Morton, Sedat Dilek, Miguel Ojeda, Kees Cook,
	Paul E. McKenney, Peter Zijlstra (Intel),
	Randy Dunlap, Ingo Molnar, Sami Tolvanen, linux-kernel,
	clang-built-linux, Andrey Konovalov, kasan-dev

On Wed, Aug 26, 2020 at 02:42PM -0700, Nathan Chancellor wrote:
> On Wed, Aug 26, 2020 at 01:14:19PM -0700, Nick Desaulniers wrote:
> > During Plumbers 2020, we voted to just support the latest release of
> > Clang for now.  Add a compile time check for this.
> > 
> > Older clang's may work, but we will likely drop workarounds for older
> > versions.
> 
> I think this part of the commit message is a little wishy-washy. If we
> are breaking the build for clang < 10.0.1, we are not saying "may work",
> we are saying "won't work". Because of this, we should take the
> opportunity to clean up behind us and revert/remove parts of:
> 
> 87e0d4f0f37f ("kbuild: disable clang's default use of -fmerge-all-constants")
> b0fe66cf0950 ("ARM: 8905/1: Emit __gnu_mcount_nc when using Clang 10.0.0 or newer")
> b9249cba25a5 ("arm64: bti: Require clang >= 10.0.1 for in-kernel BTI support")
> 3acf4be23528 ("arm64: vdso: Fix compilation with clang older than 8")
> 
> This could be a series or a part of this commit, I do not have a
> strong preference. If we are not going to clean up behind us, this
> should be a warning and not an error.

There are also some other documentation that would go stale. We probably
have to change KASAN docs to look something like the below.

I wish we could also remove the "but detection of out-of-bounds accesses
for global variables is only supported since Clang 11", but Clang 10 is
a vast improvement so I'm not complaining. :-)

Acked-by: Marco Elver <elver@google.com>

Thanks,
-- Marco

------ >8 ------

From 13d03b55c69dec813d94c1481dcb294971f164ef Mon Sep 17 00:00:00 2001
From: Marco Elver <elver@google.com>
Date: Thu, 27 Aug 2020 20:56:34 +0200
Subject: [PATCH] kasan: Remove mentions of unsupported Clang versions

Since the kernel now requires at least Clang 10.0.1, remove any mention
of old Clang versions and simplify the documentation.

Signed-off-by: Marco Elver <elver@google.com>
---
 Documentation/dev-tools/kasan.rst | 4 ++--
 lib/Kconfig.kasan                 | 9 ++++-----
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst
index 38fd5681fade..4abc84b1798c 100644
--- a/Documentation/dev-tools/kasan.rst
+++ b/Documentation/dev-tools/kasan.rst
@@ -13,10 +13,10 @@ KASAN uses compile-time instrumentation to insert validity checks before every
 memory access, and therefore requires a compiler version that supports that.
 
 Generic KASAN is supported in both GCC and Clang. With GCC it requires version
-8.3.0 or later. With Clang it requires version 7.0.0 or later, but detection of
+8.3.0 or later. Any supported Clang version is compatible, but detection of
 out-of-bounds accesses for global variables is only supported since Clang 11.
 
-Tag-based KASAN is only supported in Clang and requires version 7.0.0 or later.
+Tag-based KASAN is only supported in Clang.
 
 Currently generic KASAN is supported for the x86_64, arm64, xtensa, s390 and
 riscv architectures, and tag-based KASAN is supported only for arm64.
diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan
index 047b53dbfd58..033a5bc67ac4 100644
--- a/lib/Kconfig.kasan
+++ b/lib/Kconfig.kasan
@@ -54,9 +54,9 @@ config KASAN_GENERIC
 	  Enables generic KASAN mode.
 
 	  This mode is supported in both GCC and Clang. With GCC it requires
-	  version 8.3.0 or later. With Clang it requires version 7.0.0 or
-	  later, but detection of out-of-bounds accesses for global variables
-	  is supported only since Clang 11.
+	  version 8.3.0 or later. Any supported Clang version is compatible,
+	  but detection of out-of-bounds accesses for global variables is
+	  supported only since Clang 11.
 
 	  This mode consumes about 1/8th of available memory at kernel start
 	  and introduces an overhead of ~x1.5 for the rest of the allocations.
@@ -78,8 +78,7 @@ config KASAN_SW_TAGS
 	  Enables software tag-based KASAN mode.
 
 	  This mode requires Top Byte Ignore support by the CPU and therefore
-	  is only supported for arm64. This mode requires Clang version 7.0.0
-	  or later.
+	  is only supported for arm64. This mode requires Clang.
 
 	  This mode consumes about 1/16th of available memory at kernel start
 	  and introduces an overhead of ~20% for the rest of the allocations.
-- 
2.28.0.297.g1956fa8f8d-goog


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] compiler-clang: add build check for clang 10.0.1
  2020-08-27 19:02   ` Marco Elver
@ 2020-08-28 10:54     ` Andrey Konovalov
  0 siblings, 0 replies; 12+ messages in thread
From: Andrey Konovalov @ 2020-08-28 10:54 UTC (permalink / raw)
  To: Marco Elver
  Cc: Nick Desaulniers, Nathan Chancellor, Andrew Morton, Sedat Dilek,
	Miguel Ojeda, Kees Cook, Paul E. McKenney, Peter Zijlstra (Intel),
	Randy Dunlap, Ingo Molnar, Sami Tolvanen, LKML,
	clang-built-linux, kasan-dev

On Thu, Aug 27, 2020 at 9:02 PM Marco Elver <elver@google.com> wrote:
>
> On Wed, Aug 26, 2020 at 02:42PM -0700, Nathan Chancellor wrote:
> > On Wed, Aug 26, 2020 at 01:14:19PM -0700, Nick Desaulniers wrote:
> > > During Plumbers 2020, we voted to just support the latest release of
> > > Clang for now.  Add a compile time check for this.
> > >
> > > Older clang's may work, but we will likely drop workarounds for older
> > > versions.
> >
> > I think this part of the commit message is a little wishy-washy. If we
> > are breaking the build for clang < 10.0.1, we are not saying "may work",
> > we are saying "won't work". Because of this, we should take the
> > opportunity to clean up behind us and revert/remove parts of:
> >
> > 87e0d4f0f37f ("kbuild: disable clang's default use of -fmerge-all-constants")
> > b0fe66cf0950 ("ARM: 8905/1: Emit __gnu_mcount_nc when using Clang 10.0.0 or newer")
> > b9249cba25a5 ("arm64: bti: Require clang >= 10.0.1 for in-kernel BTI support")
> > 3acf4be23528 ("arm64: vdso: Fix compilation with clang older than 8")
> >
> > This could be a series or a part of this commit, I do not have a
> > strong preference. If we are not going to clean up behind us, this
> > should be a warning and not an error.
>
> There are also some other documentation that would go stale. We probably
> have to change KASAN docs to look something like the below.
>
> I wish we could also remove the "but detection of out-of-bounds accesses
> for global variables is only supported since Clang 11", but Clang 10 is
> a vast improvement so I'm not complaining. :-)
>
> Acked-by: Marco Elver <elver@google.com>
>
> Thanks,
> -- Marco
>
> ------ >8 ------
>
> From 13d03b55c69dec813d94c1481dcb294971f164ef Mon Sep 17 00:00:00 2001
> From: Marco Elver <elver@google.com>
> Date: Thu, 27 Aug 2020 20:56:34 +0200
> Subject: [PATCH] kasan: Remove mentions of unsupported Clang versions
>
> Since the kernel now requires at least Clang 10.0.1, remove any mention
> of old Clang versions and simplify the documentation.
>
> Signed-off-by: Marco Elver <elver@google.com>
> ---
>  Documentation/dev-tools/kasan.rst | 4 ++--
>  lib/Kconfig.kasan                 | 9 ++++-----
>  2 files changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst
> index 38fd5681fade..4abc84b1798c 100644
> --- a/Documentation/dev-tools/kasan.rst
> +++ b/Documentation/dev-tools/kasan.rst
> @@ -13,10 +13,10 @@ KASAN uses compile-time instrumentation to insert validity checks before every
>  memory access, and therefore requires a compiler version that supports that.
>
>  Generic KASAN is supported in both GCC and Clang. With GCC it requires version
> -8.3.0 or later. With Clang it requires version 7.0.0 or later, but detection of
> +8.3.0 or later. Any supported Clang version is compatible, but detection of
>  out-of-bounds accesses for global variables is only supported since Clang 11.
>
> -Tag-based KASAN is only supported in Clang and requires version 7.0.0 or later.
> +Tag-based KASAN is only supported in Clang.
>
>  Currently generic KASAN is supported for the x86_64, arm64, xtensa, s390 and
>  riscv architectures, and tag-based KASAN is supported only for arm64.
> diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan
> index 047b53dbfd58..033a5bc67ac4 100644
> --- a/lib/Kconfig.kasan
> +++ b/lib/Kconfig.kasan
> @@ -54,9 +54,9 @@ config KASAN_GENERIC
>           Enables generic KASAN mode.
>
>           This mode is supported in both GCC and Clang. With GCC it requires
> -         version 8.3.0 or later. With Clang it requires version 7.0.0 or
> -         later, but detection of out-of-bounds accesses for global variables
> -         is supported only since Clang 11.
> +         version 8.3.0 or later. Any supported Clang version is compatible,
> +         but detection of out-of-bounds accesses for global variables is
> +         supported only since Clang 11.
>
>           This mode consumes about 1/8th of available memory at kernel start
>           and introduces an overhead of ~x1.5 for the rest of the allocations.
> @@ -78,8 +78,7 @@ config KASAN_SW_TAGS
>           Enables software tag-based KASAN mode.
>
>           This mode requires Top Byte Ignore support by the CPU and therefore
> -         is only supported for arm64. This mode requires Clang version 7.0.0
> -         or later.
> +         is only supported for arm64. This mode requires Clang.
>
>           This mode consumes about 1/16th of available memory at kernel start
>           and introduces an overhead of ~20% for the rest of the allocations.
> --
> 2.28.0.297.g1956fa8f8d-goog
>

Reviewed-by: Andrey Konovalov <andreyknvl@google.com>

Thanks!

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] compiler-clang: add build check for clang 10.0.1
  2020-08-26 21:42 ` Nathan Chancellor
  2020-08-27 19:02   ` Marco Elver
@ 2020-08-31 23:32   ` Nick Desaulniers
  2020-08-31 23:36     ` Nick Desaulniers
  1 sibling, 1 reply; 12+ messages in thread
From: Nick Desaulniers @ 2020-08-31 23:32 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Andrew Morton, Sedat Dilek, Miguel Ojeda, Kees Cook, Marco Elver,
	Paul E. McKenney, Peter Zijlstra (Intel),
	Randy Dunlap, Ingo Molnar, Sami Tolvanen, LKML,
	clang-built-linux

On Wed, Aug 26, 2020 at 2:42 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> On Wed, Aug 26, 2020 at 01:14:19PM -0700, Nick Desaulniers wrote:
> > During Plumbers 2020, we voted to just support the latest release of
> > Clang for now.  Add a compile time check for this.
> >
> > Older clang's may work, but we will likely drop workarounds for older
> > versions.
>
> I think this part of the commit message is a little wishy-washy. If we

Yep, you're right. I'm still in denial. Let me rip that bandaid off
and send a v2, with your and Kees' suggestions.

Sorry, the docs patch already got picked up. Let's follow up with
additional patches to docs separately.

> are breaking the build for clang < 10.0.1, we are not saying "may work",
> we are saying "won't work". Because of this, we should take the
> opportunity to clean up behind us and revert/remove parts of:
>
> 87e0d4f0f37f ("kbuild: disable clang's default use of -fmerge-all-constants")
> b0fe66cf0950 ("ARM: 8905/1: Emit __gnu_mcount_nc when using Clang 10.0.0 or newer")
> b9249cba25a5 ("arm64: bti: Require clang >= 10.0.1 for in-kernel BTI support")
> 3acf4be23528 ("arm64: vdso: Fix compilation with clang older than 8")

I'd prefer to see this land in mainline first; otherwise, I'm worried
about this patch "racing" to mainline with those patches if they go
via separate trees.  Thoughts?
-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] compiler-clang: add build check for clang 10.0.1
  2020-08-31 23:32   ` Nick Desaulniers
@ 2020-08-31 23:36     ` Nick Desaulniers
  0 siblings, 0 replies; 12+ messages in thread
From: Nick Desaulniers @ 2020-08-31 23:36 UTC (permalink / raw)
  To: Nathan Chancellor, Andrew Morton, Masahiro Yamada
  Cc: Sedat Dilek, Miguel Ojeda, Kees Cook, Marco Elver,
	Paul E. McKenney, Peter Zijlstra (Intel),
	Randy Dunlap, Ingo Molnar, Sami Tolvanen, LKML,
	clang-built-linux

On Mon, Aug 31, 2020 at 4:32 PM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Wed, Aug 26, 2020 at 2:42 PM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > On Wed, Aug 26, 2020 at 01:14:19PM -0700, Nick Desaulniers wrote:
> > > During Plumbers 2020, we voted to just support the latest release of
> > > Clang for now.  Add a compile time check for this.
> > >
> > > Older clang's may work, but we will likely drop workarounds for older
> > > versions.
> >
> > I think this part of the commit message is a little wishy-washy. If we
> > are breaking the build for clang < 10.0.1, we are not saying "may work",
> > we are saying "won't work". Because of this, we should take the
> > opportunity to clean up behind us and revert/remove parts of:
> >
> > 87e0d4f0f37f ("kbuild: disable clang's default use of -fmerge-all-constants")
> > b0fe66cf0950 ("ARM: 8905/1: Emit __gnu_mcount_nc when using Clang 10.0.0 or newer")
> > b9249cba25a5 ("arm64: bti: Require clang >= 10.0.1 for in-kernel BTI support")
> > 3acf4be23528 ("arm64: vdso: Fix compilation with clang older than 8")
>
> I'd prefer to see this land in mainline first; otherwise, I'm worried
> about this patch "racing" to mainline with those patches if they go
> via separate trees.  Thoughts?

Maybe I should send such a series (including Marco's recommendations)
to Mr. Morton or Yamada-san?
-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-08-31 23:36 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-26 20:14 [PATCH] compiler-clang: add build check for clang 10.0.1 Nick Desaulniers
2020-08-26 21:01 ` Kees Cook
2020-08-27  7:16   ` Sedat Dilek
2020-08-26 21:17 ` Miguel Ojeda
2020-08-26 21:26   ` Nathan Chancellor
2020-08-27  7:19     ` Sedat Dilek
2020-08-26 21:42 ` Nathan Chancellor
2020-08-27 19:02   ` Marco Elver
2020-08-28 10:54     ` Andrey Konovalov
2020-08-31 23:32   ` Nick Desaulniers
2020-08-31 23:36     ` Nick Desaulniers
2020-08-27  7:22 ` Sedat Dilek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).