{"id":2221203,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2221203/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260408104935.1A55A5969F6@zero.eik.bme.hu/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.1/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260408104935.1A55A5969F6@zero.eik.bme.hu>","date":"2026-04-08T10:49:35","name":"[v2] ati-vga: Fix check for overflowing vram","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"eaddb97c27d9b7e2249852e7a2ea393f5611ec31","submitter":{"id":16148,"url":"http://patchwork.ozlabs.org/api/1.1/people/16148/?format=json","name":"BALATON Zoltan","email":"balaton@eik.bme.hu"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260408104935.1A55A5969F6@zero.eik.bme.hu/mbox/","series":[{"id":499205,"url":"http://patchwork.ozlabs.org/api/1.1/series/499205/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=499205","date":"2026-04-08T10:49:35","name":"[v2] ati-vga: Fix check for overflowing vram","version":2,"mbox":"http://patchwork.ozlabs.org/series/499205/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2221203/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2221203/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":"legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)","Received":["from lists.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4frYQz4PcBz1yD6\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 09 Apr 2026 05:43:55 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wAYau-0000q7-Hf; Wed, 08 Apr 2026 15:29:45 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <balaton@eik.bme.hu>)\n id 1wAY8O-0008Ga-UM\n for qemu-devel@nongnu.org; Wed, 08 Apr 2026 15:00:16 -0400","from zero.eik.bme.hu ([2001:738:2001:2001::2001])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <balaton@eik.bme.hu>)\n id 1wAQTd-0003rE-EL\n for qemu-devel@nongnu.org; Wed, 08 Apr 2026 06:49:43 -0400","from localhost (localhost [127.0.0.1])\n by zero.eik.bme.hu (Postfix) with ESMTP id 2A31D596A23;\n Wed, 08 Apr 2026 12:49:37 +0200 (CEST)","from zero.eik.bme.hu ([127.0.0.1])\n by localhost (zero.eik.bme.hu [127.0.0.1]) (amavis, port 10028) with ESMTP\n id 1BsFWgsbyCBn; Wed,  8 Apr 2026 12:49:35 +0200 (CEST)","by zero.eik.bme.hu (Postfix, from userid 432)\n id 1A55A5969F6; Wed, 08 Apr 2026 12:49:35 +0200 (CEST)"],"X-Virus-Scanned":"amavis at eik.bme.hu","From":"BALATON Zoltan <balaton@eik.bme.hu>","Subject":"[PATCH v2] ati-vga: Fix check for overflowing vram","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","To":"qemu-devel@nongnu.org","Cc":"Gerd Hoffmann <kraxel@redhat.com>, marcandre.lureau@redhat.com,\n Chad Jablonski <chad@jablonski.xyz>,\n =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <philmd@linaro.org>,\n Peter Maydell <peter.maydell@linaro.org>","Message-Id":"<20260408104935.1A55A5969F6@zero.eik.bme.hu>","Date":"Wed, 08 Apr 2026 12:49:35 +0200 (CEST)","Received-SPF":"pass client-ip=2001:738:2001:2001::2001;\n envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu","X-Spam_score_int":"-18","X-Spam_score":"-1.9","X-Spam_bar":"-","X-Spam_report":"(-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001,\n 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.29","Precedence":"list","List-Id":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"Take into account the bytes per pixels when checking for accessing\nbeyond end of vram area.\n\nSigned-off-by: BALATON Zoltan <balaton@eik.bme.hu>\n---\nv2: Also end of accessed region should take bypp into account\n\n hw/display/ati_2d.c | 13 +++++++------\n 1 file changed, 7 insertions(+), 6 deletions(-)","diff":"diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c\nindex f0f77cecc6..504d1c5708 100644\n--- a/hw/display/ati_2d.c\n+++ b/hw/display/ati_2d.c\n@@ -146,6 +146,7 @@ static uint32_t make_filler(int bpp, uint32_t color)\n static bool ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_pixman)\n {\n     QemuRect vis_src, vis_dst;\n+    unsigned int x, y, i, j, bypp = ctx->bpp / 8;\n \n     if (!ctx->bpp) {\n         qemu_log_mask(LOG_GUEST_ERROR, \"Invalid bpp\\n\");\n@@ -156,8 +157,9 @@ static bool ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_pixman)\n         return false;\n     }\n     if (ctx->dst.x > 0x3fff || ctx->dst.y > 0x3fff ||\n-        ctx->dst_bits >= ctx->vram_end || ctx->dst_bits + ctx->dst.x +\n-        (ctx->dst.y + ctx->dst.height) * ctx->dst_stride >= ctx->vram_end) {\n+        ctx->dst_bits >= ctx->vram_end - bypp ||\n+        ctx->dst_bits + ctx->dst.x * bypp + (ctx->dst.y + ctx->dst.height) *\n+        ctx->dst_stride >= ctx->vram_end - bypp) {\n         qemu_log_mask(LOG_UNIMP, \"blt outside vram not implemented\\n\");\n         return false;\n     }\n@@ -194,8 +196,9 @@ static bool ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_pixman)\n         }\n         if (!ctx->host_data_active &&\n             (vis_src.x > 0x3fff || vis_src.y > 0x3fff ||\n-            ctx->src_bits >= ctx->vram_end || ctx->src_bits + vis_src.x +\n-            (vis_src.y + vis_dst.height) * ctx->src_stride >= ctx->vram_end)) {\n+            ctx->src_bits >= ctx->vram_end - bypp ||\n+            ctx->src_bits + vis_src.x * bypp + (vis_src.y + vis_dst.height) *\n+            ctx->src_stride >= ctx->vram_end - bypp)) {\n             qemu_log_mask(LOG_UNIMP, \"blt outside vram not implemented\\n\");\n             return false;\n         }\n@@ -240,7 +243,6 @@ static bool ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_pixman)\n             fallback = true;\n         }\n         if (fallback) {\n-            unsigned int y, i, j, bypp = ctx->bpp / 8;\n             for (y = 0; y < vis_dst.height; y++) {\n                 i = vis_dst.x * bypp;\n                 j = vis_src.x * bypp;\n@@ -299,7 +301,6 @@ static bool ati_2d_do_blt(ATI2DCtx *ctx, uint8_t use_pixman)\n #endif\n         {\n             /* fallback when pixman failed or we don't want to call it */\n-            unsigned int x, y, i, bypp = ctx->bpp / 8;\n             for (y = 0; y < vis_dst.height; y++) {\n                 i = vis_dst.x * bypp + (vis_dst.y + y) * ctx->dst_stride;\n                 for (x = 0; x < vis_dst.width; x++, i += bypp) {\n","prefixes":["v2"]}