From nobody Thu Apr 30 00:39:37 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1776147178; cv=none; d=zohomail.com; s=zohoarc; b=TNw5x0TRLKJp6Gy1WtZeg1DqpdtyWq6o86uOKqxRZbyyl+pP0hN/OuKsHmvWclUDYLcXhsBSDGTrLAE7cqVsGLbnaKJGa5E1SHiH63KEREwJ51qmbwzw+mnrbF675t5Z4fS2tEbRBWexW/8+BurcDrB9FT2TSfZfIHLW6Rd+OwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776147178; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=N/hmCtJUyhDZtlNF474DtEetSSoAp5CYk9e1gMvgOZo=; b=neM/CvBZAyk0yX6ynxm0g0Q1sfTq5nQUxhOE71Z912f0cgDUmorYkR4EmHsgVXV26TARvQwp6WLRlFxqwCXCgmBNLpOcqJxBxqenP+wsA0A/MaTt0Y74X2MpryLurCsp8NHxWZ4soGpdq8Jau+wZXI07Hx0vVptJY4Z806cM6lI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776147178500221.9275005623906; Mon, 13 Apr 2026 23:12:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wCX0M-0004Ao-QL; Tue, 14 Apr 2026 02:12:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wCX0L-0004A7-AC; Tue, 14 Apr 2026 02:12:09 -0400 Received: from mgamail.intel.com ([192.198.163.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wCX0I-0002Uw-Vq; Tue, 14 Apr 2026 02:12:08 -0400 Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2026 23:12:03 -0700 Received: from junjie-optiplex-micro-plus-7010.bj.intel.com ([10.238.152.98]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2026 23:12:01 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1776147127; x=1807683127; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=3XvAI5ocW9PBGVckY0gOKaJpApfDZp5w06MPw8ikhDA=; b=KN2ulJ7j1qNNUlV/P7dVtrZfrJelYmYm5smUOh7nSZpOnlINphjY1NRG 1pqiYKsW4Iz0UeWSxkQxHFP3cGm1XGWjdguBfI3FcbyFyE4eQppZO01gW i436zGX2OpMf2fCd0KDpiz0qFVjEJkLxj6IhAUdqvUINX6R2/q492W2m+ BJdyfKC25KzEy67+kaFjDnxK58CZrh/8qhll6edSujDokXCeMn1hV9ifZ GX8xhPZxy9H/orviVhoAwBiAqkJrJp2J95HHk9YKIkr66I0cy6gu7LUkO 8l3r6+VXVilGTM4ruSERvhkLtFZwrS919LYJewcGFwg+da4kQ63Q+AZC7 w==; X-CSE-ConnectionGUID: FHVjNO7jQr+7V65OybofjA== X-CSE-MsgGUID: cOXI+AcVRvqXCd2gU6qW1g== X-IronPort-AV: E=McAfee;i="6800,10657,11758"; a="76125915" X-IronPort-AV: E=Sophos;i="6.23,179,1770624000"; d="scan'208";a="76125915" X-CSE-ConnectionGUID: SzLqRB7ZQK2UJLXtHiG/hg== X-CSE-MsgGUID: 6wWTaxqJSPSFvYs9baRHVQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,179,1770624000"; d="scan'208";a="231729218" From: Junjie Cao To: qemu-devel@nongnu.org Cc: BALATON Zoltan , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , junjie.cao@intel.com, qemu-stable@nongnu.org Subject: [PATCH] ati-vga: fix unsigned integer overflow in cursor bounds checks Date: Tue, 14 Apr 2026 22:14:58 +0800 Message-ID: <20260414141458.1076014-1-junjie.cao@intel.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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=lists1p.gnu.org; Received-SPF: pass client-ip=192.198.163.19; envelope-from=junjie.cao@intel.com; helo=mgamail.intel.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DATE_IN_FUTURE_06_12=1.947, DKIMWL_WL_HIGH=-0.54, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1776147181857154100 Content-Type: text/plain; charset="utf-8" The cursor bounds checks compare (srcoff + N) against vram_size, but both sides are uint32_t so the addition can wrap past UINT32_MAX when srcoff underflows from the cur_hv_offs subtraction, causing the check to be bypassed. Rewrite the checks as (srcoff > vram_size - N) to avoid the overflow-prone addition, matching the style already used in ati_mm_read() and ati_mm_write(). Fixes: 2f1fbe6ee9b5 ("ati-vga: Make sure hardware cursor data is within vra= m") Cc: qemu-stable@nongnu.org Signed-off-by: Junjie Cao Reviewed-by; BALATON Zoltan --- Found while running local QEMU fuzz testing. hw/display/ati.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/display/ati.c b/hw/display/ati.c index 88a5bbbf07..0489995d00 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -149,7 +149,7 @@ static void ati_cursor_define(ATIVGAState *s) /* FIXME handle cur_hv_offs correctly */ srcoff =3D s->regs.cur_offset - (s->regs.cur_hv_offs >> 16) - (s->regs.cur_hv_offs & 0xffff) * 16; - if (srcoff + 64 * 16 > s->vga.vram_size) { + if (srcoff > s->vga.vram_size - 64 * 16) { return; } for (int i =3D 0; i < 64; i++, srcoff +=3D 16) { @@ -206,7 +206,7 @@ static void ati_cursor_draw_line(VGACommonState *vga, u= int8_t *d, int scr_y) } /* FIXME handle cur_hv_offs correctly */ srcoff =3D s->cursor_offset + (scr_y - vga->hw_cursor_y) * 16; - if (srcoff + 16 > s->vga.vram_size) { + if (srcoff > s->vga.vram_size - 16) { return; } dp =3D &dp[vga->hw_cursor_x]; --=20 2.43.0