Skip to content

Commit 5f59c68

Browse files
samitolvanenpalmer-dabbelt
authored andcommitted
riscv: Add types to indirectly called assembly functions
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>
1 parent 08d0ce3 commit 5f59c68

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

arch/riscv/kernel/mcount.S

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <linux/init.h>
55
#include <linux/linkage.h>
6+
#include <linux/cfi_types.h>
67
#include <asm/asm.h>
78
#include <asm/csr.h>
89
#include <asm/unistd.h>
@@ -47,13 +48,13 @@
4748
addi sp, sp, 4*SZREG
4849
.endm
4950

50-
ENTRY(ftrace_stub)
51+
SYM_TYPED_FUNC_START(ftrace_stub)
5152
#ifdef CONFIG_DYNAMIC_FTRACE
5253
.global MCOUNT_NAME
5354
.set MCOUNT_NAME, ftrace_stub
5455
#endif
5556
ret
56-
ENDPROC(ftrace_stub)
57+
SYM_FUNC_END(ftrace_stub)
5758

5859
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
5960
ENTRY(return_to_handler)

arch/riscv/kernel/suspend_entry.S

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
#include <linux/linkage.h>
8+
#include <linux/cfi_types.h>
89
#include <asm/asm.h>
910
#include <asm/asm-offsets.h>
1011
#include <asm/assembler.h>
@@ -58,7 +59,7 @@ ENTRY(__cpu_suspend_enter)
5859
ret
5960
END(__cpu_suspend_enter)
6061

61-
ENTRY(__cpu_resume_enter)
62+
SYM_TYPED_FUNC_START(__cpu_resume_enter)
6263
/* Load the global pointer */
6364
.option push
6465
.option norelax
@@ -94,4 +95,4 @@ ENTRY(__cpu_resume_enter)
9495

9596
/* Return to C code */
9697
ret
97-
END(__cpu_resume_enter)
98+
SYM_FUNC_END(__cpu_resume_enter)

0 commit comments

Comments
 (0)