Skip to content

Commit e73f02c

Browse files
samitolvanenwilldeacon
authored andcommitted
arm64: efi: Restore register x18 if it was corrupted
If we detect a corrupted x18, restore the register before jumping back to potentially SCS instrumented code. This is safe, because the wrapper is called with preemption disabled and a separate shadow stack is used for interrupt handling. Signed-off-by: Sami Tolvanen <[email protected]> Reviewed-by: Kees Cook <[email protected]> Acked-by: Will Deacon <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent 6d37d81 commit e73f02c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

arch/arm64/kernel/efi-rt-wrapper.S

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,14 @@ ENTRY(__efi_rt_asm_wrapper)
3434
ldp x29, x30, [sp], #32
3535
b.ne 0f
3636
ret
37-
0: b efi_handle_corrupted_x18 // tail call
37+
0:
38+
/*
39+
* With CONFIG_SHADOW_CALL_STACK, the kernel uses x18 to store a
40+
* shadow stack pointer, which we need to restore before returning to
41+
* potentially instrumented code. This is safe because the wrapper is
42+
* called with preemption disabled and a separate shadow stack is used
43+
* for interrupts.
44+
*/
45+
mov x18, x2
46+
b efi_handle_corrupted_x18 // tail call
3847
ENDPROC(__efi_rt_asm_wrapper)

0 commit comments

Comments
 (0)