From nobody Sun Apr 28 01:47:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 152863640219134.20575425799552; Sun, 10 Jun 2018 06:13:22 -0700 (PDT) Received: from localhost ([::1]:44092 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fS09f-0008AP-JT for importer@patchew.org; Sun, 10 Jun 2018 09:13:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fS08i-0007s5-LG for qemu-devel@nongnu.org; Sun, 10 Jun 2018 09:12:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fS08f-0006Yz-Eu for qemu-devel@nongnu.org; Sun, 10 Jun 2018 09:12:12 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49006 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fS08f-0006YZ-AU; Sun, 10 Jun 2018 09:12:09 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BD1B3406E885; Sun, 10 Jun 2018 13:12:07 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 973D8100294D; Sun, 10 Jun 2018 13:12:06 +0000 (UTC) From: Thomas Huth To: Christian Borntraeger , qemu-s390x@nongnu.org Date: Sun, 10 Jun 2018 15:12:05 +0200 Message-Id: <1528636325-4237-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Sun, 10 Jun 2018 13:12:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Sun, 10 Jun 2018 13:12:07 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH] hw/s390x/ipl: Fix crash that occurs when -kernel is used with small images X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cornelia Huck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a sanity check to fix the following crash: $ echo "Insane in the mainframe" > /tmp/test.txt $ s390x-softmmu/qemu-system-s390x -nographic -kernel /tmp/test.txt Segmentation fault (core dumped) Signed-off-by: Thomas Huth Reviewed-by: Christian Borntraeger --- hw/s390x/ipl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 04245b5..9bb9b50 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -168,7 +168,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **= errp) * we can not rely on the ELF entry point - it was 0x800 (the SALI= PL * loader) and it won't work. For this case we force it to 0x10000= , too. */ - if (pentry =3D=3D KERN_IMAGE_START || pentry =3D=3D 0x800) { + if ((pentry =3D=3D KERN_IMAGE_START || pentry =3D=3D 0x800) && + kernel_size > KERN_PARM_AREA + strlen(ipl->cmdline)) { ipl->start_addr =3D KERN_IMAGE_START; /* Overwrite parameters in the kernel image, which are "rom" */ strcpy(rom_ptr(KERN_PARM_AREA), ipl->cmdline); --=20 1.8.3.1