[PATCH 3/5] lib/crypto: arm64/poly1305: Fix 32-bit length treated as 64-bit
Vladimir Kukharenko via B4 Relay
devnull+vladimir.genproof.com at kernel.org
Mon Oct 12 14:31:20 PDT 2026
From: Vladimir Kukharenko <vladimir at genproof.com>
The C code declares the length argument of poly1305_blocks_arm64() and
poly1305_blocks_neon() as u32, but the assembly, which comes from
OpenSSL/CRYPTOGAMS where the length is a size_t, reads it from the
64-bit register x2. The arm64 ABI leaves the upper 32 bits of a 32-bit
argument unspecified, and gcc and clang don't zero-extend it. In
practice the upper bits are zero in the current callers, so I don't
know of a failure.
Declare the length as size_t, as OpenSSL and the x86_64 code do, rather
than changing the imported assembly. The assembly also reads hibit from
x3, but the callers always pass the constant 0 or 1.
This has been the case since commit f569ca164751 ("crypto:
arm64/poly1305 - incorporate OpenSSL/CRYPTOGAMS NEON implementation").
Assisted-by: LLM
Signed-off-by: Vladimir Kukharenko <vladimir at genproof.com>
---
lib/crypto/arm64/poly1305.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/crypto/arm64/poly1305.h b/lib/crypto/arm64/poly1305.h
index 3d4bde857699..205a7b5fcf47 100644
--- a/lib/crypto/arm64/poly1305.h
+++ b/lib/crypto/arm64/poly1305.h
@@ -14,9 +14,9 @@
asmlinkage void poly1305_block_init(struct poly1305_block_state *state,
const u8 raw_key[POLY1305_BLOCK_SIZE]);
asmlinkage void poly1305_blocks_arm64(struct poly1305_block_state *state,
- const u8 *src, u32 len, u32 hibit);
+ const u8 *src, size_t len, u32 hibit);
asmlinkage void poly1305_blocks_neon(struct poly1305_block_state *state,
- const u8 *src, u32 len, u32 hibit);
+ const u8 *src, size_t len, u32 hibit);
asmlinkage void poly1305_emit(const struct poly1305_state *state,
u8 digest[POLY1305_DIGEST_SIZE],
const u32 nonce[4]);
--
2.43.0
More information about the linux-arm-kernel
mailing list