From nobody Sun Feb 8 23:16:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=1558109677; cv=none; d=zoho.com; s=zohoarc; b=WeDTGpJwZIgAPFfxBg1CKjy0k2QZ97h0Cai/D0uLPvEwWbO80+UDvvWX6u/1QLuCOAnH4ABEltRwafUUi74iVG2Ys92R3hvZ5mJPPmFMNFRVsLsHn0JN0ZE01ycJvyMu4C7RHgL2S8bEnBjNQo27UB5laJC6kAXOMCKkBAG7Gxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558109677; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=r1k5TDGeTWtGrz/6Bqp8Hzyp52q84r1UtpZRaHJixMw=; b=drt7KMctqgEVOC/sqIxMaUpuvER0cdTCeHIH/Z6cqqOLQZc6TfOLBxqiyKX7EV6zFekziS/2+qA3V/1OtU+16IgPohFJJqR7xSK91gY3u8K2RUMHRyKvi9YYftrZ79LbHleRBc197aPbTGLFqk9zHtYx/g2iBNFyDTZQy2OqAOc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558109677390612.2268589688342; Fri, 17 May 2019 09:14:37 -0700 (PDT) Received: from localhost ([127.0.0.1]:50837 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRfV2-00056i-SN for importer@patchew.org; Fri, 17 May 2019 12:14:24 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRfTh-000420-0W for qemu-devel@nongnu.org; Fri, 17 May 2019 12:13:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRfTf-000827-9h for qemu-devel@nongnu.org; Fri, 17 May 2019 12:13:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58990) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hRfTf-0007v7-3T for qemu-devel@nongnu.org; Fri, 17 May 2019 12:12:59 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1E3AA30BBE84; Fri, 17 May 2019 16:12:45 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-74.ams2.redhat.com [10.36.117.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9988A5D719; Fri, 17 May 2019 16:12:42 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id BB54F17534; Fri, 17 May 2019 18:12:41 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 17 May 2019 18:12:40 +0200 Message-Id: <20190517161241.11813-4-kraxel@redhat.com> In-Reply-To: <20190517161241.11813-1-kraxel@redhat.com> References: <20190517161241.11813-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 17 May 2019 16:12:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/4] ui/console: Precautionary glBindTexture and surface->texture validation in surface_gl_update_texture 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 , HOU Qiming Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: HOU Qiming In a GVT-g setup with dmabuf and GTK GUI, the current 2D texture at surface_gl_update_texture is not necessarily surface->texture. Adding a glBindTexture fixes related crashes and artifacts, and is generally more secure. Signed-off-by: HOU Qiming Tested-by: Marcel Apfelbaum Signed-off-by: Marcel Apfelbaum Message-id: 20190507080501.26712-1-marcel.apfelbaum@gmail.com [fixed malformed patch, rebase to master] Signed-off-by: Marcel Apfelbaum Signed-off-by: Gerd Hoffmann --- ui/console-gl.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ui/console-gl.c b/ui/console-gl.c index a56e1cd8ebce..c1cb3bd67359 100644 --- a/ui/console-gl.c +++ b/ui/console-gl.c @@ -92,13 +92,17 @@ void surface_gl_update_texture(QemuGLShader *gls, =20 assert(gls); =20 - glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, - surface_stride(surface) / surface_bytes_per_pixel(surfac= e)); - glTexSubImage2D(GL_TEXTURE_2D, 0, - x, y, w, h, - surface->glformat, surface->gltype, - data + surface_stride(surface) * y - + surface_bytes_per_pixel(surface) * x); + if (surface->texture) { + glBindTexture(GL_TEXTURE_2D, surface->texture); + glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, + surface_stride(surface) + / surface_bytes_per_pixel(surface)); + glTexSubImage2D(GL_TEXTURE_2D, 0, + x, y, w, h, + surface->glformat, surface->gltype, + data + surface_stride(surface) * y + + surface_bytes_per_pixel(surface) * x); + } } =20 void surface_gl_render_texture(QemuGLShader *gls, --=20 2.18.1