mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 13:53:33 +00:00
random: account for arch randomness in bits
commit77fc95f8c0
upstream. Rather than accounting in bytes and multiplying (shifting), we can just account in bits and avoid the shift. The main motivation for this is there are other patches in flux that expand this code a bit, and avoiding the duplication of "* 8" everywhere makes things a bit clearer. Cc: stable@vger.kernel.org Fixes:12e45a2a63
("random: credit architectural init the exact amount") Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
e061ef6818
commit
60e198d152
1 changed files with 4 additions and 4 deletions
|
@ -817,7 +817,7 @@ early_param("random.trust_bootloader", parse_trust_bootloader);
|
|||
int __init random_init(const char *command_line)
|
||||
{
|
||||
ktime_t now = ktime_get_real();
|
||||
unsigned int i, arch_bytes;
|
||||
unsigned int i, arch_bits;
|
||||
unsigned long entropy;
|
||||
|
||||
#if defined(LATENT_ENTROPY_PLUGIN)
|
||||
|
@ -825,12 +825,12 @@ int __init random_init(const char *command_line)
|
|||
_mix_pool_bytes(compiletime_seed, sizeof(compiletime_seed));
|
||||
#endif
|
||||
|
||||
for (i = 0, arch_bytes = BLAKE2S_BLOCK_SIZE;
|
||||
for (i = 0, arch_bits = BLAKE2S_BLOCK_SIZE * 8;
|
||||
i < BLAKE2S_BLOCK_SIZE; i += sizeof(entropy)) {
|
||||
if (!arch_get_random_seed_long_early(&entropy) &&
|
||||
!arch_get_random_long_early(&entropy)) {
|
||||
entropy = random_get_entropy();
|
||||
arch_bytes -= sizeof(entropy);
|
||||
arch_bits -= sizeof(entropy) * 8;
|
||||
}
|
||||
_mix_pool_bytes(&entropy, sizeof(entropy));
|
||||
}
|
||||
|
@ -842,7 +842,7 @@ int __init random_init(const char *command_line)
|
|||
if (crng_ready())
|
||||
crng_reseed();
|
||||
else if (trust_cpu)
|
||||
_credit_init_bits(arch_bytes * 8);
|
||||
_credit_init_bits(arch_bits);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue