Commit 3ed7b4d6 authored by Josh Poimboeuf's avatar Josh Poimboeuf Committed by Herbert Xu

crypto: x86/des3_ede - Fix RBP usage

Using RBP as a temporary register breaks frame pointer convention and
breaks stack traces when unwinding from an interrupt in the crypto code.

Use RSI instead of RBP for RT1.  Since RSI is also used as a the 'dst'
function argument, it needs to be saved on the stack until the argument
is needed.
Reported-by: default avatarEric Biggers <ebiggers@google.com>
Reported-by: default avatarPeter Zijlstra <peterz@infradead.org>
Tested-by: default avatarEric Biggers <ebiggers@google.com>
Acked-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent c66cc3be
...@@ -64,12 +64,12 @@ ...@@ -64,12 +64,12 @@
#define RW2bh %ch #define RW2bh %ch
#define RT0 %r15 #define RT0 %r15
#define RT1 %rbp #define RT1 %rsi
#define RT2 %r14 #define RT2 %r14
#define RT3 %rdx #define RT3 %rdx
#define RT0d %r15d #define RT0d %r15d
#define RT1d %ebp #define RT1d %esi
#define RT2d %r14d #define RT2d %r14d
#define RT3d %edx #define RT3d %edx
...@@ -177,13 +177,14 @@ ENTRY(des3_ede_x86_64_crypt_blk) ...@@ -177,13 +177,14 @@ ENTRY(des3_ede_x86_64_crypt_blk)
* %rsi: dst * %rsi: dst
* %rdx: src * %rdx: src
*/ */
pushq %rbp;
pushq %rbx; pushq %rbx;
pushq %r12; pushq %r12;
pushq %r13; pushq %r13;
pushq %r14; pushq %r14;
pushq %r15; pushq %r15;
pushq %rsi; /* dst */
read_block(%rdx, RL0, RR0); read_block(%rdx, RL0, RR0);
initial_permutation(RL0, RR0); initial_permutation(RL0, RR0);
...@@ -241,6 +242,8 @@ ENTRY(des3_ede_x86_64_crypt_blk) ...@@ -241,6 +242,8 @@ ENTRY(des3_ede_x86_64_crypt_blk)
round1(32+15, RL0, RR0, dummy2); round1(32+15, RL0, RR0, dummy2);
final_permutation(RR0, RL0); final_permutation(RR0, RL0);
popq %rsi /* dst */
write_block(%rsi, RR0, RL0); write_block(%rsi, RR0, RL0);
popq %r15; popq %r15;
...@@ -248,7 +251,6 @@ ENTRY(des3_ede_x86_64_crypt_blk) ...@@ -248,7 +251,6 @@ ENTRY(des3_ede_x86_64_crypt_blk)
popq %r13; popq %r13;
popq %r12; popq %r12;
popq %rbx; popq %rbx;
popq %rbp;
ret; ret;
ENDPROC(des3_ede_x86_64_crypt_blk) ENDPROC(des3_ede_x86_64_crypt_blk)
...@@ -432,13 +434,14 @@ ENTRY(des3_ede_x86_64_crypt_blk_3way) ...@@ -432,13 +434,14 @@ ENTRY(des3_ede_x86_64_crypt_blk_3way)
* %rdx: src (3 blocks) * %rdx: src (3 blocks)
*/ */
pushq %rbp;
pushq %rbx; pushq %rbx;
pushq %r12; pushq %r12;
pushq %r13; pushq %r13;
pushq %r14; pushq %r14;
pushq %r15; pushq %r15;
pushq %rsi /* dst */
/* load input */ /* load input */
movl 0 * 4(%rdx), RL0d; movl 0 * 4(%rdx), RL0d;
movl 1 * 4(%rdx), RR0d; movl 1 * 4(%rdx), RR0d;
...@@ -520,6 +523,7 @@ ENTRY(des3_ede_x86_64_crypt_blk_3way) ...@@ -520,6 +523,7 @@ ENTRY(des3_ede_x86_64_crypt_blk_3way)
bswapl RR2d; bswapl RR2d;
bswapl RL2d; bswapl RL2d;
popq %rsi /* dst */
movl RR0d, 0 * 4(%rsi); movl RR0d, 0 * 4(%rsi);
movl RL0d, 1 * 4(%rsi); movl RL0d, 1 * 4(%rsi);
movl RR1d, 2 * 4(%rsi); movl RR1d, 2 * 4(%rsi);
...@@ -532,7 +536,6 @@ ENTRY(des3_ede_x86_64_crypt_blk_3way) ...@@ -532,7 +536,6 @@ ENTRY(des3_ede_x86_64_crypt_blk_3way)
popq %r13; popq %r13;
popq %r12; popq %r12;
popq %rbx; popq %rbx;
popq %rbp;
ret; ret;
ENDPROC(des3_ede_x86_64_crypt_blk_3way) ENDPROC(des3_ede_x86_64_crypt_blk_3way)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment