Skip to contentSkip to conversation

compiler_types.h: Move __nocfi out of compiler-specific header

tip: x86/core tip-bot2 for Kees Cook 1 participant 1 message Sep 11, 2025 Clang/LLVM build support

lore
Share & tools
lore

tip-bot2 for Kees Cook

author merge bot Applied
#0 lore raw

The following commit has been merged into the x86/core branch of tip:

Commit-ID:     038c7dc66e2744e5df57163b8f957745ae10d23e
Gitweb:        https://git.kernel.org/tip/038c7dc66e2744e5df57163b8f957745ae10d23e
Author:        Kees Cook <[email protected]>
AuthorDate:    Wed, 03 Sep 2025 20:46:40 -07:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Thu, 04 Sep 2025 21:59:07 +02:00

compiler_types.h: Move __nocfi out of compiler-specific header

Prepare for GCC KCFI support and move the __nocfi attribute from compiler-clang.h to compiler_types.h. This was already gated by CONFIG_CFI_CLANG, so this remains safe for non-KCFI GCC builds.

---
 include/linux/compiler-clang.h | 5 -----
 include/linux/compiler_types.h | 4 +++-
 2 files changed, 3 insertions(+), 6 deletions(-)
include/linux/compiler-clang.h +0 -5
index fa4ffe0..7a4568e 100644
@@ -96,11 +96,6 @@
 # define __noscs	__attribute__((__no_sanitize__("shadow-call-stack")))
 #endif
 
-#if __has_feature(kcfi)
-/* Disable CFI checking inside a function. */
-#define __nocfi		__attribute__((__no_sanitize__("kcfi")))
-#endif
-
 /*
  * Turn individual warnings and errors on and off locally, depending
  * on version.
include/linux/compiler_types.h +3 -1
index 1675543..a910f9f 100644
@@ -432,7 +432,9 @@ struct ftrace_likely_data {
 # define __noscs
 #endif
 
-#ifndef __nocfi
+#if defined(CONFIG_CFI_CLANG)
+# define __nocfi		__attribute__((__no_sanitize__("kcfi")))
+#else
 # define __nocfi
 #endif