]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
SHA512/x86_64: Fix SIGSEGV on $avx=0 path
authorStanciu, Adrian <adrian.stanciu@intel.com>
Tue, 6 May 2025 17:24:36 +0000 (10:24 -0700)
committerPauli <ppzgs1@gmail.com>
Thu, 8 May 2025 23:33:37 +0000 (09:33 +1000)
Fixes #27555

When $avx>1, codegen is:
    lea OPENSSL_ia32cap_P(%rip),%r10
    mov 0(%r10),%r9
    mov 8(%r10),%r11d
    mov 20(%r10),%r10d

When $avx is true, codegen was:
    lea OPENSSL_ia32cap_P(%rip),%r10
    mov 0(%r10),%r9
    mov 8(%r10),%r11d
    mov 20(%r10),%r10d    # not used by dispatcher

When $avx=0, codegen was:
    mov 20(%r10),%r10d    # %r10 not initalized, causing SIGSEGV

After fix, `mov 20(%r10),%r10d` is only included when $avx>1

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/27574)

crypto/sha/asm/sha512-x86_64.pl

index 0dfbdfcf44e844ee0ebe3d56bdb2cc39e3522fef..a34ab420662ecabb71c4b59e62c25d364f0f797c 100755 (executable)
@@ -284,7 +284,7 @@ $code.=<<___ if ($SZ==4 || $avx);
     mov 0(%r10),%r9
     mov 8(%r10),%r11d
 ___
-$code.=<<___ if ($SZ==8);
+$code.=<<___ if ($SZ==8 && $avx>1);
     mov 20(%r10),%r10d
 ___
 if ($SZ==4) {
@@ -306,12 +306,8 @@ if ($avx>1) { # $SZ==8 && $avx>1
 $code.=<<___;
     test \$`1<<5`,%r11d             # check for AVX2
     jz   .Lavx_dispatch
-___
-$code.=<<___ if ($SZ==8);
     test \$`1<<0`,%r10d             # AVX2 confirmed, check SHA512
     jnz  .Lsha512ext_shortcut
-___
-$code.=<<___;
     and \$`1<<8|1<<3`,%r11d         # AVX2 confirmed, check BMI2+BMI1
     cmp \$`1<<8|1<<3`,%r11d
     je  .Lavx2_shortcut