From: Stanciu, Adrian Date: Tue, 6 May 2025 17:24:36 +0000 (-0700) Subject: SHA512/x86_64: Fix SIGSEGV on $avx=0 path X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ce76714966227a2ba6a4ef80c2bd78bb36f6cffd;p=thirdparty%2Fopenssl.git SHA512/x86_64: Fix SIGSEGV on $avx=0 path 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 Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/27574) --- diff --git a/crypto/sha/asm/sha512-x86_64.pl b/crypto/sha/asm/sha512-x86_64.pl index 0dfbdfcf44e..a34ab420662 100755 --- a/crypto/sha/asm/sha512-x86_64.pl +++ b/crypto/sha/asm/sha512-x86_64.pl @@ -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