“dceb2005237e39d0f3992fea0417f9f1d3b4fac4”上不存在“git@gitcode.net:Crayonxin2000/Paddle.git”
提交 ae736721 编写于 作者: J Jason A. Donenfeld 提交者: Zheng Zengkai

random: mix build-time latent entropy into pool at init

stable inclusion
from stable-v5.10.119
commit be0d4e3e96adb6a9bb68a237a33d95bf2b9d3143
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6BB

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=be0d4e3e96adb6a9bb68a237a33d95bf2b9d3143

--------------------------------

commit 1754abb3 upstream.

Prior, the "input_pool_data" array needed no real initialization, and so
it was easy to mark it with __latent_entropy to populate it during
compile-time. In switching to using a hash function, this required us to
specifically initialize it to some specific state, which means we
dropped the __latent_entropy attribute. An unfortunate side effect was
this meant the pool was no longer seeded using compile-time random data.
In order to bring this back, we declare an array in rand_initialize()
with __latent_entropy and call mix_pool_bytes() on that at init, which
accomplishes the same thing as before. We make this __initconst, so that
it doesn't take up space at runtime after init.

Fixes: 6e8ec255 ("random: use computational hash for entropy extraction")
Reviewed-by: NDominik Brodowski <linux@dominikbrodowski.net>
Reviewed-by: NTheodore Ts'o <tytso@mit.edu>
Signed-off-by: NJason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 3d03d8fb
...@@ -972,6 +972,11 @@ int __init rand_initialize(void) ...@@ -972,6 +972,11 @@ int __init rand_initialize(void)
bool arch_init = true; bool arch_init = true;
unsigned long rv; unsigned long rv;
#if defined(LATENT_ENTROPY_PLUGIN)
static const u8 compiletime_seed[BLAKE2S_BLOCK_SIZE] __initconst __latent_entropy;
_mix_pool_bytes(compiletime_seed, sizeof(compiletime_seed));
#endif
for (i = 0; i < BLAKE2S_BLOCK_SIZE; i += sizeof(rv)) { for (i = 0; i < BLAKE2S_BLOCK_SIZE; i += sizeof(rv)) {
if (!arch_get_random_seed_long_early(&rv) && if (!arch_get_random_seed_long_early(&rv) &&
!arch_get_random_long_early(&rv)) { !arch_get_random_long_early(&rv)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册