From patchwork Mon Sep 6 14:12:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 63920 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by ozlabs.org (Postfix) with ESMTP id 11F43B70F1 for ; Tue, 7 Sep 2010 00:21:10 +1000 (EST) Received: from localhost ([127.0.0.1]:32822 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OscTq-0007Gi-8j for incoming@patchwork.ozlabs.org; Mon, 06 Sep 2010 10:15:30 -0400 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) X-ME-UUID: 20100906141412239.3A730700324C@mwinf2806.orange.fr From: Daniel Lezcano To: qemu-devel@nongnu.org Date: Mon, 6 Sep 2010 16:12:51 +0200 Message-Id: <1283782373-4797-2-git-send-email-daniel.lezcano@free.fr> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1283782373-4797-1-git-send-email-daniel.lezcano@free.fr> References: <1283782373-4797-1-git-send-email-daniel.lezcano@free.fr> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [rfc 1/3] arm : raise an error if the kernel size will overlap the initrd X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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,