[lkml]   [2021]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH v5 03/15] linkage: Add DECLARE_NOT_CALLED_FROM_C
The kernel has several assembly functions, which are not directly
callable from C but need to be referred to from C code. This change adds
the DECLARE_NOT_CALLED_FROM_C macro, which allows us to declare these
symbols using an opaque type, which makes misuse harder, and avoids the
need to annotate references to the functions for Clang's Control-Flow
Integrity (CFI).

Suggested-by: Andy Lutomirski <>
Suggested-by: Steven Rostedt <>
Signed-off-by: Sami Tolvanen <>
Tested-by: Nick Desaulniers <>
Tested-by: Sedat Dilek <>
include/linux/linkage.h | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/include/linux/linkage.h b/include/linux/linkage.h
index dbf8506decca..f982d5f550ac 100644
--- a/include/linux/linkage.h
+++ b/include/linux/linkage.h
@@ -48,6 +48,19 @@
#define __PAGE_ALIGNED_DATA .section ".data..page_aligned", "aw"
#define __PAGE_ALIGNED_BSS .section ".bss..page_aligned", "aw"

+ * Declares a function not callable from C using an opaque type. Defined as
+ * an array to allow the address of the symbol to be taken without '&'.
+ */
+ extern const u8 sym[]
+#ifndef __ASSEMBLY__
+typedef const u8 *asm_func_ptr;
* This is used by architectures to keep arguments on the stack
* untouched by the compiler by keeping them live until the end.
 \ /
  Last update: 2021-10-13 20:18    [W:0.291 / U:2.372 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site