From nobody Fri May 3 22:03:18 2024 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; dkim=fail; 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1557145886; cv=none; d=zoho.com; s=zohoarc; b=dB8nJNiJqY2riliZasx8JMAnQcEpFHoF95GSTRq5hvVoqoak//VWHAfY4Qtj9V9u+Lh9bRnCMVcEu1TzF8LF2ij4HRAKzA2q1/s9Yq4bM8kCHo5uz3t/wy6mvwABR6PEIdnULZIYB7pM46G5SxXQA5bEyVR+0u0vHAwUAXhCSAQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557145886; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=BAhXP5CLaXWaYpbxvaw7BJXdE7oN8tDQrIi1PFrfNX4=; b=ahDkAoDxg2XoYVKUaWE+NYXln9P9G6nXgpRrtLbMripm9FwxAJSV2Vz97CSZKtqScWv+sY4cgaUz+L29fsmzBoZT4O8lF1GUM2hv7wIGoE9Xcm0Hz29A78sjcrmTlGzkSO13GviGVSj7BjTQhm1mNDAn0SebKEDmHM4QhLIRI9Y= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557145886348798.9477081908514; Mon, 6 May 2019 05:31:26 -0700 (PDT) Received: from localhost ([127.0.0.1]:55957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNcm7-0008Oy-Oh for importer@patchew.org; Mon, 06 May 2019 08:31:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43844) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNYQ8-0006ZS-Cl for qemu-devel@nongnu.org; Mon, 06 May 2019 03:52:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hNYQ7-0008WI-DO for qemu-devel@nongnu.org; Mon, 06 May 2019 03:52:20 -0400 Received: from mail-qk1-x741.google.com ([2607:f8b0:4864:20::741]:44367) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hNYQ6-0008Vc-2r for qemu-devel@nongnu.org; Mon, 06 May 2019 03:52:18 -0400 Received: by mail-qk1-x741.google.com with SMTP id w25so1217958qkj.11 for ; Mon, 06 May 2019 00:52:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=o5xX3C8tLGSyzOs3XjyCI/c5jOX+7y4gxe446FXclO4=; b=LEab/cdrENZfYOeLAMJbXAit0664xTbbgSwQzhltS2srzsdd3tK9BQK6ti2jvpi5Kg WHLQJGYjF88zIzVmLo0G0xNtdRVnT6995/+4V0t6s0OZkBsW9IKq+F1e8FYoX09aZCyP jJ2ClD8E0baBIhOZrZZ5867j8a//w/3EV1B7kt70zEWOeG82TGQxys3jOEfP57kw+9gn FroI47isaRIQ6iJv+j3SxCOWGwWNOIf4lBL5kPx5nzhxH39PlN5HhMAOhb7UIjr2mHd2 SK2XtFPZT6zP3I/om6ZL+cTvUOxyrQhABcVDmx9Vanun80+IAVyz+zQGfrGEG82c4Kxs swsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=o5xX3C8tLGSyzOs3XjyCI/c5jOX+7y4gxe446FXclO4=; b=EnUEnldYq0rYwfUvdfNLNgFrO8Eg0I2pstECW5LNYAntq2eB8wFJSJ86J7rhX4eSNR cd6vxWYmnZ7h76BPgzzOCt9uHyB4hY8kojNUjg0oEKYmHVzRafB7C47NI4iD/FR0PrPZ pxAXKNB7gydtyOR6bNfgLt4yk5CoDsvnPSrtXwzlzrm0gcOfEOF9JHsdHKJ9RyF7na+S yEm92T0xphG5GX6nA2ezPbvq9nnpe9U6+pyTQUF9KqqdUvxxf/GMMe74nNJ6q628exTB 41Ut/tD5YbBgrLmrb1nZo+Ej7yTuQPzYQD8zh8lONPSgemxM25pIp3dYsXQ8d3K7nUWO N8Gg== X-Gm-Message-State: APjAAAUATilDHfaRNMfESbQfiucf8iHjGa7AK1n9uxTLyZaQjhhwhPHJ 9PcfJWjebmJJ7vLZd1jsl4qb69t6KlPGxJiU5kA= X-Google-Smtp-Source: APXvYqy2ZjPKUsoWkJ1G99ABRoTybQk01HKjoTzE/SV52MMz2cWpO+8vuM8DtxstGMp5tVQ067fGcT0XHCOPqYn8JH0= X-Received: by 2002:a37:a5c6:: with SMTP id o189mr5022926qke.318.1557129136290; Mon, 06 May 2019 00:52:16 -0700 (PDT) MIME-Version: 1.0 From: Hou Qiming Date: Mon, 6 May 2019 15:50:18 +0800 Message-ID: To: Gerd Hoffmann X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::741 X-Mailman-Approved-At: Mon, 06 May 2019 08:29:53 -0400 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: [Qemu-devel] Patch: Precautionary glBindTexture 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: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From 48d1f092a7960d711fb2c77ab8d3f9d0a0ca0d5c Mon Sep 17 00:00:00 2001 From: HQM Date: Mon, 6 May 2019 15:37:59 +0800 Subject: [PATCH] Precautionary glBindTexture and surface->texture validation in surface_gl_update_texture 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: HQM Tested-by: Marcel Apfelbaum --- 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 a56e1cd..c1cb3bd 100644 --- a/ui/console-gl.c +++ b/ui/console-gl.c @@ -92,13 +92,17 @@ void surface_gl_update_texture(QemuGLShader *gls, assert(gls); - 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); + 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); + } } void surface_gl_render_texture(QemuGLShader *gls, --=20 2.17.1