Random number generator fixes for Linux 6.2-rc1.

-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEq5lC5tSkz8NBJiCnSfxwEqXeA64FAmOhGqkACgkQSfxwEqXe
 A663VxAA0TOqGpqhI5FFV4r9rQR876SwD5doernG2k/lDugweTb0o4JK3jo03aFE
 V+McSbPAkiICSVsKompc48Blt7stHYfAIGu7KXBl88ZlrbNYay3ooV26WcAMbo7Y
 T3iLiK8wiqJBYOD5TUA3GA1ijVRmKBMiURrC1trHK7qZRc5N9lIedp6hRJD1INC+
 LUpSj6LoIhjpIqjbBLD3QlPRklkVhsceAvFwu/q2E5VUZgnMvBDzdJdll0Nt8uU4
 JBjw4GPsP5EdTOG0c+xt9aHApAbaT7Q7Un+dGKRf7xDUkgNvdZHwYitMIsIItyL0
 COiwQJS67ny61fBddz90yh6l7QK6D52fCC4xYLheBsS8cvZy2GcXZHYwDKUxqFWK
 UhqkEVTbl7gXC/NxGomEvkA84tPkLOtLlpd8BVaIQh5wEanVZOO9VxiMmFUYfmB+
 ygfcy011cxr4lLFzykh1JaRLGkWNTDN4RZXEsu501yZwv/xIcXZks0J5sRllZ3Pl
 JMjEwjWpy7CzCUAzR9v5wlRdYNTQjghT5zQEVeQMmsO+1LEKbh6HKPMHJd6DZWUI
 McuMylGChIYO4h6NTlY9wlkPI8MWTSSpN8UPXqRnpVwFSqhegnWul/C254tdX0aC
 0nrqLnlVQ95a2ZwfWkvZbbjN2kOtti+osQIv3PlCPeYiil599nU=
 =IBNq
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2022-12-21 08:02:30 -08:00
Родитель 19822e3ee4 3c202d14a9
Коммит 222882c2ab
10 изменённых файлов: 10 добавлений и 11 удалений

Просмотреть файл

@ -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
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