Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

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

authored by

Kees Cook and committed by
Peter Zijlstra
038c7dc6 894af4a1

+3 -6
-5
include/linux/compiler-clang.h
··· 96 96 # define __noscs __attribute__((__no_sanitize__("shadow-call-stack"))) 97 97 #endif 98 98 99 - #if __has_feature(kcfi) 100 - /* Disable CFI checking inside a function. */ 101 - #define __nocfi __attribute__((__no_sanitize__("kcfi"))) 102 - #endif 103 - 104 99 /* 105 100 * Turn individual warnings and errors on and off locally, depending 106 101 * on version.
+3 -1
include/linux/compiler_types.h
··· 432 432 # define __noscs 433 433 #endif 434 434 435 - #ifndef __nocfi 435 + #if defined(CONFIG_CFI_CLANG) 436 + # define __nocfi __attribute__((__no_sanitize__("kcfi"))) 437 + #else 436 438 # define __nocfi 437 439 #endif 438 440