qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/loader: only patch linux kernels
@ 2024-04-10  7:21 Gerd Hoffmann
  2024-04-10  7:26 ` Michael S. Tsirkin
  0 siblings, 1 reply; 9+ messages in thread
From: Gerd Hoffmann @ 2024-04-10  7:21 UTC (permalink / raw)
  To: qemu-devel
  Cc: Gerd Hoffmann, Michael S. Tsirkin, Marcel Apfelbaum,
	Paolo Bonzini, Richard Henderson, Eduardo Habkost

If the binary loaded via -kernel is *not* a linux kernel (in which
case protocol == 0), do not patch the linux kernel header fields.

It's (a) pointless and (b) might break binaries by random patching
and (c) changes the binary hash which in turn breaks secure boot
verification.

Background: OVMF happily loads and runs not only linux kernels but
any efi binary via direct kernel boot.

Note: Breaking the secure boot verification is a problem for linux
kernels too, but fixed that is left for another day ...

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/i386/x86.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index ffbda48917fd..765899eebe43 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -1108,7 +1108,7 @@ void x86_load_linux(X86MachineState *x86ms,
      * kernel on the other side of the fw_cfg interface matches the hash of the
      * file the user passed in.
      */
-    if (!sev_enabled()) {
+    if (!sev_enabled() && protocol > 0) {
         memcpy(setup, header, MIN(sizeof(header), setup_size));
     }
 
-- 
2.44.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-04-15 13:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-10  7:21 [PATCH] x86/loader: only patch linux kernels Gerd Hoffmann
2024-04-10  7:26 ` Michael S. Tsirkin
2024-04-10 10:35   ` secure boot & direct kernel load (was: Re: [PATCH] x86/loader: only patch linux kernels) Gerd Hoffmann
2024-04-10 11:10     ` Michael S. Tsirkin
2024-04-10 11:52       ` Gerd Hoffmann
2024-04-10 15:01         ` Gerd Hoffmann
2024-04-15 11:59     ` Daniel P. Berrangé
2024-04-15 13:30       ` Gerd Hoffmann
2024-04-15 13:48         ` Daniel P. Berrangé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).