Skip to content

Commit

Permalink
Merge tag 'random-6.2-rc1-for-linus' of git://git.kernel.org/pub/scm/…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Linus Torvalds committed Dec 21, 2022
2 parents 19822e3 + 3c202d1 commit 222882c
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 11 deletions.
1 change: 1 addition & 0 deletions arch/powerpc/kernel/setup-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions arch/s390/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/mm/cpu_entry_area.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions drivers/char/hw_random/powernv-rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions drivers/char/hw_random/s390-trng.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions drivers/char/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 3 additions & 1 deletion drivers/firmware/efi/efi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 0 additions & 6 deletions include/linux/prandom.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
2 changes: 0 additions & 2 deletions include/linux/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/tcp_plb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 222882c

Please sign in to comment.