Skip to content

Commit c50d328

Browse files
samitolvanenkees
authored andcommitted
arm64: Add types to indirect 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 SYM_TYPED_FUNC_START for the indirectly called functions, and ensure we emit `bti c` also with SYM_TYPED_FUNC_START. Signed-off-by: Sami Tolvanen <[email protected]> Reviewed-by: Kees Cook <[email protected]> Tested-by: Kees Cook <[email protected]> Tested-by: Nathan Chancellor <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 44f665b commit c50d328

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

arch/arm64/crypto/ghash-ce-core.S

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

88
#include <linux/linkage.h>
9+
#include <linux/cfi_types.h>
910
#include <asm/assembler.h>
1011

1112
SHASH .req v0
@@ -350,11 +351,11 @@ CPU_LE( rev64 T1.16b, T1.16b )
350351
* void pmull_ghash_update(int blocks, u64 dg[], const char *src,
351352
* struct ghash_key const *k, const char *head)
352353
*/
353-
SYM_FUNC_START(pmull_ghash_update_p64)
354+
SYM_TYPED_FUNC_START(pmull_ghash_update_p64)
354355
__pmull_ghash p64
355356
SYM_FUNC_END(pmull_ghash_update_p64)
356357

357-
SYM_FUNC_START(pmull_ghash_update_p8)
358+
SYM_TYPED_FUNC_START(pmull_ghash_update_p8)
358359
__pmull_ghash p8
359360
SYM_FUNC_END(pmull_ghash_update_p8)
360361

arch/arm64/crypto/sm3-ce-core.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include <linux/linkage.h>
9+
#include <linux/cfi_types.h>
910
#include <asm/assembler.h>
1011

1112
.irp b, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
@@ -73,7 +74,7 @@
7374
* int blocks)
7475
*/
7576
.text
76-
SYM_FUNC_START(sm3_ce_transform)
77+
SYM_TYPED_FUNC_START(sm3_ce_transform)
7778
/* load state */
7879
ld1 {v8.4s-v9.4s}, [x0]
7980
rev64 v8.4s, v8.4s

arch/arm64/include/asm/linkage.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,8 @@
3939
SYM_START(name, SYM_L_WEAK, SYM_A_NONE) \
4040
bti c ;
4141

42+
#define SYM_TYPED_FUNC_START(name) \
43+
SYM_TYPED_START(name, SYM_L_GLOBAL, SYM_A_ALIGN) \
44+
bti c ;
45+
4246
#endif

arch/arm64/kernel/cpu-reset.S

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
#include <linux/linkage.h>
11+
#include <linux/cfi_types.h>
1112
#include <asm/assembler.h>
1213
#include <asm/sysreg.h>
1314
#include <asm/virt.h>
@@ -28,7 +29,7 @@
2829
* branch to what would be the reset vector. It must be executed with the
2930
* flat identity mapping.
3031
*/
31-
SYM_CODE_START(cpu_soft_restart)
32+
SYM_TYPED_FUNC_START(cpu_soft_restart)
3233
mov_q x12, INIT_SCTLR_EL1_MMU_OFF
3334
pre_disable_mmu_workaround
3435
/*
@@ -47,6 +48,6 @@ SYM_CODE_START(cpu_soft_restart)
4748
mov x1, x3 // arg1
4849
mov x2, x4 // arg2
4950
br x8
50-
SYM_CODE_END(cpu_soft_restart)
51+
SYM_FUNC_END(cpu_soft_restart)
5152

5253
.popsection

arch/arm64/mm/proc.S

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/init.h>
1111
#include <linux/linkage.h>
1212
#include <linux/pgtable.h>
13+
#include <linux/cfi_types.h>
1314
#include <asm/assembler.h>
1415
#include <asm/asm-offsets.h>
1516
#include <asm/asm_pointer_auth.h>
@@ -185,7 +186,7 @@ SYM_FUNC_END(cpu_do_resume)
185186
* This is the low-level counterpart to cpu_replace_ttbr1, and should not be
186187
* called by anything else. It can only be executed from a TTBR0 mapping.
187188
*/
188-
SYM_FUNC_START(idmap_cpu_replace_ttbr1)
189+
SYM_TYPED_FUNC_START(idmap_cpu_replace_ttbr1)
189190
save_and_disable_daif flags=x2
190191

191192
__idmap_cpu_set_reserved_ttbr1 x1, x3
@@ -253,7 +254,7 @@ SYM_FUNC_END(idmap_cpu_replace_ttbr1)
253254
SYM_DATA(__idmap_kpti_flag, .long 1)
254255
.popsection
255256

256-
SYM_FUNC_START(idmap_kpti_install_ng_mappings)
257+
SYM_TYPED_FUNC_START(idmap_kpti_install_ng_mappings)
257258
cpu .req w0
258259
temp_pte .req x0
259260
num_cpus .req w1

0 commit comments

Comments
 (0)