Skip to content

Commit 222882c

Browse files
committed
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
2 parents 19822e3 + 3c202d1 commit 222882c

File tree

10 files changed

+10
-11
lines changed

10 files changed

+10
-11
lines changed

arch/powerpc/kernel/setup-common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#include <asm/xmon.h>
6060
#include <asm/cputhreads.h>
6161
#include <mm/mmu_decl.h>
62+
#include <asm/archrandom.h>
6263
#include <asm/fadump.h>
6364
#include <asm/udbg.h>
6465
#include <asm/hugetlb.h>

arch/s390/kernel/setup.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include <linux/hugetlb.h>
5353
#include <linux/kmemleak.h>
5454

55+
#include <asm/archrandom.h>
5556
#include <asm/boot_data.h>
5657
#include <asm/ipl.h>
5758
#include <asm/facility.h>

arch/x86/mm/cpu_entry_area.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static __init void init_cea_offsets(void)
3636
unsigned int cea;
3737

3838
again:
39-
cea = prandom_u32_max(max_cea);
39+
cea = get_random_u32_below(max_cea);
4040

4141
for_each_possible_cpu(j) {
4242
if (cea_offset(j) == cea)

drivers/char/hw_random/powernv-rng.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/platform_device.h>
1212
#include <linux/random.h>
1313
#include <linux/hw_random.h>
14+
#include <asm/archrandom.h>
1415

1516
static int powernv_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
1617
{

drivers/char/hw_random/s390-trng.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/sched/signal.h>
2424
#include <asm/debug.h>
2525
#include <asm/cpacf.h>
26+
#include <asm/archrandom.h>
2627

2728
MODULE_LICENSE("GPL v2");
2829
MODULE_AUTHOR("IBM Corporation");

drivers/char/random.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#include <linux/sched/isolation.h>
5757
#include <crypto/chacha.h>
5858
#include <crypto/blake2s.h>
59+
#include <asm/archrandom.h>
5960
#include <asm/processor.h>
6061
#include <asm/irq.h>
6162
#include <asm/irq_regs.h>

drivers/firmware/efi/efi.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,9 @@ static int __init efisubsys_init(void)
429429
platform_device_register_simple("efi_secret", 0, NULL, 0);
430430
#endif
431431

432-
execute_with_initialized_rng(&refresh_nv_rng_seed_nb);
432+
if (efi_rt_services_supported(EFI_RT_SUPPORTED_SET_VARIABLE))
433+
execute_with_initialized_rng(&refresh_nv_rng_seed_nb);
434+
433435
return 0;
434436

435437
err_remove_group:

include/linux/prandom.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ void prandom_seed_full_state(struct rnd_state __percpu *pcpu_state);
2424
#define prandom_init_once(pcpu_state) \
2525
DO_ONCE(prandom_seed_full_state, (pcpu_state))
2626

27-
/* Deprecated: use get_random_u32_below() instead. */
28-
static inline u32 prandom_u32_max(u32 ep_ro)
29-
{
30-
return get_random_u32_below(ep_ro);
31-
}
32-
3327
/*
3428
* Handle minimum values for seeds
3529
*/

include/linux/random.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ declare_get_random_var_wait(long, unsigned long)
152152
*/
153153
#include <linux/prandom.h>
154154

155-
#include <asm/archrandom.h>
156-
157155
#ifdef CONFIG_SMP
158156
int random_prepare_cpu(unsigned int cpu);
159157
int random_online_cpu(unsigned int cpu);

net/ipv4/tcp_plb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void tcp_plb_update_state_upon_rto(struct sock *sk, struct tcp_plb_state *plb)
9797
return;
9898

9999
pause = READ_ONCE(net->ipv4.sysctl_tcp_plb_suspend_rto_sec) * HZ;
100-
pause += prandom_u32_max(pause);
100+
pause += get_random_u32_below(pause);
101101
plb->pause_until = tcp_jiffies32 + pause;
102102

103103
/* Reset PLB state upon RTO, since an RTO causes a sk_rethink_txhash() call

0 commit comments

Comments
 (0)