]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
compiler_types.h: Move __nocfi out of compiler-specific header
authorKees Cook <kees@kernel.org>
Thu, 4 Sep 2025 03:46:40 +0000 (20:46 -0700)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 4 Sep 2025 19:59:07 +0000 (21:59 +0200)
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.

Signed-off-by: Kees Cook <kees@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20250904034656.3670313-1-kees@kernel.org
include/linux/compiler-clang.h
include/linux/compiler_types.h

index fa4ffe037bc77f4ff2e4e69d50afcc57d856d961..7a4568e421dc620d4a22046c3e365e9b46261246 100644 (file)
 # 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.
index 16755431fc11ee5e31c31df236fcda6c83a15b15..a910f9fa5341732ef403a9f58b65755c16e54f30 100644 (file)
@@ -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