Commit 222882c2 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'random-6.2-rc1-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/crng/random

Pull more random number generator updates from Jason Donenfeld:
 "Two remaining changes that are now possible after you merged a few
  other trees:

   - #include <asm/archrandom.h> can be removed from random.h now,
     making the direct use of the arch_random_* API more of a private
     implementation detail between the archs and random.c, rather than
     something for general consumers.

   - Two additional uses of prandom_u32_max() snuck in during the
     initial phase of pulls, so these have been converted to
     get_random_u32_below(), and now the deprecated prandom_u32_max()
     alias -- which was just a wrapper around get_random_u32_below() --
     can be removed.

  In addition, there is one fix:

   - Check efi_rt_services_supported() before attempting to use an EFI
     runtime function.

     This affected EFI systems that disable runtime services yet still
     boot via EFI (e.g. the reporter's Lenovo Thinkpad X13s laptop), as
     well systems where EFI runtime services have been forcibly
     disabled, such as on PREEMPT_RT.

     On those machines, a very early and hard to diagnose crash would
     happen, preventing boot"

* tag 'random-6.2-rc1-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/crng/random:
  prandom: remove prandom_u32_max()
  efi: random: fix NULL-deref when refreshing seed
  random: do not include <asm/archrandom.h> from random.h
parents 19822e3e 3c202d14
......@@ -59,6 +59,7 @@
#include <asm/xmon.h>
#include <asm/cputhreads.h>
#include <mm/mmu_decl.h>
#include <asm/archrandom.h>
#include <asm/fadump.h>
#include <asm/udbg.h>
#include <asm/hugetlb.h>
......
......@@ -52,6 +52,7 @@
#include <linux/hugetlb.h>
#include <linux/kmemleak.h>
#include <asm/archrandom.h>
#include <asm/boot_data.h>
#include <asm/ipl.h>
#include <asm/facility.h>
......
......@@ -36,7 +36,7 @@ static __init void init_cea_offsets(void)
unsigned int cea;
again:
cea = prandom_u32_max(max_cea);
cea = get_random_u32_below(max_cea);
for_each_possible_cpu(j) {
if (cea_offset(j) == cea)
......
......@@ -11,6 +11,7 @@
#include <linux/platform_device.h>
#include <linux/random.h>
#include <linux/hw_random.h>
#include <asm/archrandom.h>
static int powernv_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
{
......
......@@ -23,6 +23,7 @@
#include <linux/sched/signal.h>
#include <asm/debug.h>
#include <asm/cpacf.h>
#include <asm/archrandom.h>
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("IBM Corporation");
......
......@@ -56,6 +56,7 @@
#include <linux/sched/isolation.h>
#include <crypto/chacha.h>
#include <crypto/blake2s.h>
#include <asm/archrandom.h>
#include <asm/processor.h>
#include <asm/irq.h>
#include <asm/irq_regs.h>
......
......@@ -429,7 +429,9 @@ static int __init efisubsys_init(void)
platform_device_register_simple("efi_secret", 0, NULL, 0);
#endif
execute_with_initialized_rng(&refresh_nv_rng_seed_nb);
if (efi_rt_services_supported(EFI_RT_SUPPORTED_SET_VARIABLE))
execute_with_initialized_rng(&refresh_nv_rng_seed_nb);
return 0;
err_remove_group:
......
......@@ -24,12 +24,6 @@ void prandom_seed_full_state(struct rnd_state __percpu *pcpu_state);
#define prandom_init_once(pcpu_state) \
DO_ONCE(prandom_seed_full_state, (pcpu_state))
/* Deprecated: use get_random_u32_below() instead. */
static inline u32 prandom_u32_max(u32 ep_ro)
{
return get_random_u32_below(ep_ro);
}
/*
* Handle minimum values for seeds
*/
......
......@@ -152,8 +152,6 @@ declare_get_random_var_wait(long, unsigned long)
*/
#include <linux/prandom.h>
#include <asm/archrandom.h>
#ifdef CONFIG_SMP
int random_prepare_cpu(unsigned int cpu);
int random_online_cpu(unsigned int cpu);
......
......@@ -97,7 +97,7 @@ void tcp_plb_update_state_upon_rto(struct sock *sk, struct tcp_plb_state *plb)
return;
pause = READ_ONCE(net->ipv4.sysctl_tcp_plb_suspend_rto_sec) * HZ;
pause += prandom_u32_max(pause);
pause += get_random_u32_below(pause);
plb->pause_until = tcp_jiffies32 + pause;
/* Reset PLB state upon RTO, since an RTO causes a sk_rethink_txhash() call
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment