Received: from [140.186.70.92] (port=40026 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OscSe-0007G8-CB for qemu-devel@nongnu.org; Mon, 06 Sep 2010 10:14:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OscSd-0002Rs-Ck for qemu-devel@nongnu.org; Mon, 06 Sep 2010 10:14:16 -0400 Received: from smtp28.orange.fr ([80.12.242.100]:29674) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OscSd-0002RW-7a for qemu-devel@nongnu.org; Mon, 06 Sep 2010 10:14:15 -0400 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2806.orange.fr (SMTP Server) with ESMTP id 822EC7002020 for ; Mon, 6 Sep 2010 16:14:12 +0200 (CEST) Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2806.orange.fr (SMTP Server) with ESMTP id 7516B700011F for ; Mon, 6 Sep 2010 16:14:12 +0200 (CEST) Received: from localhost.localdomain (AToulouse-159-1-51-197.w92-134.abo.wanadoo.fr [92.134.82.197]) by mwinf2806.orange.fr (SMTP Server) with ESMTP id 3A730700324C for ; Mon, 6 Sep 2010 16:14:12 +0200 (CEST) From: Daniel Lezcano Date: Mon, 6 Sep 2010 16:12:51 +0200 Message-Id: <1283782373-4797-2-git-send-email-daniel.lezcano@free.fr> In-Reply-To: <1283782373-4797-1-git-send-email-daniel.lezcano@free.fr> References: <1283782373-4797-1-git-send-email-daniel.lezcano@free.fr> Subject: [Qemu-devel] [rfc 1/3] arm : raise an error if the kernel size will overlap the initrd List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 --- 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