From patchwork Tue Aug 4 14:00:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 11700473 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 082CB913 for ; Tue, 4 Aug 2020 14:05:34 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E56112075F for ; Tue, 4 Aug 2020 14:05:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gmx.net header.i=@gmx.net header.b="FD9sHxKp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E56112075F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:52674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2xZN-0003Xv-0a for patchwork-qemu-devel@patchwork.kernel.org; Tue, 04 Aug 2020 10:05:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2xVQ-0000qI-NO for qemu-devel@nongnu.org; Tue, 04 Aug 2020 10:01:28 -0400 Received: from mout.gmx.net ([212.227.15.15]:34825) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2xVO-00039L-Mv for qemu-devel@nongnu.org; Tue, 04 Aug 2020 10:01:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1596549659; bh=y9/0kXDAkWHkYY6NN8um6Z2aRXFPdGg7kDlpxDyaF8A=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=FD9sHxKpybhF6JzY0tAiS7lFioMC7iwyDzs8/0SihmNV5IYsjzlZdXID3KPaCgzj5 Xe2keQdrOPpL2ooqEt79N8+vlVwXb4BLb2NorACcEdda4ISXCI++C1EBGDBQx57QFx BRCul3AzwuOFzB11EgQ28AhXQGz0VRWncTdtKC10= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from ls3530.fritz.box ([92.116.144.148]) by mail.gmx.com (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M5fMe-1k5iNd2Fas-007B6l; Tue, 04 Aug 2020 16:00:59 +0200 From: Helge Deller To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PATCH v3 4/8] hw/display/artist.c: fix out of bounds check Date: Tue, 4 Aug 2020 16:00:52 +0200 Message-Id: <20200804140056.7690-5-deller@gmx.de> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200804140056.7690-1-deller@gmx.de> References: <20200804140056.7690-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:xxkvc81/3YA1k8mzHxwz97o/FeuTD5eQ3lPnvUIHF6TIOcuh86R tN1VlCTnPBAyWdK8s61b1h/EoExnS7XLlawqhJPEKbM5yjcBxB4tpy61NVcmXrkIqmm+8HS /YKqvkeDoohps3HVlPPwtOyb0hLPMYPT97TjjpOuNGpJx28agOg/UM9R1Abiw3/960MvCpG V2UhDiD8oB9IeCQGT3deA== X-UI-Out-Filterresults: notjunk:1;V03:K0:llVXWnup/xQ=:NPf8Cv/VzrbB+gMcM+Pp7X 4EIztvpa0MvhZm26GOxGUzJwItXhVPIGc9YOvWwyqOo+L+sb/ZXwFNCGHLvVMnKz51UGH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Jms293VIFK0MI1yPS6n quLjwB2WSmoLBINdwlXkUOmrG1q/1+IkenwMGqVEBnR20L99ETCJLv4N10oJjX2PaD6S3uo9h 1DCLd3sNk21lEP0g2 Received-SPF: pass client-ip=212.227.15.15; envelope-from=deller@gmx.de; helo=mout.gmx.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/04 08:28:01 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Helge Deller , Sven Schnelle , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Sven Schnelle Fix the following runtime warning with artist framebuffer: "write outside bounds: wants 1256x1023, max size 1280x1024" Reviewed-by: Richard Henderson Signed-off-by: Sven Schnelle Signed-off-by: Helge Deller --- hw/display/artist.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) -- 2.21.3 diff --git a/hw/display/artist.c b/hw/display/artist.c index 6261bfe65b..de56200dbf 100644 --- a/hw/display/artist.c +++ b/hw/display/artist.c @@ -340,14 +340,13 @@ static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x, { struct vram_buffer *buf; uint32_t vram_bitmask = s->vram_bitmask; - int mask, i, pix_count, pix_length, offset, height, width; + int mask, i, pix_count, pix_length, offset, width; uint8_t *data8, *p; pix_count = vram_write_pix_per_transfer(s); pix_length = vram_pixel_length(s); buf = vram_write_buffer(s); - height = buf->height; width = buf->width; if (s->cmap_bm_access) { @@ -367,13 +366,6 @@ static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x, pix_count = size * 8; } - if (posy * width + posx + pix_count > buf->size) { - qemu_log("write outside bounds: wants %dx%d, max size %dx%d\n", - posx, posy, width, height); - return; - } - - switch (pix_length) { case 0: if (s->image_bitmap_op & 0x20000000) { @@ -381,8 +373,11 @@ static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x, } for (i = 0; i < pix_count; i++) { - artist_rop8(s, p + offset + pix_count - 1 - i, - (data & 1) ? (s->plane_mask >> 24) : 0); + uint32_t off = offset + pix_count - 1 - i; + if (off < buf->size) { + artist_rop8(s, p + off, + (data & 1) ? (s->plane_mask >> 24) : 0); + } data >>= 1; } memory_region_set_dirty(&buf->mr, offset, pix_count); @@ -398,7 +393,10 @@ static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x, for (i = 3; i >= 0; i--) { if (!(s->image_bitmap_op & 0x20000000) || s->vram_bitmask & (1 << (28 + i))) { - artist_rop8(s, p + offset + 3 - i, data8[ROP8OFF(i)]); + uint32_t off = offset + 3 - i; + if (off < buf->size) { + artist_rop8(s, p + off, data8[ROP8OFF(i)]); + } } } memory_region_set_dirty(&buf->mr, offset, 3); @@ -420,7 +418,7 @@ static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x, break; } - for (i = 0; i < pix_count; i++) { + for (i = 0; i < pix_count && offset + i < buf->size; i++) { mask = 1 << (pix_count - 1 - i); if (!(s->image_bitmap_op & 0x20000000) ||