From nobody Tue May 7 20:29:06 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510228789796584.0126971757818; Thu, 9 Nov 2017 03:59:49 -0800 (PST) Received: from localhost ([::1]:36386 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eClUW-0005Dv-Pq for importer@patchew.org; Thu, 09 Nov 2017 06:59:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48982) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eClTd-0004l8-Nm for qemu-devel@nongnu.org; Thu, 09 Nov 2017 06:58:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eClTd-0003TL-0z for qemu-devel@nongnu.org; Thu, 09 Nov 2017 06:58:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51682) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eClTY-0003OW-OA; Thu, 09 Nov 2017 06:58:28 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA28699D5E; Thu, 9 Nov 2017 11:58:26 +0000 (UTC) Received: from localhost.localdomain (vpn2-54-72.bne.redhat.com [10.64.54.72]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 994FA60012; Thu, 9 Nov 2017 11:58:21 +0000 (UTC) From: P J P To: Qemu Developers Date: Thu, 9 Nov 2017 17:28:14 +0530 Message-Id: <20171109115814.28232-1-ppandit@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 09 Nov 2017 11:58:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] highbank: validate register offset before access 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: Peter Maydell , qemu-arm@nongnu.org, Moguofang , Prasad J Pandit Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Prasad J Pandit An 'offset' parameter sent to highbank register r/w functions could be greater than number(NUM_REGS=3D0x200) of hb registers, leading to an OOB access issue. Add check to avoid it. Reported-by: Moguofang (Dennis mo) Signed-off-by: Prasad J Pandit --- hw/arm/highbank.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c index 354c6b25a8..94df151454 100644 --- a/hw/arm/highbank.c +++ b/hw/arm/highbank.c @@ -117,6 +117,9 @@ static void hb_regs_write(void *opaque, hwaddr offset, } } =20 + if (offset / 4 >=3D NUM_REGS) { + return; + } regs[offset/4] =3D value; } =20 @@ -124,6 +127,10 @@ static uint64_t hb_regs_read(void *opaque, hwaddr offs= et, unsigned size) { uint32_t *regs =3D opaque; + + if (offset / 4 >=3D NUM_REGS) { + return 0; + } uint32_t value =3D regs[offset/4]; =20 if ((offset =3D=3D 0x100) || (offset =3D=3D 0x108) || (offset =3D=3D 0= x10C)) { --=20 2.13.6