qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] x86: reset rng seed when reading cmdline, not kernel image


From: Jason A. Donenfeld
Subject: [PATCH 1/2] x86: reset rng seed when reading cmdline, not kernel image
Date: Tue, 7 Feb 2023 19:48:46 -0300

With eac7a7791bb6 ("x86: don't let decompressed kernel image clobber
setup_data"), the rng seed setup_data is now appended to the cmdline
file rather than the kernel image file. But in the process, the code to
re-randomize the seed when selecting the image was left out. So, change
the re-randomization over to trigger when selecting the cmdline, rather
than the kernel image.

Fixes: eac7a7791bb6 ("x86: don't let decompressed kernel image clobber 
setup_data")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 hw/i386/x86.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index eaff4227bd..c6d7bf6db2 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -1114,15 +1114,15 @@ void x86_load_linux(X86MachineState *x86ms,
         setup_data->len = cpu_to_le32(RNG_SEED_LENGTH);
         qemu_guest_getrandom_nofail(setup_data->data, RNG_SEED_LENGTH);
         qemu_register_reset_nosnapshotload(reset_rng_seed, setup_data);
-        fw_cfg_add_bytes_callback(fw_cfg, FW_CFG_KERNEL_DATA, reset_rng_seed, 
NULL,
-                                  setup_data, kernel, kernel_size, true);
+        fw_cfg_add_bytes_callback(fw_cfg, FW_CFG_CMDLINE_DATA, reset_rng_seed, 
NULL,
+                                  setup_data, kernel_cmdline, cmdline_size, 
true);
     } else {
-        fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size);
+        fw_cfg_add_bytes(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline, 
cmdline_size);
     }
 
+    fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size);
     fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_ADDR, cmdline_addr);
     fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, cmdline_size);
-    fw_cfg_add_bytes(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline, 
cmdline_size);
     sev_load_ctx.cmdline_data = (char *)kernel_cmdline;
     sev_load_ctx.cmdline_size = cmdline_size;
 
-- 
2.39.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]