Random number generator fixes for Linux 6.9-rc5.

-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEq5lC5tSkz8NBJiCnSfxwEqXeA64FAmYhOXgACgkQSfxwEqXe
 A67aWA//VLFS7tJWf6wiP+XKM5vxktakjOqEL+P9RSQJbSfM6glRt5FjmTJjP5Uq
 w0JZDk6m0aDTq1vfkcOi8D8sF6xgzn4d2LcOr8xn+KvzVnbcU7qNJe+wqTT7TxAJ
 AYcYMygc8Nt7EKWLP3EvbudzEnKJF/qLYc6kwUEUyT0PgL5tgR0+V5OeIey3YUUd
 R+X2ELe0BkMVVwB0+OOwpK05TqoGeF6y5djU4jX9YvIDMGs6lSvCv+e+Ec6+PAPw
 l3Pg/267gWOk83p8WMpdVBuoDzwyzP6n8qd0Lfjbtk2JylGCNtqek7GGFeBUmJh7
 8nlxOTJg0LJgOKoM9Hdn+Y1s18gfU4JCafRHTlHSJljvnzf6AYOStR8WKQ5fb50O
 E+0oc1mdYUjiWS8hPTmU3aT1K5TRj93yVOTATsKac8yPlEYmq6xPTWk2GqM4sdF7
 mcqihmGhVPw0SC8DVebmI8SKCmDL9rLPxbjhklBf1wTPBVaF0eePXgA8NdtKJZ6O
 qmYG6BMctL56c1YQy3nGpGw/m1jkHwcDO+9NkZqOMZAYKVvbPWxP4/3XzZnokGP/
 tqFIdZqJKanPaesbqaWyNp6UfNl1Evkxdp0jEALE8B/lYZodtfpXATCNsSTrSRwr
 LXsWwMNbQCmK9SCVRJf0aokTPw5s6hNmT30GNb/j7tDmnHFjn/o=
 =AK8k
 -----END PGP SIGNATURE-----

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

Pull random number generator fixes from Jason Donenfeld:

 - The input subsystem contributes entropy in some places where a
   spinlock is held, but the entropy accounting code only handled
   callers being in an interrupt or non-atomic process context, but not
   atomic process context. We fix this by removing an optimization and
   just calling queue_work() unconditionally.

 - Greg accidently sent up a patch not intended for his tree and that
   had been nack'd, so that's now reverted.

* tag 'random-6.9-rc5-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/crng/random:
  Revert "vmgenid: emit uevent when VMGENID updates"
  random: handle creditable entropy from atomic process context
This commit is contained in:
Linus Torvalds 2024-04-18 09:49:08 -07:00
commit e4add02086
2 changed files with 5 additions and 7 deletions

View File

@ -702,7 +702,7 @@ static void extract_entropy(void *buf, size_t len)
static void __cold _credit_init_bits(size_t bits)
{
static struct execute_work set_ready;
static DECLARE_WORK(set_ready, crng_set_ready);
unsigned int new, orig, add;
unsigned long flags;
@ -718,8 +718,8 @@ static void __cold _credit_init_bits(size_t bits)
if (orig < POOL_READY_BITS && new >= POOL_READY_BITS) {
crng_reseed(NULL); /* Sets crng_init to CRNG_READY under base_crng.lock. */
if (static_key_initialized)
execute_in_process_context(crng_set_ready, &set_ready);
if (static_key_initialized && system_unbound_wq)
queue_work(system_unbound_wq, &set_ready);
atomic_notifier_call_chain(&random_ready_notifier, 0, NULL);
wake_up_interruptible(&crng_init_wait);
kill_fasync(&fasync, SIGIO, POLL_IN);
@ -890,8 +890,8 @@ void __init random_init(void)
/*
* If we were initialized by the cpu or bootloader before jump labels
* are initialized, then we should enable the static branch here, where
* it's guaranteed that jump labels have been initialized.
* or workqueues are initialized, then we should enable the static
* branch here, where it's guaranteed that these have been initialized.
*/
if (!static_branch_likely(&crng_is_ready) && crng_init >= CRNG_READY)
crng_set_ready(NULL);

View File

@ -68,7 +68,6 @@ out:
static void vmgenid_notify(struct acpi_device *device, u32 event)
{
struct vmgenid_state *state = acpi_driver_data(device);
char *envp[] = { "NEW_VMGENID=1", NULL };
u8 old_id[VMGENID_SIZE];
memcpy(old_id, state->this_id, sizeof(old_id));
@ -76,7 +75,6 @@ static void vmgenid_notify(struct acpi_device *device, u32 event)
if (!memcmp(old_id, state->this_id, sizeof(old_id)))
return;
add_vmfork_randomness(state->this_id, sizeof(state->this_id));
kobject_uevent_env(&device->dev.kobj, KOBJ_CHANGE, envp);
}
static const struct acpi_device_id vmgenid_ids[] = {