Skip to content

Commit

Permalink
SPARC assembly: Don't file aes-cbc on T4 with small sizes.
Browse files Browse the repository at this point in the history
The "openssl speed -testmode -seconds 1 -bytes 1 aes-128-cbc" test
revealed that the assembly code is crashing if length is less than 16.
The code shifts the provided length by 4 and than subtracts one until
the length hits zero. If it was already zero then it underflows the
counter and continues until it segfaults on reading or writing.

Replace the check against 0 with less than 15.

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
  • Loading branch information
sebastianas committed Oct 8, 2024
1 parent 6f08353 commit 0904552
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crypto/perlasm/sparcv9_modes.pl
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ sub alg_cbc_encrypt_implement {
.align 32
${alg}${bits}_t4_cbc_encrypt:
save %sp, -$::frame, %sp
cmp $len, 0
be,pn $::size_t_cc, .L${bits}_cbc_enc_abort
cmp $len, 15
bleu,pn $::size_t_cc, .L${bits}_cbc_enc_abort
srln $len, 0, $len ! needed on v8+, "nop" on v9
sub $inp, $out, $blk_init ! $inp!=$out
___
Expand Down Expand Up @@ -264,8 +264,8 @@ sub alg_cbc_decrypt_implement {
.align 32
${alg}${bits}_t4_cbc_decrypt:
save %sp, -$::frame, %sp
cmp $len, 0
be,pn $::size_t_cc, .L${bits}_cbc_dec_abort
cmp $len, 15
bleu,pn $::size_t_cc, .L${bits}_cbc_dec_abort
srln $len, 0, $len ! needed on v8+, "nop" on v9
sub $inp, $out, $blk_init ! $inp!=$out
___
Expand Down

0 comments on commit 0904552

Please sign in to comment.