qemu-trivial
[Top][All Lists]
Advanced

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

[Qemu-trivial] [PULL 07/19] pc: check for underflow in load_linux


From: Michael Tokarev
Subject: [Qemu-trivial] [PULL 07/19] pc: check for underflow in load_linux
Date: Thu, 8 Oct 2015 19:52:16 +0300

From: Paolo Bonzini <address@hidden>

If (setup_size+1)*512 is small enough, kernel_size -= setup_size can allocate
a huge amount of memory.  Avoid that.

Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: Michael Tokarev <address@hidden>
---
 hw/i386/pc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 9275297..682867a 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -985,6 +985,10 @@ static void load_linux(PCMachineState *pcms,
         setup_size = 4;
     }
     setup_size = (setup_size+1)*512;
+    if (setup_size > kernel_size) {
+        fprintf(stderr, "qemu: invalid kernel header\n");
+        exit(1);
+    }
     kernel_size -= setup_size;
 
     setup  = g_malloc(setup_size);
-- 
2.1.4




reply via email to

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