From nobody Mon Feb 9 20:32:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552381917672703.5113389611994; Tue, 12 Mar 2019 02:11:57 -0700 (PDT) Received: from localhost ([127.0.0.1]:47812 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3dS0-0006PX-F6 for importer@patchew.org; Tue, 12 Mar 2019 05:11:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3dCh-0002Af-Uj for qemu-devel@nongnu.org; Tue, 12 Mar 2019 04:56:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3dCc-0001uT-3q for qemu-devel@nongnu.org; Tue, 12 Mar 2019 04:56:07 -0400 Received: from ozlabs.org ([203.11.71.1]:45937) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3dCb-0001Ya-Nu; Tue, 12 Mar 2019 04:56:02 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 44JTMM3NLWz9sPD; Tue, 12 Mar 2019 19:55:26 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1552380927; bh=pd3/Zt9I+QIf5SvUUcCcPyaQnV4kkikhQmRPeT+U5kw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NuSQqZtBfuV6unQXEykSO5sdAyKyxKDCXqEzzRcWPY+IDjk0qHZWfKUCGvbtx60+V p8+qE/Sp9QsPYoKfIaA0Sq8vH6U9svt0Y3WOW2F1U5CpjksbtatHUjgAmQn0rbZn2e OT91zXWP1sFFSZhpXFRnRLPq+Z7Aehm/xCy0TfeI= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 12 Mar 2019 19:54:18 +1100 Message-Id: <20190312085502.8203-19-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190312085502.8203-1-david@gibson.dropbear.id.au> References: <20190312085502.8203-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 18/62] spapr: Force SPAPR_MEMORY_BLOCK_SIZE to be a hwaddr (64-bit) 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: lvivier@redhat.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" SPAPR_MEMORY_BLOCK_SIZE is logically a difference in memory addresses, and hence of type hwaddr which is 64-bit. Previously it wasn't marked as such which means that it could be treated as 32-bit. That will work in some circumstances but if multiplied by another 32-bit value it could lead to a 32-bit overflow and an incorrect result. One specific instance of this in spapr_lmb_dt_populate() was spotted by Coverity (CID 1399145). Reported-by: Peter Maydell Signed-off-by: David Gibson --- include/hw/ppc/spapr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index ff1bd60615..1311ebe28e 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -792,7 +792,7 @@ int spapr_rtc_import_offset(sPAPRRTCState *rtc, int64_t= legacy_offset); =20 #define TYPE_SPAPR_RNG "spapr-rng" =20 -#define SPAPR_MEMORY_BLOCK_SIZE (1 << 28) /* 256MB */ +#define SPAPR_MEMORY_BLOCK_SIZE ((hwaddr)1 << 28) /* 256MB */ =20 /* * This defines the maximum number of DIMM slots we can have for sPAPR --=20 2.20.1