lkml.org 
[lkml]   [2022]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[RFC PATCH 13/21] cfi: Add the cfi_unchecked macro
From
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(+)

diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
index c4ff42859077..0d6a0e7e36dc 100644
--- a/include/linux/compiler-clang.h
+++ b/include/linux/compiler-clang.h
@@ -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
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index bdd2526af46a..41f547fe9724 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -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
--
2.36.0.464.gb9c8b46e94-goog
\
 
 \ /
  Last update: 2022-04-29 22:39    [W:0.406 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site