lib/crypto: arm64/poly1305: Fix register corruption in no-SIMD contexts
authorEric Biggers <ebiggers@kernel.org>
Sun, 6 Jul 2025 23:10:58 +0000 (16:10 -0700)
committerEric Biggers <ebiggers@kernel.org>
Fri, 11 Jul 2025 21:29:42 +0000 (14:29 -0700)
commiteec76ea5a7213c48529a46eed1b343e5cee3aaab
treec3f055d15bcea9add6a350a8bc20adb71d106aec
parent52c3e242f4d0043186b70d65460ba1767f27494a
lib/crypto: arm64/poly1305: Fix register corruption in no-SIMD contexts

Restore the SIMD usability check that was removed by commit a59e5468a921
("crypto: arm64/poly1305 - Add block-only interface").

This safety check is cheap and is well worth eliminating a footgun.
While the Poly1305 functions should not be called when SIMD registers
are unusable, if they are anyway, they should just do the right thing
instead of corrupting random tasks' registers and/or computing incorrect
MACs.  Fixing this is also needed for poly1305_kunit to pass.

Just use may_use_simd() instead of the original crypto_simd_usable(),
since poly1305_kunit won't rely on crypto_simd_disabled_for_test.

Fixes: a59e5468a921 ("crypto: arm64/poly1305 - Add block-only interface")
Cc: stable@vger.kernel.org
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20250706231100.176113-4-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
lib/crypto/arm64/poly1305-glue.c