Patchwork [rfc,1/3] arm : raise an error if the kernel size will overlap the initrd

login
register
mail settings
Submitter Daniel Lezcano
Date Sept. 6, 2010, 2:12 p.m.
Message ID <1283782373-4797-2-git-send-email-daniel.lezcano@free.fr>
Download mbox | patch
Permalink /patch/63920/
State New
Headers show

Comments

Daniel Lezcano - Sept. 6, 2010, 2:12 p.m.
If the kernel size is too big, it overwrite the initrd image in memory
without detecting the problem. Let't detect this error and exit gracefully.

Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
---
 hw/arm_boot.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

Patch

diff --git a/hw/arm_boot.c b/hw/arm_boot.c
index 620550b..50ec717 100644
--- a/hw/arm_boot.c
+++ b/hw/arm_boot.c
@@ -247,6 +247,13 @@  void arm_load_kernel(CPUState *env, struct arm_boot_info *info)
     info->entry = entry;
     if (is_linux) {
         if (info->initrd_filename) {
+
+            if (KERNEL_LOAD_ADDR + kernel_size >= INITRD_LOAD_ADDR) {
+		    fprintf(stderr, "qemu: kernel is too big: %d Bytes\n",
+			    kernel_size);
+		    exit(1);
+	    }
+
             initrd_size = load_image_targphys(info->initrd_filename,
                                               info->loader_start
                                               + INITRD_LOAD_ADDR,