Skip to content

Commit 519a0d7

Browse files
ardbiesheuvelherbertx
authored andcommitted
crypto: arm64/poly1305-neon - reorder PAC authentication with SP update
PAC pointer authentication signs the return address against the value of the stack pointer, to prevent stack overrun exploits from corrupting the control flow. However, this requires that the AUTIASP is issued with SP holding the same value as it held when the PAC value was generated. The Poly1305 NEON code got this wrong, resulting in crashes on PAC capable hardware. Fixes: f569ca1 ("crypto: arm64/poly1305 - incorporate OpenSSL/CRYPTOGAMS ...") Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 92eb6c3 commit 519a0d7

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎arch/arm64/crypto/poly1305-armv8.pl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,6 @@
840840
ldp d14,d15,[sp,#64]
841841
addp $ACC2,$ACC2,$ACC2
842842
ldr x30,[sp,#8]
843-
.inst 0xd50323bf // autiasp
844843
845844
////////////////////////////////////////////////////////////////
846845
// lazy reduction, but without narrowing
@@ -882,6 +881,7 @@
882881
str x4,[$ctx,#8] // set is_base2_26
883882
884883
ldr x29,[sp],#80
884+
.inst 0xd50323bf // autiasp
885885
ret
886886
.size poly1305_blocks_neon,.-poly1305_blocks_neon
887887

‎arch/arm64/crypto/poly1305-core.S_shipped‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,6 @@ poly1305_blocks_neon:
779779
ldp d14,d15,[sp,#64]
780780
addp v21.2d,v21.2d,v21.2d
781781
ldr x30,[sp,#8]
782-
.inst 0xd50323bf // autiasp
783782

784783
////////////////////////////////////////////////////////////////
785784
// lazy reduction, but without narrowing
@@ -821,6 +820,7 @@ poly1305_blocks_neon:
821820
str x4,[x0,#8] // set is_base2_26
822821

823822
ldr x29,[sp],#80
823+
.inst 0xd50323bf // autiasp
824824
ret
825825
.size poly1305_blocks_neon,.-poly1305_blocks_neon
826826

0 commit comments

Comments
 (0)