mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
lib/crypto: x86/sha1: Follow the normal %rbp convention
Some of the SHA-1 assembly functions push callee-save GPRs to the stack
*before* they set up the frame pointer (%rbp). (They are leaf
functions, but they need to set up a frame pointer anyway because they
allocate a 16- or 32-byte-aligned buffer on the stack.)
As a result, during these functions, 8(%rbp) doesn't contain a return
address like it is supposed to.
This differs from the convention used by C code, and it interferes with
the frame pointer unwinder (CONFIG_UNWINDER_FRAME_POINTER=y).
Specifically, if a call trace is dumped in these functions, then all
entries are populated purely from the fallback scan of the entire stack:
RIP: 0010:sha1_transform_avx2+0x1921/0x1ea0
[...]
Call Trace:
<TASK>
? sha1_transform_avx+0x2a9/0xc90
? sha1_blocks_avx2+0x78/0x140
? kernel_fpu_end+0x2d/0x40
? sha1_blocks_avx2+0x52/0x140
? sha1_update+0x77/0x220
[...]
? do_syscall_64+0x6f/0x3e0
With this fix to follow the normal %rbp convention, the call trace is
generated reliably:
RIP: 0010:sha1_transform_avx2+0x66e/0x1ea0
[...]
Call Trace:
<TASK>
sha1_blocks_avx2+0x78/0x140
sha1_update+0x77/0x220
[...]
do_syscall_64+0x6f/0x3e0
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://patch.msgid.link/20261011134843.166585-2-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
This commit is contained in:
parent
6a50ce0af5
commit
0b173877fb
|
|
@ -622,6 +622,9 @@
|
|||
.macro SHA1_VECTOR_ASM name
|
||||
SYM_FUNC_START(\name)
|
||||
|
||||
push %rbp
|
||||
mov %rsp, %rbp
|
||||
|
||||
push %rbx
|
||||
push %r12
|
||||
push %r13
|
||||
|
|
@ -631,8 +634,6 @@
|
|||
RESERVE_STACK = (W_SIZE*4 + 8+24)
|
||||
|
||||
/* Align stack */
|
||||
push %rbp
|
||||
mov %rsp, %rbp
|
||||
and $~(0x20-1), %rsp
|
||||
sub $RESERVE_STACK, %rsp
|
||||
|
||||
|
|
@ -651,14 +652,13 @@
|
|||
|
||||
avx2_zeroupper
|
||||
|
||||
mov %rbp, %rsp
|
||||
pop %rbp
|
||||
|
||||
lea -40(%rbp), %rsp
|
||||
pop %r15
|
||||
pop %r14
|
||||
pop %r13
|
||||
pop %r12
|
||||
pop %rbx
|
||||
pop %rbp
|
||||
|
||||
RET
|
||||
|
||||
|
|
|
|||
|
|
@ -69,11 +69,12 @@
|
|||
.macro SHA1_VECTOR_ASM name
|
||||
SYM_FUNC_START(\name)
|
||||
|
||||
push %rbx
|
||||
push %r12
|
||||
push %rbp
|
||||
mov %rsp, %rbp
|
||||
|
||||
push %rbx
|
||||
push %r12
|
||||
|
||||
sub $64, %rsp # allocate workspace
|
||||
and $~15, %rsp # align stack
|
||||
|
||||
|
|
@ -95,10 +96,10 @@
|
|||
xor %eax, %eax
|
||||
rep stosq
|
||||
|
||||
mov %rbp, %rsp # deallocate workspace
|
||||
pop %rbp
|
||||
lea -16(%rbp), %rsp # deallocate workspace
|
||||
pop %r12
|
||||
pop %rbx
|
||||
pop %rbp
|
||||
RET
|
||||
|
||||
SYM_FUNC_END(\name)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user