riscv: Add types to indirectly called assembly functions
authorSami Tolvanen <samitolvanen@google.com>
Mon, 10 Jul 2023 18:35:47 +0000 (18:35 +0000)
committerPalmer Dabbelt <palmer@rivosinc.com>
Wed, 23 Aug 2023 21:16:37 +0000 (14:16 -0700)
With CONFIG_CFI_CLANG, assembly functions indirectly called
from C code must be annotated with type identifiers to pass CFI
checking. Use the SYM_TYPED_START macro to add types to the
relevant functions.

Reviewed-by: Kees Cook <keescook@chromium.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Link: https://lore.kernel.org/r/20230710183544.999540-10-samitolvanen@google.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/kernel/mcount.S
arch/riscv/kernel/suspend_entry.S

index 8a6e5a9e842a68bf056ed30738defd9b48f10921..6c9469050f4c0c8cbaa8b2a59775949969ac5036 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <linux/init.h>
 #include <linux/linkage.h>
+#include <linux/cfi_types.h>
 #include <asm/asm.h>
 #include <asm/csr.h>
 #include <asm/unistd.h>
        addi    sp, sp, 4*SZREG
        .endm
 
-ENTRY(ftrace_stub)
+SYM_TYPED_FUNC_START(ftrace_stub)
 #ifdef CONFIG_DYNAMIC_FTRACE
        .global MCOUNT_NAME
        .set    MCOUNT_NAME, ftrace_stub
 #endif
        ret
-ENDPROC(ftrace_stub)
+SYM_FUNC_END(ftrace_stub)
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 ENTRY(return_to_handler)
index 12b52afe09a421c2340065ff7612debe86a4c3a5..f7960c7c5f9e25081424f3edbe526896c1692303 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 #include <linux/linkage.h>
+#include <linux/cfi_types.h>
 #include <asm/asm.h>
 #include <asm/asm-offsets.h>
 #include <asm/assembler.h>
@@ -58,7 +59,7 @@ ENTRY(__cpu_suspend_enter)
        ret
 END(__cpu_suspend_enter)
 
-ENTRY(__cpu_resume_enter)
+SYM_TYPED_FUNC_START(__cpu_resume_enter)
        /* Load the global pointer */
        .option push
        .option norelax
@@ -94,4 +95,4 @@ ENTRY(__cpu_resume_enter)
 
        /* Return to C code */
        ret
-END(__cpu_resume_enter)
+SYM_FUNC_END(__cpu_resume_enter)