Skip to contentSkip to conversation

rng stable patches from 5.19-rc2

PATCH New Jason A. Donenfeld 1 participant 2 messages Jun 13, 2022 Stable branch

lore
Share & tools
lore
#0 lore raw

cover rng stable patches from 5.19-rc2

Hi Greg,

These three patches from 5.19-rc2 failed to automatically apply. The following series should work okay.

Note that these are already part of the 4.9, 4.14, 4.19, 5.4 backport I did for later this week.

Jason

Jason A. Donenfeld (3):
random: avoid checking crng_ready() twice in random_init()
random: mark bootloader randomness code as __init
random: account for arch randomness in bits

 drivers/char/random.c  | 15 +++++++--------
 include/linux/random.h |  2 +-
 2 files changed, 8 insertions(+), 9 deletions(-)
Signature · 1 line
2.35.1
#1 lore raw

PATCH 1/3 random: avoid checking crng_ready() twice in random_init()

commit 9b29b6b20376ab64e1b043df6301d8a92378e631 upstream.

The current flow expands to:

    if (crng_ready())
       ...
    else if (...)
        if (!crng_ready())
            ...

The second crng_ready() call is redundant, but can't so easily be optimized out by the compiler.

This commit simplifies that to:

    if (crng_ready()
        ...
    else if (...)
        ...
Fixes 560181c27b58 ("random: move initialization functions out of hot pages")
Cc Dominik Brodowski <[email protected]>
---
 drivers/char/random.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/random.c +1 -1
index 420d78eee6c5..9972259809db 100644
@@ -834,7 +834,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_bytes * 8);
 
 	return 0;
 }
Signature · 1 line
2.35.1