qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@free.fr>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [rfc 1/3] arm : raise an error if the kernel size will overlap the initrd
Date: Mon,  6 Sep 2010 16:12:51 +0200	[thread overview]
Message-ID: <1283782373-4797-2-git-send-email-daniel.lezcano@free.fr> (raw)
In-Reply-To: <1283782373-4797-1-git-send-email-daniel.lezcano@free.fr>

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(-)

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,
-- 
1.7.0.4

  reply	other threads:[~2010-09-06 14:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-06 14:12 [Qemu-devel] [rfc 0/3] arm : dynamically choose initrd load address Daniel Lezcano
2010-09-06 14:12 ` Daniel Lezcano [this message]
2010-09-06 14:12 ` [Qemu-devel] [rfc 2/3] arm : factor out set_kernel_args[_old] Daniel Lezcano
2010-09-06 14:12 ` [Qemu-devel] [rfc 3/3] arm : make initrd load address dynamic Daniel Lezcano
2010-09-08 11:47 ` [Qemu-devel] [rfc 0/3] arm : dynamically choose initrd load address Daniel Lezcano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1283782373-4797-2-git-send-email-daniel.lezcano@free.fr \
    --to=daniel.lezcano@free.fr \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).