Skip to contentSkip to conversation

compiler-gcc: be consistent with underscores use for `no_sanitize`

PATCH Applied Miguel Ojeda 4 participants 17 messages Oct 21, 2022

lore
Share & tools
lore
#0 lore raw

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.

---
 include/linux/compiler-gcc.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
include/linux/compiler-gcc.h +4 -4
index f55a37efdb97..b9530d3515ac 100644
@@ -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

Signature · 1 line
2.38.1
#1 lore raw

PATCH 2/5 compiler-gcc: remove attribute support check for `__no_sanitize_address__`

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

Therefore, remove the check.

---
 include/linux/compiler-gcc.h | 4 ----
 1 file changed, 4 deletions(-)
include/linux/compiler-gcc.h +0 -4
index b9530d3515ac..bfce7f4d0978 100644
@@ -82,11 +82,7 @@
 #define __noscs __attribute__((__no_sanitize__("shadow-call-stack")))
 #endif
 
-#if __has_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__))
Signature · 1 line
2.38.1
Reviewed-by on v1 2/5
#3 lore raw

Re: [PATCH 2/5] compiler-gcc: remove attribute support check for `__no_sanitize_address__`

In reply to Miguel Ojeda
Quoted 7 lines · Miguel Ojeda

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

Therefore, remove the check.

Quoted 24 lines
---
 include/linux/compiler-gcc.h | 4 ----
 1 file changed, 4 deletions(-)
include/linux/compiler-gcc.h +0 -4
index b9530d3515ac..bfce7f4d0978 100644
@@ -82,11 +82,7 @@
 #define __noscs __attribute__((__no_sanitize__("shadow-call-stack")))
 #endif
 
-#if __has_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__))
Signature · 1 line
2.38.1
#4 lore raw

PATCH 3/5 compiler-gcc: remove attribute support check for `__no_sanitize_thread__`

In reply to Miguel Ojeda

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

Therefore, remove the check.

---
 include/linux/compiler-gcc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/compiler-gcc.h +1 -1
index bfce7f4d0978..ba207deb77ca 100644
@@ -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
Signature · 1 line
2.38.1
Acked-by on v1 3/5
#5 lore raw

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

Quoted 8 lines · Miguel Ojeda

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

Therefore, remove the check.

Quoted 20 lines
---
 include/linux/compiler-gcc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/compiler-gcc.h +1 -2
index bfce7f4d0978..ba207deb77ca 100644
@@ -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

Reviewed-by on v1 3/5
#7 lore raw

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

In reply to Miguel Ojeda
Quoted 7 lines · Miguel Ojeda

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

Therefore, remove the check.

Quoted 21 lines
---
 include/linux/compiler-gcc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/compiler-gcc.h +1 -1
index bfce7f4d0978..ba207deb77ca 100644
@@ -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
Signature · 1 line
2.38.1
#8 lore raw

PATCH 4/5 compiler-gcc: remove attribute support check for `__no_sanitize_undefined__`

In reply to Miguel Ojeda

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.

---
 include/linux/compiler-gcc.h | 4 ----
 1 file changed, 4 deletions(-)
include/linux/compiler-gcc.h +0 -4
index ba207deb77ca..7f2c2bb73815 100644
@@ -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__))
Signature · 1 line
2.38.1
Reviewed-by on v1 4/5
#10 lore raw

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

In reply to Miguel Ojeda
Quoted 7 lines · Miguel Ojeda

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.

Quoted 24 lines
---
 include/linux/compiler-gcc.h | 4 ----
 1 file changed, 4 deletions(-)
include/linux/compiler-gcc.h +0 -4
index ba207deb77ca..7f2c2bb73815 100644
@@ -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__))
Signature · 1 line
2.38.1
#11 lore raw

PATCH 5/5 compiler-gcc: document minimum version for `__no_sanitize_coverage__`

In reply to Miguel Ojeda

The attribute was added in GCC 12.1.

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

---
 include/linux/compiler-gcc.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/compiler-gcc.h +3 -0
index 7f2c2bb73815..7af9e34ec261 100644
@@ -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
Signature · 1 line
2.38.1
Acked-by on v1 5/5
#12 lore raw

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

Quoted 8 lines · Miguel Ojeda

The attribute was added in GCC 12.1.

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

Quoted 21 lines
---
 include/linux/compiler-gcc.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/compiler-gcc.h +3 -1
index 7f2c2bb73815..7af9e34ec261 100644
@@ -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

Reviewed-by on v1 5/5
#14 lore raw

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

In reply to Miguel Ojeda
Quoted 7 lines · Miguel Ojeda

The attribute was added in GCC 12.1.

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

Quoted 22 lines
---
 include/linux/compiler-gcc.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/compiler-gcc.h +3 -0
index 7f2c2bb73815..7af9e34ec261 100644
@@ -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
Signature · 1 line
2.38.1
Reviewed-by on v1 1/5
#16 lore raw
In reply to Miguel Ojeda
Quoted 4 lines · Miguel Ojeda

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

Quoted 44 lines
---
 include/linux/compiler-gcc.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
include/linux/compiler-gcc.h +4 -4
index f55a37efdb97..b9530d3515ac 100644
@@ -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

Signature · 1 line
2.38.1