linux/arch/s390/crypto
Eric Biggers 56ea774604 crypto: s390/sha - Fix uninitialized variable in SHA-1 and SHA-2
commit 6827938026 upstream.

Commit 88c02b3f79 ("s390/sha3: Support sha3 performance enhancements")
added the field s390_sha_ctx::first_message_part and made it be used by
s390_sha_update() (now s390_sha_update_blocks()).  At the time,
s390_sha_update() was used by all the s390 SHA-1, SHA-2, and SHA-3
algorithms.  However, only the initialization functions for SHA-3 were
updated, leaving SHA-1 and SHA-2 using first_message_part uninitialized.

This could cause e.g. the function code CPACF_KIMD_SHA_512 |
CPACF_KIMD_NIP to be used instead of just CPACF_KIMD_SHA_512.  This
apparently was harmless, as the SHA-1 and SHA-2 function codes ignore
CPACF_KIMD_NIP; it is recognized only by the SHA-3 function codes
(https://lore.kernel.org/r/73477fe9-a1dc-4e38-98a6-eba9921e8afa@linux.ibm.com/).
Therefore, this bug was found only when first_message_part was later
converted to a boolean and UBSAN detected its uninitialized use.
Regardless, let's fix this by just initializing to zero.

Note: in 6.16, we need to patch SHA-1, SHA-384, and SHA-512.  In 6.15
and earlier, we'll also need to patch SHA-224 and SHA-256, as they
hadn't yet been librarified (which incidentally fixed this bug).

Fixes: 88c02b3f79 ("s390/sha3: Support sha3 performance enhancements")
Cc: stable@vger.kernel.org
Reported-by: Ingo Franzki <ifranzki@linux.ibm.com>
Closes: https://lore.kernel.org/r/12740696-595c-4604-873e-aefe8b405fbf@linux.ibm.com
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Link: https://lore.kernel.org/r/20250703172316.7914-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2025-07-17 18:37:01 +02:00
..
aes_s390.c s390/crypto: Add hardware acceleration for full AES-XTS mode 2024-08-29 22:56:33 +02:00
arch_random.c s390/archrandom: add missing header include 2023-01-10 14:39:08 +01:00
chacha-glue.c s390/fpu: decrease stack usage for some cases 2024-02-16 14:30:16 +01:00
chacha-s390.h s390/crypto: add SIMD implementation for ChaCha20 2021-12-06 14:42:24 +01:00
chacha-s390.S s390/fpu: move, rename, and merge header files 2024-02-16 14:30:14 +01:00
crc32-vx.c s390/crc32: Add missing MODULE_DESCRIPTION() macro 2024-06-28 14:52:30 +02:00
crc32-vx.h s390/crc32le: convert to C 2024-02-16 14:30:18 +01:00
crc32be-vx.c s390/crc32be: convert to C 2024-02-16 14:30:18 +01:00
crc32le-vx.c s390/crc32le: convert to C 2024-02-16 14:30:18 +01:00
des_s390.c s390/cpufeature: rework to allow more than only hwcap bits 2022-07-19 16:18:49 +02:00
ghash_s390.c s390/cpufeature: rework to allow more than only hwcap bits 2022-07-19 16:18:49 +02:00
hmac_s390.c s390/crypto: Add hardware acceleration for HMAC modes 2024-08-29 22:56:33 +02:00
Kconfig crypto: lib/Kconfig - Hide arch options from user 2025-05-02 07:59:32 +02:00
Makefile s390/crypto: Add hardware acceleration for HMAC modes 2024-08-29 22:56:33 +02:00
paes_s390.c This push fixes the following issues: 2024-09-24 10:46:54 -07:00
prng.c s390/cpufeature: rework to allow more than only hwcap bits 2022-07-19 16:18:49 +02:00
sha.h s390/sha3: Support sha3 performance enhancements 2024-08-29 22:56:34 +02:00
sha1_s390.c crypto: s390/sha - Fix uninitialized variable in SHA-1 and SHA-2 2025-07-17 18:37:01 +02:00
sha3_256_s390.c s390/sha3: Fix SHA3 selftests failures 2024-09-05 15:17:23 +02:00
sha3_512_s390.c s390/sha3: Fix SHA3 selftests failures 2024-09-05 15:17:23 +02:00
sha256_s390.c crypto: s390/sha - Fix uninitialized variable in SHA-1 and SHA-2 2025-07-17 18:37:01 +02:00
sha512_s390.c crypto: s390/sha - Fix uninitialized variable in SHA-1 and SHA-2 2025-07-17 18:37:01 +02:00
sha_common.c s390/sha3: Fix SHA3 selftests failures 2024-09-05 15:17:23 +02:00