Skip to content

Commit e052a47

Browse files
committed
random: remove rng_has_arch_random()
With arch randomness being used by every distro and enabled in defconfigs, the distinction between rng_has_arch_random() and rng_is_initialized() is now rather small. In fact, the places where they differ are now places where paranoid users and system builders really don't want arch randomness to be used, in which case we should respect that choice, or places where arch randomness is known to be broken, in which case that choice is all the more important. So this commit just removes the function and its one user. Reviewed-by: Petr Mladek <pmladek@suse.com> # for vsprintf.c Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
1 parent 846bb97 commit e052a47

File tree

3 files changed

+1
-16
lines changed

3 files changed

+1
-16
lines changed

drivers/char/random.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,6 @@ static void __cold _credit_init_bits(size_t bits)
725725
*
726726
**********************************************************************/
727727

728-
static bool used_arch_random;
729728
static bool trust_cpu __initdata = IS_ENABLED(CONFIG_RANDOM_TRUST_CPU);
730729
static bool trust_bootloader __initdata = IS_ENABLED(CONFIG_RANDOM_TRUST_BOOTLOADER);
731730
static int __init parse_trust_cpu(char *arg)
@@ -811,7 +810,6 @@ int __init random_init(const char *command_line)
811810
crng_reseed();
812811
else if (trust_cpu)
813812
_credit_init_bits(arch_bits);
814-
used_arch_random = arch_bits >= POOL_READY_BITS;
815813

816814
WARN_ON(register_pm_notifier(&pm_notifier));
817815

@@ -820,17 +818,6 @@ int __init random_init(const char *command_line)
820818
return 0;
821819
}
822820

823-
/*
824-
* Returns whether arch randomness has been mixed into the initial
825-
* state of the RNG, regardless of whether or not that randomness
826-
* was credited. Knowing this is only good for a very limited set
827-
* of uses, such as early init printk pointer obfuscation.
828-
*/
829-
bool rng_has_arch_random(void)
830-
{
831-
return used_arch_random;
832-
}
833-
834821
/*
835822
* Add device- or boot-specific data to the input pool to help
836823
* initialize it.

include/linux/random.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ static inline unsigned long get_random_canary(void)
7474

7575
int __init random_init(const char *command_line);
7676
bool rng_is_initialized(void);
77-
bool rng_has_arch_random(void);
7877
int wait_for_random_bytes(void);
7978

8079
/* Calls wait_for_random_bytes() and then calls get_random_bytes(buf, nbytes).

lib/vsprintf.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,7 @@ static inline int __ptr_to_hashval(const void *ptr, unsigned long *hashval_out)
769769
static DECLARE_WORK(enable_ptr_key_work, enable_ptr_key_workfn);
770770
unsigned long flags;
771771

772-
if (!system_unbound_wq ||
773-
(!rng_is_initialized() && !rng_has_arch_random()) ||
772+
if (!system_unbound_wq || !rng_is_initialized() ||
774773
!spin_trylock_irqsave(&filling, flags))
775774
return -EAGAIN;
776775

0 commit comments

Comments
 (0)