Skip to content

Commit 2198d07

Browse files
ardbiesheuvelctmarinas
authored andcommitted
arm64: Always load shadow stack pointer directly from the task struct
All occurrences of the scs_load macro load the value of the shadow call stack pointer from the task which is current at that point. So instead of taking a task struct register argument in the scs_load macro to specify the task struct to load from, let's always reference the current task directly. This should make it much harder to exploit any instruction sequences reloading the shadow call stack pointer register from memory. Signed-off-by: Ard Biesheuvel <[email protected]> Acked-by: Mark Rutland <[email protected]> Reviewed-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent b7bfaa7 commit 2198d07

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

arch/arm64/include/asm/scs.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010
#ifdef CONFIG_SHADOW_CALL_STACK
1111
scs_sp .req x18
1212

13-
.macro scs_load tsk
14-
ldr scs_sp, [\tsk, #TSK_TI_SCS_SP]
13+
.macro scs_load_current
14+
get_current_task scs_sp
15+
ldr scs_sp, [scs_sp, #TSK_TI_SCS_SP]
1516
.endm
1617

1718
.macro scs_save tsk
1819
str scs_sp, [\tsk, #TSK_TI_SCS_SP]
1920
.endm
2021
#else
21-
.macro scs_load tsk
22+
.macro scs_load_current
2223
.endm
2324

2425
.macro scs_save tsk

arch/arm64/kernel/entry.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ alternative_if ARM64_HAS_ADDRESS_AUTH
275275
alternative_else_nop_endif
276276
1:
277277

278-
scs_load tsk
278+
scs_load_current
279279
.else
280280
add x21, sp, #PT_REGS_SIZE
281281
get_current_task tsk
@@ -848,7 +848,7 @@ SYM_FUNC_START(cpu_switch_to)
848848
msr sp_el0, x1
849849
ptrauth_keys_install_kernel x1, x8, x9, x10
850850
scs_save x0
851-
scs_load x1
851+
scs_load_current
852852
ret
853853
SYM_FUNC_END(cpu_switch_to)
854854
NOKPROBE(cpu_switch_to)

arch/arm64/kernel/head.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ SYM_FUNC_END(create_kernel_mapping)
404404
stp xzr, xzr, [sp, #S_STACKFRAME]
405405
add x29, sp, #S_STACKFRAME
406406

407-
scs_load \tsk
407+
scs_load_current
408408

409409
adr_l \tmp1, __per_cpu_offset
410410
ldr w\tmp2, [\tsk, #TSK_TI_CPU]

0 commit comments

Comments
 (0)