[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 03/14] x86: reinitialize RNG seed on system reboot
From: |
Paolo Bonzini |
Subject: |
[PULL 03/14] x86: reinitialize RNG seed on system reboot |
Date: |
Thu, 29 Sep 2022 18:30:03 +0200 |
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Since this is read from fw_cfg on each boot, the kernel zeroing it out
alone is insufficient to prevent it from being used twice. And indeed on
reboot we always want a new seed, not the old one. So re-fill it in this
circumstance.
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Message-Id: <20220921093134.2936487-3-Jason@zx2c4.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/i386/x86.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 1ee0b1b413..f9a4ddaa4a 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -783,6 +783,12 @@ static void reset_setup_data(void *opaque)
stq_p(fixup->pos, fixup->orig_val);
}
+static void reset_rng_seed(void *opaque)
+{
+ SetupData *setup_data = opaque;
+ qemu_guest_getrandom_nofail(setup_data->data,
le32_to_cpu(setup_data->len));
+}
+
void x86_load_linux(X86MachineState *x86ms,
FWCfgState *fw_cfg,
int acpi_data_size,
@@ -1105,6 +1111,7 @@ void x86_load_linux(X86MachineState *x86ms,
setup_data->type = cpu_to_le32(SETUP_RNG_SEED);
setup_data->len = cpu_to_le32(RNG_SEED_LENGTH);
qemu_guest_getrandom_nofail(setup_data->data, RNG_SEED_LENGTH);
+ qemu_register_reset(reset_rng_seed, setup_data);
}
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr);
--
2.37.3
- [PULL 00/14] x86 + misc changes for 2022-09-29, Paolo Bonzini, 2022/09/29
- [PULL 01/14] x86: return modified setup_data only if read as memory, not as file, Paolo Bonzini, 2022/09/29
- [PULL 06/14] configure: do not invoke as/ld directly for pc-bios/optionrom, Paolo Bonzini, 2022/09/29
- [PULL 07/14] watchdog: remove -watchdog option, Paolo Bonzini, 2022/09/29
- [PULL 05/14] qboot: rebuild based on latest commit, Paolo Bonzini, 2022/09/29
- [PULL 02/14] x86: use typedef for SetupData struct, Paolo Bonzini, 2022/09/29
- [PULL 03/14] x86: reinitialize RNG seed on system reboot,
Paolo Bonzini <=
- [PULL 08/14] ui: fix path to dbus-display1.h, Paolo Bonzini, 2022/09/29
- [PULL 04/14] x86: re-enable rng seeding via SetupData, Paolo Bonzini, 2022/09/29
- [PULL 09/14] meson: require 0.61.3, Paolo Bonzini, 2022/09/29
- [PULL 10/14] meson: multiple names can be passed to dependency(), Paolo Bonzini, 2022/09/29
- [PULL 11/14] configure, meson: move C++ compiler detection to meson.build, Paolo Bonzini, 2022/09/29
- [PULL 12/14] configure, meson: move linker flag detection to meson, Paolo Bonzini, 2022/09/29
- [PULL 13/14] target/i386/kvm: fix kvmclock_current_nsec: Assertion `time.tsc_timestamp <= migration_tsc' failed, Paolo Bonzini, 2022/09/29
- [PULL 14/14] x86: re-initialize RNG seed when selecting kernel, Paolo Bonzini, 2022/09/29
- Re: [PULL 00/14] x86 + misc changes for 2022-09-29, Stefan Hajnoczi, 2022/09/29