From: Eric Biggers <ebiggers@kernel.org>
To: linux-crypto@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Ard Biesheuvel <ardb@kernel.org>,
"Jason A . Donenfeld" <Jason@zx2c4.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
linux-hardening@vger.kernel.org, Kees Cook <kees@kernel.org>,
Eric Biggers <ebiggers@kernel.org>
Subject: [PATCH 1/6] lib/crypto: chacha: Add at_least decoration to fixed-size array params
Date: Sat, 22 Nov 2025 11:42:01 -0800 [thread overview]
Message-ID: <20251122194206.31822-2-ebiggers@kernel.org> (raw)
In-Reply-To: <20251122194206.31822-1-ebiggers@kernel.org>
Add the at_least (i.e. 'static') decoration to the fixed-size array
parameters of the chacha library functions. This causes clang to warn
when a too-small array of known size is passed.
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
include/crypto/chacha.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/crypto/chacha.h b/include/crypto/chacha.h
index 38e26dff27b0..1cc301a48469 100644
--- a/include/crypto/chacha.h
+++ b/include/crypto/chacha.h
@@ -36,22 +36,22 @@
struct chacha_state {
u32 x[CHACHA_STATE_WORDS];
};
void chacha_block_generic(struct chacha_state *state,
- u8 out[CHACHA_BLOCK_SIZE], int nrounds);
+ u8 out[at_least CHACHA_BLOCK_SIZE], int nrounds);
static inline void chacha20_block(struct chacha_state *state,
- u8 out[CHACHA_BLOCK_SIZE])
+ u8 out[at_least CHACHA_BLOCK_SIZE])
{
chacha_block_generic(state, out, 20);
}
void hchacha_block_generic(const struct chacha_state *state,
- u32 out[HCHACHA_OUT_WORDS], int nrounds);
+ u32 out[at_least HCHACHA_OUT_WORDS], int nrounds);
void hchacha_block(const struct chacha_state *state,
- u32 out[HCHACHA_OUT_WORDS], int nrounds);
+ u32 out[at_least HCHACHA_OUT_WORDS], int nrounds);
enum chacha_constants { /* expand 32-byte k */
CHACHA_CONSTANT_EXPA = 0x61707865U,
CHACHA_CONSTANT_ND_3 = 0x3320646eU,
CHACHA_CONSTANT_2_BY = 0x79622d32U,
@@ -65,12 +65,12 @@ static inline void chacha_init_consts(struct chacha_state *state)
state->x[2] = CHACHA_CONSTANT_2_BY;
state->x[3] = CHACHA_CONSTANT_TE_K;
}
static inline void chacha_init(struct chacha_state *state,
- const u32 key[CHACHA_KEY_WORDS],
- const u8 iv[CHACHA_IV_SIZE])
+ const u32 key[at_least CHACHA_KEY_WORDS],
+ const u8 iv[at_least CHACHA_IV_SIZE])
{
chacha_init_consts(state);
state->x[4] = key[0];
state->x[5] = key[1];
state->x[6] = key[2];
--
2.51.2
next prev parent reply other threads:[~2025-11-22 19:42 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-22 19:42 [PATCH 0/6] lib/crypto: More at_least decorations Eric Biggers
2025-11-22 19:42 ` Eric Biggers [this message]
2025-11-22 19:42 ` [PATCH 2/6] lib/crypto: curve25519: Add at_least decoration to fixed-size array params Eric Biggers
2025-11-22 19:42 ` [PATCH 3/6] lib/crypto: md5: " Eric Biggers
2025-11-22 19:42 ` [PATCH 4/6] lib/crypto: poly1305: " Eric Biggers
2025-11-22 19:42 ` [PATCH 5/6] lib/crypto: sha1: " Eric Biggers
2025-11-22 19:42 ` [PATCH 6/6] lib/crypto: sha2: " Eric Biggers
2025-11-22 21:00 ` [PATCH 0/6] lib/crypto: More at_least decorations Jason A. Donenfeld
2025-11-23 4:00 ` Eric Biggers
2025-11-23 5:16 ` Jason A. Donenfeld
2025-11-23 5:17 ` Eric Biggers
2025-11-23 8:31 ` Ard Biesheuvel
2025-11-23 20:35 ` Eric Biggers
2025-11-23 20:38 ` Jason A. Donenfeld
2025-11-23 20:54 ` Eric Biggers
2025-11-24 19:17 ` Kees Cook
2025-11-23 20:31 ` Eric Biggers
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=20251122194206.31822-2-ebiggers@kernel.org \
--to=ebiggers@kernel.org \
--cc=Jason@zx2c4.com \
--cc=ardb@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=kees@kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).