Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lib/crypto: chacha: Add at_least decoration to fixed-size array params

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.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: "Jason A. Donenfeld" <Jason@zx2c4.com>
Link: https://lore.kernel.org/r/20251122194206.31822-2-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>

+6 -6
+6 -6
include/crypto/chacha.h
··· 38 38 }; 39 39 40 40 void chacha_block_generic(struct chacha_state *state, 41 - u8 out[CHACHA_BLOCK_SIZE], int nrounds); 41 + u8 out[at_least CHACHA_BLOCK_SIZE], int nrounds); 42 42 static inline void chacha20_block(struct chacha_state *state, 43 - u8 out[CHACHA_BLOCK_SIZE]) 43 + u8 out[at_least CHACHA_BLOCK_SIZE]) 44 44 { 45 45 chacha_block_generic(state, out, 20); 46 46 } 47 47 48 48 void hchacha_block_generic(const struct chacha_state *state, 49 - u32 out[HCHACHA_OUT_WORDS], int nrounds); 49 + u32 out[at_least HCHACHA_OUT_WORDS], int nrounds); 50 50 51 51 void hchacha_block(const struct chacha_state *state, 52 - u32 out[HCHACHA_OUT_WORDS], int nrounds); 52 + u32 out[at_least HCHACHA_OUT_WORDS], int nrounds); 53 53 54 54 enum chacha_constants { /* expand 32-byte k */ 55 55 CHACHA_CONSTANT_EXPA = 0x61707865U, ··· 67 67 } 68 68 69 69 static inline void chacha_init(struct chacha_state *state, 70 - const u32 key[CHACHA_KEY_WORDS], 71 - const u8 iv[CHACHA_IV_SIZE]) 70 + const u32 key[at_least CHACHA_KEY_WORDS], 71 + const u8 iv[at_least CHACHA_IV_SIZE]) 72 72 { 73 73 chacha_init_consts(state); 74 74 state->x[4] = key[0];