Re: [PATCH] crypto: lib/sha256 - Disable SIMD

Borislav Petkov
2025-05-16T12:27:35Z

On Fri, May 16, 2025 at 07:48:52PM +0800, Herbert Xu wrote:
> On Fri, May 16, 2025 at 07:34:06PM +0800, Herbert Xu wrote:
> >
> > So what's happened is that previously if you call sha256_update
> > from lib/crypto it would only use the generic C code to perform
> > the operation.
> >
> > This has now been changed to automatically use SIMD instructions
> > which obviously blew up in your case.
>
> In the interim you can go back to the old ways and disable SIMD
> for lib/crypto sha256 with this patch:
>
> ---8<---
> Disable SIMD usage in lib/crypto sha256 as it is causing crashes.
>
> Reported-by: Borislav Petkov <bp@alien8.de>

Please make that

Reported-by: Ayush Jain <Ayush.Jain3@amd.com>

I'm just the messenger.

> Fixes: 950e5c84118c ("crypto: sha256 - support arch-optimized lib and expose through shash")
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
>
> diff --git a/include/crypto/internal/sha2.h b/include/crypto/internal/sha2.h
> index b9bccd3ff57f..e1b0308c0539 100644
> --- a/include/crypto/internal/sha2.h
> +++ b/include/crypto/internal/sha2.h
> @@ -32,7 +32,7 @@ static inline void sha256_choose_blocks(
> if (!IS_ENABLED(CONFIG_CRYPTO_ARCH_HAVE_LIB_SHA256) || force_generic)
> sha256_blocks_generic(state, data, nblocks);
> else if (IS_ENABLED(CONFIG_CRYPTO_ARCH_HAVE_LIB_SHA256_SIMD) &&
> - (force_simd || crypto_simd_usable()))
> + force_simd)
> sha256_blocks_simd(state, data, nblocks);
> else
> sha256_blocks_arch(state, data, nblocks);
> --

If you end up doing this, that fixes it, obviously:

Tested-by: Ayush Jain <Ayush.Jain3@amd.com>

Thx.

--
Regards/Gruss,
Boris.