From nobody Fri Apr 19 18:58:51 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 Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507671917842506.2298151167786; Tue, 10 Oct 2017 14:45:17 -0700 (PDT) Received: from localhost ([::1]:37288 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e22Ku-0001E9-3I for importer@patchew.org; Tue, 10 Oct 2017 17:45:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38756) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e22CM-0002G1-7J for qemu-devel@nongnu.org; Tue, 10 Oct 2017 17:36:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e22CL-0001nr-8z for qemu-devel@nongnu.org; Tue, 10 Oct 2017 17:36:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36204) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e22CL-0001lA-2Q for qemu-devel@nongnu.org; Tue, 10 Oct 2017 17:36:21 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 71FD025767; Tue, 10 Oct 2017 21:36:19 +0000 (UTC) Received: from localhost.localdomain (ovpn-117-99.phx2.redhat.com [10.3.117.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BE66A1883E; Tue, 10 Oct 2017 21:36:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 71FD025767 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ppandit@redhat.com From: P J P To: Qemu Developers Date: Wed, 11 Oct 2017 03:06:08 +0530 Message-Id: <20171010213608.31567-1-ppandit@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 10 Oct 2017 21:36:19 +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] cirrus: keep vga vram pointer within bounds 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: Gerd Hoffmann , Niu Guoxiang , Prasad J Pandit 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" From: Prasad J Pandit 'dst' pointer could exceed vga vram size when writing to the cirrus memory area; it'd lead to an OOB access issue. Add check to avoid it. Reported-by: Niu Guoxiang Signed-off-by: Prasad J Pandit --- hw/display/cirrus_vga.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c index afc290ab91..451a736262 100644 --- a/hw/display/cirrus_vga.c +++ b/hw/display/cirrus_vga.c @@ -2047,8 +2047,11 @@ static void cirrus_mem_writeb_mode4and5_8bpp(CirrusV= GAState * s, } val <<=3D 1; dst++; + if (dst >=3D s->vga.vram_ptr + s->vga.vram_size) { + break; + } } - memory_region_set_dirty(&s->vga.vram, offset, 8); + memory_region_set_dirty(&s->vga.vram, offset, x); } =20 static void cirrus_mem_writeb_mode4and5_16bpp(CirrusVGAState * s, @@ -2071,8 +2074,11 @@ static void cirrus_mem_writeb_mode4and5_16bpp(Cirrus= VGAState * s, } val <<=3D 1; dst +=3D 2; + if (dst >=3D s->vga.vram_ptr + s->vga.vram_size) { + break; + } } - memory_region_set_dirty(&s->vga.vram, offset, 16); + memory_region_set_dirty(&s->vga.vram, offset, x<<1); } =20 /*************************************** --=20 2.13.6