diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2022-09-21 11:31:33 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2022-09-27 11:30:59 +0200 |
commit | 763a2828bf313ed55878b09759dc435355035f2e (patch) | |
tree | 151fab0b966105101675bda0f0d351a4192394d9 /hw | |
parent | eebb38a5633a77f5fa79d6486d5b2fcf8fbe3c07 (diff) |
x86: reinitialize RNG seed on system reboot
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>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/i386/x86.c | 7 |
1 files changed, 7 insertions, 0 deletions
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); |