From nobody Sun Feb 8 13:45:25 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603023211; cv=none; d=zohomail.com; s=zohoarc; b=BQNIPFM5JqcoEfHaDwKOl5OzTbNVeYOqU5T/dfF8JRDJ1wQD5M7uWeaRHXz1G2GokKmMcFhJNPMC0mHRj3KcHh7Yt75aj2QiK5Qc84UMpXlXLzw5WpHP3ybHdcPKJuhy7fneTvHiDJmvYAPZdw+gtxYH2ptuPkvdCaORP/gSvPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603023211; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=uQPbboVlYsym3DZZ98GZqBFEfIZQntDHqWrB618Alis=; b=S2BRqMZOCKfjAIuChRc4p1XDaKa/BAxadqGKLcyWPDsoBOWlkql22RgvgXpP7kl8w0bSVNhLnYlh2weiVIRTGx6Vwxe1RMOCgsc6E9jlnh1ffypPCM+81vgXos94y3tCp6kmXbG3QcOxnJzti3pXcdENqYN53SIg8h1EfSogJKc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603023211756847.3666092727077; Sun, 18 Oct 2020 05:13:31 -0700 (PDT) Received: from localhost ([::1]:57370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kU7Z4-0002pV-2C for importer@patchew.org; Sun, 18 Oct 2020 08:13:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48222) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kU7Wr-00025T-Ct for qemu-devel@nongnu.org; Sun, 18 Oct 2020 08:11:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33056) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kU7Wm-0004QE-NQ for qemu-devel@nongnu.org; Sun, 18 Oct 2020 08:11:12 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-305-0139t6IrMf2QxWNMTzjsig-1; Sun, 18 Oct 2020 08:11:04 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ACD2A1005E6B; Sun, 18 Oct 2020 12:11:02 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-6.ams2.redhat.com [10.36.112.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 077675B4A1; Sun, 18 Oct 2020 12:10:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603023066; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uQPbboVlYsym3DZZ98GZqBFEfIZQntDHqWrB618Alis=; b=WTp77+lQzqyBtHrrvx6SLm4vOUd2YbDx/u4bVAbJaE1iq6YqRyt0QAWFeVGZkr88Qz8F29 F8Jj4FjwIo8aU4fz9GyzDMBPdBGbqd2CXk77WK1VstClG6VP7vz/RFsWSkzSn6WO7Mi6ob /LbZGXdzbgnuRcYaAV3rMi6MoQBEAxk= X-MC-Unique: 0139t6IrMf2QxWNMTzjsig-1 From: P J P To: Gerd Hoffmann Subject: [PATCH] ati: mask x y display parameter values Date: Sun, 18 Oct 2020 17:38:52 +0530 Message-Id: <20201018120852.1415440-1-ppandit@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ppandit@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=ppandit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/18 07:11:38 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Gaoning Pan , QEMU Developers , Prasad J Pandit Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Prasad J Pandit The source and destination x,y display parameters in ati_2d_blt() may run off the vga limits if either of s->regs.[src|dst]_[xy] is zero. Mask the register values to avoid potential crash. Reported-by: Gaoning Pan Signed-off-by: Prasad J Pandit --- hw/display/ati_2d.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index 23a8ae0cd8..524bc03a83 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -53,10 +53,10 @@ void ati_2d_blt(ATIVGAState *s) s->vga.vbe_start_addr, surface_data(ds), surface_stride(ds), surface_bits_per_pixel(ds), (s->regs.dp_mix & GMC_ROP3_MASK) >> 16); - unsigned dst_x =3D (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT ? - s->regs.dst_x : s->regs.dst_x + 1 - s->regs.dst_widt= h); - unsigned dst_y =3D (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ? - s->regs.dst_y : s->regs.dst_y + 1 - s->regs.dst_heig= ht); + unsigned dst_x =3D (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT ? s->regs.ds= t_x + : (s->regs.dst_x + 1 - s->regs.dst_width) & 0x3fff= ); + unsigned dst_y =3D (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ? s->regs.ds= t_y + : (s->regs.dst_y + 1 - s->regs.dst_height) & 0x3ff= f); int bpp =3D ati_bpp_from_datatype(s); if (!bpp) { qemu_log_mask(LOG_GUEST_ERROR, "Invalid bpp\n"); @@ -91,9 +91,9 @@ void ati_2d_blt(ATIVGAState *s) case ROP3_SRCCOPY: { unsigned src_x =3D (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT ? - s->regs.src_x : s->regs.src_x + 1 - s->regs.dst_wid= th); + s->regs.src_x : (s->regs.src_x + 1 - s->regs.dst_width) & 0x3ff= f); unsigned src_y =3D (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ? - s->regs.src_y : s->regs.src_y + 1 - s->regs.dst_hei= ght); + s->regs.src_y : (s->regs.src_y + 1 - s->regs.dst_height) & 0x3f= ff); int src_stride =3D DEFAULT_CNTL ? s->regs.src_pitch : s->regs.default_pitch; if (!src_stride) { --=20 2.26.2