2022-10-21 12:26:33

by Miguel Ojeda

[permalink] [raw]
Subject: [PATCH 1/5] compiler-gcc: be consistent with underscores use for `no_sanitize`

Other macros that define shorthands for attributes in e.g.
`compiler_attributes.h` and elsewhere use underscores.

Signed-off-by: Miguel Ojeda <[email protected]>
---
include/linux/compiler-gcc.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index f55a37efdb97..b9530d3515ac 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -83,25 +83,25 @@
#endif

#if __has_attribute(__no_sanitize_address__)
-#define __no_sanitize_address __attribute__((no_sanitize_address))
+#define __no_sanitize_address __attribute__((__no_sanitize_address__))
#else
#define __no_sanitize_address
#endif

#if defined(__SANITIZE_THREAD__) && __has_attribute(__no_sanitize_thread__)
-#define __no_sanitize_thread __attribute__((no_sanitize_thread))
+#define __no_sanitize_thread __attribute__((__no_sanitize_thread__))
#else
#define __no_sanitize_thread
#endif

#if __has_attribute(__no_sanitize_undefined__)
-#define __no_sanitize_undefined __attribute__((no_sanitize_undefined))
+#define __no_sanitize_undefined __attribute__((__no_sanitize_undefined__))
#else
#define __no_sanitize_undefined
#endif

#if defined(CONFIG_KCOV) && __has_attribute(__no_sanitize_coverage__)
-#define __no_sanitize_coverage __attribute__((no_sanitize_coverage))
+#define __no_sanitize_coverage __attribute__((__no_sanitize_coverage__))
#else
#define __no_sanitize_coverage
#endif

base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780
--
2.38.1


2022-10-21 12:26:41

by Miguel Ojeda

[permalink] [raw]
Subject: [PATCH 3/5] compiler-gcc: remove attribute support check for `__no_sanitize_thread__`

The attribute was added in GCC 5.1, which matches the minimum GCC version
supported by the kernel.

Therefore, remove the check.

Link: https://godbolt.org/z/vbxKejxbx
Signed-off-by: Miguel Ojeda <[email protected]>
---
include/linux/compiler-gcc.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index bfce7f4d0978..ba207deb77ca 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -84,7 +84,7 @@

#define __no_sanitize_address __attribute__((__no_sanitize_address__))

-#if defined(__SANITIZE_THREAD__) && __has_attribute(__no_sanitize_thread__)
+#if defined(__SANITIZE_THREAD__)
#define __no_sanitize_thread __attribute__((__no_sanitize_thread__))
#else
#define __no_sanitize_thread
--
2.38.1

2022-10-21 12:38:44

by Miguel Ojeda

[permalink] [raw]
Subject: [PATCH 5/5] compiler-gcc: document minimum version for `__no_sanitize_coverage__`

The attribute was added in GCC 12.1.

This will simplify future cleanups, and is closer to what we do
in `compiler_attributes.h`.

Link: https://godbolt.org/z/MGbT76j6G
Signed-off-by: Miguel Ojeda <[email protected]>
---
include/linux/compiler-gcc.h | 3 +++
1 file changed, 3 insertions(+)

diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 7f2c2bb73815..7af9e34ec261 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -92,6 +92,9 @@

#define __no_sanitize_undefined __attribute__((__no_sanitize_undefined__))

+/*
+ * Only supported since gcc >= 12
+ */
#if defined(CONFIG_KCOV) && __has_attribute(__no_sanitize_coverage__)
#define __no_sanitize_coverage __attribute__((__no_sanitize_coverage__))
#else
--
2.38.1

2022-10-21 12:39:59

by Miguel Ojeda

[permalink] [raw]
Subject: [PATCH 4/5] compiler-gcc: remove attribute support check for `__no_sanitize_undefined__`

The attribute was added in GCC 4.9, while the minimum GCC version
supported by the kernel is GCC 5.1.

Therefore, remove the check.

Link: https://godbolt.org/z/GrMeo6fYr
Signed-off-by: Miguel Ojeda <[email protected]>
---
include/linux/compiler-gcc.h | 4 ----
1 file changed, 4 deletions(-)

diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index ba207deb77ca..7f2c2bb73815 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -90,11 +90,7 @@
#define __no_sanitize_thread
#endif

-#if __has_attribute(__no_sanitize_undefined__)
#define __no_sanitize_undefined __attribute__((__no_sanitize_undefined__))
-#else
-#define __no_sanitize_undefined
-#endif

#if defined(CONFIG_KCOV) && __has_attribute(__no_sanitize_coverage__)
#define __no_sanitize_coverage __attribute__((__no_sanitize_coverage__))
--
2.38.1

2022-10-21 15:12:18

by Marco Elver

[permalink] [raw]
Subject: Re: [PATCH 3/5] compiler-gcc: remove attribute support check for `__no_sanitize_thread__`

On Fri, 21 Oct 2022 at 05:00, Miguel Ojeda <[email protected]> wrote:
>
> The attribute was added in GCC 5.1, which matches the minimum GCC version
> supported by the kernel.
>
> Therefore, remove the check.
>
> Link: https://godbolt.org/z/vbxKejxbx
> Signed-off-by: Miguel Ojeda <[email protected]>

Acked-by: Marco Elver <[email protected]>

> ---
> include/linux/compiler-gcc.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
> index bfce7f4d0978..ba207deb77ca 100644
> --- a/include/linux/compiler-gcc.h
> +++ b/include/linux/compiler-gcc.h
> @@ -84,7 +84,7 @@
>
> #define __no_sanitize_address __attribute__((__no_sanitize_address__))
>
> -#if defined(__SANITIZE_THREAD__) && __has_attribute(__no_sanitize_thread__)
> +#if defined(__SANITIZE_THREAD__)
> #define __no_sanitize_thread __attribute__((__no_sanitize_thread__))
> #else
> #define __no_sanitize_thread
> --
> 2.38.1
>

2022-10-21 15:12:21

by Marco Elver

[permalink] [raw]
Subject: Re: [PATCH 5/5] compiler-gcc: document minimum version for `__no_sanitize_coverage__`

On Fri, 21 Oct 2022 at 05:00, Miguel Ojeda <[email protected]> wrote:
>
> The attribute was added in GCC 12.1.
>
> This will simplify future cleanups, and is closer to what we do
> in `compiler_attributes.h`.
>
> Link: https://godbolt.org/z/MGbT76j6G
> Signed-off-by: Miguel Ojeda <[email protected]>

Acked-by: Marco Elver <[email protected]>

> ---
> include/linux/compiler-gcc.h | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
> index 7f2c2bb73815..7af9e34ec261 100644
> --- a/include/linux/compiler-gcc.h
> +++ b/include/linux/compiler-gcc.h
> @@ -92,6 +92,9 @@
>
> #define __no_sanitize_undefined __attribute__((__no_sanitize_undefined__))
>
> +/*
> + * Only supported since gcc >= 12
> + */
> #if defined(CONFIG_KCOV) && __has_attribute(__no_sanitize_coverage__)
> #define __no_sanitize_coverage __attribute__((__no_sanitize_coverage__))
> #else
> --
> 2.38.1
>

2022-10-21 16:21:39

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 4/5] compiler-gcc: remove attribute support check for `__no_sanitize_undefined__`

On Fri, Oct 21, 2022 at 01:59:55PM +0200, Miguel Ojeda wrote:
> The attribute was added in GCC 4.9, while the minimum GCC version
> supported by the kernel is GCC 5.1.
>
> Therefore, remove the check.
>
> Link: https://godbolt.org/z/GrMeo6fYr
> Signed-off-by: Miguel Ojeda <[email protected]>

Reviewed-by: Kees Cook <[email protected]>

--
Kees Cook

2022-10-21 16:25:02

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 3/5] compiler-gcc: remove attribute support check for `__no_sanitize_thread__`

On Fri, Oct 21, 2022 at 01:59:54PM +0200, Miguel Ojeda wrote:
> The attribute was added in GCC 5.1, which matches the minimum GCC version
> supported by the kernel.
>
> Therefore, remove the check.
>
> Link: https://godbolt.org/z/vbxKejxbx
> Signed-off-by: Miguel Ojeda <[email protected]>

Reviewed-by: Kees Cook <[email protected]>

--
Kees Cook

2022-10-21 16:54:21

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 1/5] compiler-gcc: be consistent with underscores use for `no_sanitize`

On Fri, Oct 21, 2022 at 01:59:52PM +0200, Miguel Ojeda wrote:
> Other macros that define shorthands for attributes in e.g.
> `compiler_attributes.h` and elsewhere use underscores.
>
> Signed-off-by: Miguel Ojeda <[email protected]>

Reviewed-by: Kees Cook <[email protected]>

--
Kees Cook

2022-10-21 17:19:27

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 5/5] compiler-gcc: document minimum version for `__no_sanitize_coverage__`

On Fri, Oct 21, 2022 at 01:59:56PM +0200, Miguel Ojeda wrote:
> The attribute was added in GCC 12.1.
>
> This will simplify future cleanups, and is closer to what we do
> in `compiler_attributes.h`.
>
> Link: https://godbolt.org/z/MGbT76j6G
> Signed-off-by: Miguel Ojeda <[email protected]>

Reviewed-by: Kees Cook <[email protected]>

--
Kees Cook

2022-10-21 21:23:15

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH 4/5] compiler-gcc: remove attribute support check for `__no_sanitize_undefined__`

On Fri, Oct 21, 2022 at 01:59:55PM +0200, Miguel Ojeda wrote:
> The attribute was added in GCC 4.9, while the minimum GCC version
> supported by the kernel is GCC 5.1.
>
> Therefore, remove the check.
>
> Link: https://godbolt.org/z/GrMeo6fYr
> Signed-off-by: Miguel Ojeda <[email protected]>

Reviewed-by: Nathan Chancellor <[email protected]>

> ---
> include/linux/compiler-gcc.h | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
> index ba207deb77ca..7f2c2bb73815 100644
> --- a/include/linux/compiler-gcc.h
> +++ b/include/linux/compiler-gcc.h
> @@ -90,11 +90,7 @@
> #define __no_sanitize_thread
> #endif
>
> -#if __has_attribute(__no_sanitize_undefined__)
> #define __no_sanitize_undefined __attribute__((__no_sanitize_undefined__))
> -#else
> -#define __no_sanitize_undefined
> -#endif
>
> #if defined(CONFIG_KCOV) && __has_attribute(__no_sanitize_coverage__)
> #define __no_sanitize_coverage __attribute__((__no_sanitize_coverage__))
> --
> 2.38.1
>
>

2022-10-21 21:23:59

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH 5/5] compiler-gcc: document minimum version for `__no_sanitize_coverage__`

On Fri, Oct 21, 2022 at 01:59:56PM +0200, Miguel Ojeda wrote:
> The attribute was added in GCC 12.1.
>
> This will simplify future cleanups, and is closer to what we do
> in `compiler_attributes.h`.
>
> Link: https://godbolt.org/z/MGbT76j6G
> Signed-off-by: Miguel Ojeda <[email protected]>

Reviewed-by: Nathan Chancellor <[email protected]>

> ---
> include/linux/compiler-gcc.h | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
> index 7f2c2bb73815..7af9e34ec261 100644
> --- a/include/linux/compiler-gcc.h
> +++ b/include/linux/compiler-gcc.h
> @@ -92,6 +92,9 @@
>
> #define __no_sanitize_undefined __attribute__((__no_sanitize_undefined__))
>
> +/*
> + * Only supported since gcc >= 12
> + */
> #if defined(CONFIG_KCOV) && __has_attribute(__no_sanitize_coverage__)
> #define __no_sanitize_coverage __attribute__((__no_sanitize_coverage__))
> #else
> --
> 2.38.1
>
>

2022-10-21 21:34:28

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH 1/5] compiler-gcc: be consistent with underscores use for `no_sanitize`

On Fri, Oct 21, 2022 at 01:59:52PM +0200, Miguel Ojeda wrote:
> Other macros that define shorthands for attributes in e.g.
> `compiler_attributes.h` and elsewhere use underscores.
>
> Signed-off-by: Miguel Ojeda <[email protected]>

Reviewed-by: Nathan Chancellor <[email protected]>

> ---
> include/linux/compiler-gcc.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
> index f55a37efdb97..b9530d3515ac 100644
> --- a/include/linux/compiler-gcc.h
> +++ b/include/linux/compiler-gcc.h
> @@ -83,25 +83,25 @@
> #endif
>
> #if __has_attribute(__no_sanitize_address__)
> -#define __no_sanitize_address __attribute__((no_sanitize_address))
> +#define __no_sanitize_address __attribute__((__no_sanitize_address__))
> #else
> #define __no_sanitize_address
> #endif
>
> #if defined(__SANITIZE_THREAD__) && __has_attribute(__no_sanitize_thread__)
> -#define __no_sanitize_thread __attribute__((no_sanitize_thread))
> +#define __no_sanitize_thread __attribute__((__no_sanitize_thread__))
> #else
> #define __no_sanitize_thread
> #endif
>
> #if __has_attribute(__no_sanitize_undefined__)
> -#define __no_sanitize_undefined __attribute__((no_sanitize_undefined))
> +#define __no_sanitize_undefined __attribute__((__no_sanitize_undefined__))
> #else
> #define __no_sanitize_undefined
> #endif
>
> #if defined(CONFIG_KCOV) && __has_attribute(__no_sanitize_coverage__)
> -#define __no_sanitize_coverage __attribute__((no_sanitize_coverage))
> +#define __no_sanitize_coverage __attribute__((__no_sanitize_coverage__))
> #else
> #define __no_sanitize_coverage
> #endif
>
> base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780
> --
> 2.38.1
>
>

2022-10-21 21:43:17

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH 3/5] compiler-gcc: remove attribute support check for `__no_sanitize_thread__`

On Fri, Oct 21, 2022 at 01:59:54PM +0200, Miguel Ojeda wrote:
> The attribute was added in GCC 5.1, which matches the minimum GCC version
> supported by the kernel.
>
> Therefore, remove the check.
>
> Link: https://godbolt.org/z/vbxKejxbx
> Signed-off-by: Miguel Ojeda <[email protected]>

Reviewed-by: Nathan Chancellor <[email protected]>

> ---
> include/linux/compiler-gcc.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
> index bfce7f4d0978..ba207deb77ca 100644
> --- a/include/linux/compiler-gcc.h
> +++ b/include/linux/compiler-gcc.h
> @@ -84,7 +84,7 @@
>
> #define __no_sanitize_address __attribute__((__no_sanitize_address__))
>
> -#if defined(__SANITIZE_THREAD__) && __has_attribute(__no_sanitize_thread__)
> +#if defined(__SANITIZE_THREAD__)
> #define __no_sanitize_thread __attribute__((__no_sanitize_thread__))
> #else
> #define __no_sanitize_thread
> --
> 2.38.1
>
>