[PATCH v2 1/9] compiler_types.h: Move __nocfi out of compiler-specific header
Kees Cook
kees at kernel.org
Wed Sep 3 20:46:40 PDT 2025
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 at kernel.org>
---
Cc: Nathan Chancellor <nathan at kernel.org>
Cc: Nick Desaulniers <nick.desaulniers+lkml at gmail.com>
Cc: Bill Wendling <morbo at google.com>
Cc: Justin Stitt <justinstitt at google.com>
Cc: Miguel Ojeda <ojeda at kernel.org>
Cc: Marco Elver <elver at google.com>
Cc: Przemek Kitszel <przemyslaw.kitszel at intel.com>
Cc: Ramon de C Valle <rcvalle at google.com>
Cc: <llvm at lists.linux.dev>
---
include/linux/compiler-clang.h | 5 -----
include/linux/compiler_types.h | 4 +++-
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
index fa4ffe037bc7..7a4568e421dc 100644
--- a/include/linux/compiler-clang.h
+++ b/include/linux/compiler-clang.h
@@ -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.
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 16755431fc11..a910f9fa5341 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -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
--
2.34.1
More information about the linux-arm-kernel
mailing list