From nobody Mon Feb 9 23:00:59 2026 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; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529375803795333.9416872431766; Mon, 18 Jun 2018 19:36:43 -0700 (PDT) Received: from localhost ([::1]:38677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6Vc-000777-4W for importer@patchew.org; Mon, 18 Jun 2018 22:36:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5i0-0001cQ-Vp for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hz-0008P3-F3 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:25 -0400 Received: from mail-oi0-x236.google.com ([2607:f8b0:4003:c06::236]:46063) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hz-0008Ou-9o; Mon, 18 Jun 2018 21:45:23 -0400 Received: by mail-oi0-x236.google.com with SMTP id 188-v6so16659507oid.12; Mon, 18 Jun 2018 18:45:23 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id t4-v6sm16637815otd.40.2018.06.18.18.45.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=xexEk92pBLmhUh/GHAqJdoJ1+xWn3k2Z1CHYN5qYw5s=; b=KdFds+yLiCJXUnai5smEgwmmHmKED7a8p5/x1yO4/pL689JDSmYBJQHV0QcNqcpo0G 70yuqawQHnp9Zn/iOZV+L1Sp3bdV1cFrx+Kve8j81ySoL7e8hIirzY3L3ZxEQZnchQvL wLWpZyNCtZpWm0qcIKl6WS7yKdahcuHyyUWClMdcOSvSysm4hzgpuOFwC9aIDyEpMKZ1 r6Mxo+eSXmEQxvxHAiiZArMGT3U/HZ1M0o0veD18FhrGaLkVNLMtI3TfWW0F1LofAHBh s8gh+jL0h47eSCWO70UIKIqgZYRESRS0zTQImwouVyxLwHx5EWXygyXuBMJWIdyX4lE1 jx9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=xexEk92pBLmhUh/GHAqJdoJ1+xWn3k2Z1CHYN5qYw5s=; b=Is0iQlkLDgdrwFty2AIN+H8pXcYp+RLA7JKyxwhgk7p+USwZ1GITRCLa4rveLCRAbv 48d7ZYbXoT5tZ2TWkktWaysO40mU5hXO4uyENI2vP6g1QYbPRVV3I8EVarqATW+3+k3H AJ/xuiXHnvcCUJqwJkiANbYOJI0SUm41HV7aEMjbE7lcM/CTJSN7NYAIhe/9x+NfP53E Cj9xFrZp93uJfWnNAP7RWQIZA0Pk3ndOUmqThqUwBpfB6cfLETCAsJUu+QFFyKhdA4B+ AGxwfvYh8RXaePHXOLrpxGfSpqe+HGj2OSs1T0M+tk3xuysRER/vZFz2snySM12Fg/wE 8I1A== X-Gm-Message-State: APt69E2nLnk8d49lx/9Qz70tloZLss7U3C0DfNB6yjgoWGq/TMft/ztJ GF+bP/++YuJfROCP1kO4DaTAybdv X-Google-Smtp-Source: ADUXVKKhC2q1fVLDL4/ymb0YzHvfTa4o0mbrRW5VnsIl/hTVAwR/oPv0siRK36TiTm7Jm/TdJ0Zfvg== X-Received: by 2002:aca:5317:: with SMTP id h23-v6mr7883967oib.90.1529372722161; Mon, 18 Jun 2018 18:45:22 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:02 -0500 Message-Id: <20180619014319.28272-37-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::236 Subject: [Qemu-devel] [PATCH 036/113] multiboot: bss_end_addr can be zero 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: Kevin Wolf , qemu-stable@nongnu.org, Jack Schwartz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jack Schwartz The multiboot spec (https://www.gnu.org/software/grub/manual/multiboot/), section 3.1.3, allows for bss_end_addr to be zero. A zero bss_end_addr signifies there is no .bss section. Suggested-by: Daniel Kiper Signed-off-by: Jack Schwartz Reviewed-by: Daniel Kiper Reviewed-by: Prasad J Pandit Signed-off-by: Kevin Wolf (cherry picked from commit 2a8fcd119eb7c6bb3837fc3669eb1b2dfb31daf8) Signed-off-by: Michael Roth --- hw/i386/multiboot.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c index c7b70c91d5..ff2733d12e 100644 --- a/hw/i386/multiboot.c +++ b/hw/i386/multiboot.c @@ -233,12 +233,6 @@ int load_multiboot(FWCfgState *fw_cfg, mh_entry_addr =3D ldl_p(header+i+28); =20 if (mh_load_end_addr) { - if (mh_bss_end_addr < mh_load_addr) { - fprintf(stderr, "invalid mh_bss_end_addr address\n"); - exit(1); - } - mb_kernel_size =3D mh_bss_end_addr - mh_load_addr; - if (mh_load_end_addr < mh_load_addr) { fprintf(stderr, "invalid mh_load_end_addr address\n"); exit(1); @@ -249,8 +243,16 @@ int load_multiboot(FWCfgState *fw_cfg, fprintf(stderr, "invalid kernel_file_size\n"); exit(1); } - mb_kernel_size =3D kernel_file_size - mb_kernel_text_offset; - mb_load_size =3D mb_kernel_size; + mb_load_size =3D kernel_file_size - mb_kernel_text_offset; + } + if (mh_bss_end_addr) { + if (mh_bss_end_addr < (mh_load_addr + mb_load_size)) { + fprintf(stderr, "invalid mh_bss_end_addr address\n"); + exit(1); + } + mb_kernel_size =3D mh_bss_end_addr - mh_load_addr; + } else { + mb_kernel_size =3D mb_load_size; } =20 /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE. --=20 2.11.0