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

crypto: lib/blake2s - reduce stack frame usage in self test

Using 3 blocks here doesn't give us much more than using 2, and it
causes a stack frame size warning on certain compiler/config/arch
combinations:

lib/crypto/blake2s-selftest.c: In function 'blake2s_selftest':
>> lib/crypto/blake2s-selftest.c:632:1: warning: the frame size of 1088 bytes is larger than 1024 bytes [-Wframe-larger-than=]
632 | }
| ^

So this patch just reduces the block from 3 to 2, which makes the
warning go away.

Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/linux-crypto/202206200851.gE3MHCgd-lkp@intel.com
Fixes: 2d16803c562e ("crypto: blake2s - remove shash module")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Jason A. Donenfeld and committed by
Herbert Xu
d6c14da4 9c846c5d

+3 -3
+3 -3
lib/crypto/blake2s-selftest.c
··· 593 593 enum { TEST_ALIGNMENT = 16 }; 594 594 u8 unaligned_block[BLAKE2S_BLOCK_SIZE + TEST_ALIGNMENT - 1] 595 595 __aligned(TEST_ALIGNMENT); 596 - u8 blocks[BLAKE2S_BLOCK_SIZE * 3]; 596 + u8 blocks[BLAKE2S_BLOCK_SIZE * 2]; 597 597 struct blake2s_state state1, state2; 598 598 599 599 get_random_bytes(blocks, sizeof(blocks)); ··· 603 603 defined(CONFIG_CRYPTO_ARCH_HAVE_LIB_BLAKE2S) 604 604 memcpy(&state1, &state, sizeof(state1)); 605 605 memcpy(&state2, &state, sizeof(state2)); 606 - blake2s_compress(&state1, blocks, 3, BLAKE2S_BLOCK_SIZE); 607 - blake2s_compress_generic(&state2, blocks, 3, BLAKE2S_BLOCK_SIZE); 606 + blake2s_compress(&state1, blocks, 2, BLAKE2S_BLOCK_SIZE); 607 + blake2s_compress_generic(&state2, blocks, 2, BLAKE2S_BLOCK_SIZE); 608 608 if (memcmp(&state1, &state2, sizeof(state1))) { 609 609 pr_err("blake2s random compress self-test %d: FAIL\n", 610 610 i + 1);