@@ -94,4 +94,6 @@
#if CONFIG_CFI_CLANG
/* Disable CFI checking inside a function. */
#define __nocfi __attribute__((__no_sanitize__("kcfi")))
+/* Disable CFI checking for the indirect call expression. */
+#define cfi_unchecked(expr) __builtin_kcfi_call_unchecked(expr)
#endif
@@ -263,6 +263,10 @@ struct ftrace_likely_data {
# define __nocfi
#endif
+#ifndef cfi_unchecked
+# define cfi_unchecked(expr) expr
+#endif
+
/*
* Any place that could be marked with the "alloc_size" attribute is also
* a place to be marked with the "malloc" attribute. Do this as part of the
The cfi_unchecked macro allows CFI checking to be disabled for a specific indirect call expression, by passing the expression as an argument to the macro. For example: static void call(void (*f)(void)) { cfi_unchecked(f()); } Signed-off-by: Sami Tolvanen <samitolvanen@google.com> --- include/linux/compiler-clang.h | 2 ++ include/linux/compiler_types.h | 4 ++++ 2 files changed, 6 insertions(+)