From: Vladimir Kukharenko via B4 Relay <devnull+vladimir.genproof.com@kernel.org>
To: Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
Eric Biggers <ebiggers@kernel.org>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
Ard Biesheuvel <ardb@kernel.org>
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-riscv@lists.infradead.org, linux-mips@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexandre Ghiti <alex@ghiti.fr>,
Vladimir Kukharenko <vladimir@genproof.com>
Subject: [PATCH 3/5] lib/crypto: arm64/poly1305: Fix 32-bit length treated as 64-bit
Date: Mon, 12 Oct 2026 21:31:20 +0000 [thread overview]
Message-ID: <20261012-libcrypto-4gib-lengths-v1-3-ea566c129a2e@genproof.com> (raw)
In-Reply-To: <20261012-libcrypto-4gib-lengths-v1-0-ea566c129a2e@genproof.com>
From: Vladimir Kukharenko <vladimir@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@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
next prev parent reply other threads:[~2026-10-12 21:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 21:31 [PATCH 0/5] lib/crypto: Handle large lengths in poly1305 and chacha20poly1305 Vladimir Kukharenko via B4 Relay
2026-10-12 21:31 ` [PATCH 1/5] lib/crypto: riscv/poly1305: Fix 32-bit length treated as 64-bit Vladimir Kukharenko via B4 Relay
2026-10-12 21:31 ` [PATCH 2/5] lib/crypto: mips/poly1305: " Vladimir Kukharenko via B4 Relay
2026-10-12 21:31 ` Vladimir Kukharenko via B4 Relay [this message]
2026-10-12 21:31 ` [PATCH 4/5] lib/crypto: poly1305: Take a size_t length in poly1305_update() Vladimir Kukharenko via B4 Relay
2026-10-12 21:31 ` [PATCH 5/5] lib/crypto: chacha: Take a size_t length in chacha_crypt() Vladimir Kukharenko via B4 Relay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261012-libcrypto-4gib-lengths-v1-3-ea566c129a2e@genproof.com \
--to=devnull+vladimir.genproof.com@kernel.org \
--cc=Jason@zx2c4.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=ardb@kernel.org \
--cc=davem@davemloft.net \
--cc=ebiggers@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=vladimir@genproof.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®