From nobody Mon Nov 23 04:44:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794299607; cv=none; d=zohomail.com; s=zohoarc; b=a3SpyDdOFgwcBETJvMm7WQHDRhMLNLLDrNbOTrFyMs5emJjrO2WBE7OStGrAAcfmN6y+mvCTUzv4nVm7rDiZrPJfSBiQcPOX+2edIHMhn14RcrCF2TPXHufMjhYqGfUHFTkyGvPdq7jCNeToThvt144PoAh+lQYsZLP4BSiNuzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794299607; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To: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=g4+PeeUg1L0PvbmpaMiBoNKFbJTrOkGimcAzCBgBaxw=; b=febYZkTAcNVyWE+bFB+Obys9LI8BdWWeXJZ5XoKWBFHgwxPIQ425UiKnGpymGsmyd9KVSoS04FwePkcJa1X9a8qh4cNcV6hkT3Qs9sfA3e/5DqKp8Q7ihWH9ZdFBlNY1dcOd/WVFRqbGucSlfBOuMNMPAtI9WbDwx+JvQsUorng= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794299607275820.5015628795232; Tue, 10 Nov 2026 00:33:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQhI1-00054x-3o; Tue, 10 Nov 2026 03:33:13 -0500 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 1xQhHy-0004xu-1M for qemu-devel@nongnu.org; Tue, 10 Nov 2026 03:33:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQhHw-0003OY-Fo for qemu-devel@nongnu.org; Tue, 10 Nov 2026 03:33:09 -0500 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661-en7ZyXRzOJSEHEbXlLFPXQ-1; Tue, 10 Nov 2026 03:33:05 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9B0AC1955EB5; Tue, 10 Nov 2026 08:33:03 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 22CCB18004E9; Tue, 10 Nov 2026 08:33:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794299586; 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: in-reply-to:in-reply-to:references:references; bh=g4+PeeUg1L0PvbmpaMiBoNKFbJTrOkGimcAzCBgBaxw=; b=XvPjnG/9ib9L+nWiGF8zRfdx7DpAQVZk0Q9fkQxFdhRnyTarqeqBQK42+ZDROVPX8htjan TVY+3YmllDk/UQDJ0DFpK5tqcv9AOw3BeOayGgphXOgcCyCOPAQ+vV462A3oJRl7SgHay+ n51vPOUccgTDtsJ0d5b7fmO89Wj+62s= X-MC-Unique: en7ZyXRzOJSEHEbXlLFPXQ-1 X-Mimecast-MFC-AGG-ID: en7ZyXRzOJSEHEbXlLFPXQ_1794299584 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Tue, 10 Nov 2026 12:31:11 +0400 Subject: [PATCH 1/4] virtio-gpu: make some 2d callbacks statics MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261110-master-v1-1-7a0505d6c259@redhat.com> References: <20261110-master-v1-0-7a0505d6c259@redhat.com> In-Reply-To: <20261110-master-v1-0-7a0505d6c259@redhat.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , Stefano Garzarella , Gurchetan Singh , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=2331; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=4lwsIzq85WLiw+N7jSTWAcOZ1RbzjQcYyDz8rp6zHuE=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBq8ta3RM+jrHQr5GklixyQrFwPrT3eINLxRCjH+ yMR5K+ac0OJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCavLWtwAKCRDa6OEJdZac 5Tw2EACIjaSoH86ceD3HAQjLmiBOFVFVi/lys+J6IIWMPAdqvIW8biR0j6I0YIpBsW5lbBiZDks hPuOmbN654yj4dxhvmJ0OQaXV7Gc2JXOq8Rps6yfaNmKslYAghDApyGKyc440XDQTYgDldkP/dy szg9wSRbXSOdZ0zUxErFOIwofAK8sI0RgO41MCnR0NKtnZGFrEcFBSu8mhjMgkOQgYlV4Pxcf92 jLBn1LNXziH61QlaLKuqXBb9V8Mu8Pgh7qTjOMY2izdhKcRSHw85f+9mWZGUHGDYp4V+DafNYtJ VrzXnHjc4V9PLy480DjtvR538Cop0XOUy6P+ahJTYc8KEGCQzOZJCTnFoK3Mm0BHdfqXGMD+Juv nlneZ3figwbn+bSPprPYcIngPpPHHwPVaGfaAFS+HUVbO6/JXeOrD5nR+UoLZGcTcwqCgC9Bg+Z Es5CvinIQ2Zx1EQRWQ2LUt7b2oj5P5ophZWTYPZnChyTZNaLz+rP7v7SeJaVnjdM9KFzoiBlgdH 0rQ05lwmM45F06jxHRjbY1JtiJdOp/Tme2Uv8gvGedncQFUTw+/cHlgXV82PlxAFDNIoUy0ewI8 jdOWT9aRDfRkKna9PxjWK3BrsVP517Px4MED2RhsdVKM7cOHNPUFqET28icWoDWMyDPY/UB0vUr YVwD0HJR8U57mXQ== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1794299608932158500 Those functions are not shared with other units. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Akihiko Odaki Reviewed-by: Daniel P. Berrang=C3=A9 --- hw/display/virtio-gpu.c | 12 +++++++----- include/hw/virtio/virtio-gpu.h | 4 ---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 5d43ffb99184..6450f4734861 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -81,9 +81,10 @@ virtio_gpu_simple_resource_new_blob(uint32_t resource_id= , uint64_t blob_size) return res; } =20 -void virtio_gpu_update_cursor_data(VirtIOGPU *g, - struct virtio_gpu_scanout *s, - uint32_t resource_id) +static void +virtio_gpu_update_cursor_data(VirtIOGPU *g, + struct virtio_gpu_scanout *s, + uint32_t resource_id) { struct virtio_gpu_simple_resource *res; uint32_t pixels; @@ -1178,8 +1179,9 @@ virtio_gpu_resource_detach_backing(VirtIOGPU *g, virtio_gpu_cleanup_mapping(g, res); } =20 -void virtio_gpu_simple_process_cmd(VirtIOGPU *g, - struct virtio_gpu_ctrl_command *cmd) +static void +virtio_gpu_simple_process_cmd(VirtIOGPU *g, + struct virtio_gpu_ctrl_command *cmd) { VIRTIO_GPU_FILL_CMD(cmd->cmd_hdr); virtio_gpu_ctrl_hdr_bswap(&cmd->cmd_hdr); diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 631dfc63a4d4..65e96b8fc4de 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -361,10 +361,6 @@ void virtio_gpu_cleanup_mapping(VirtIOGPU *g, void virtio_gpu_process_cmdq(VirtIOGPU *g); void virtio_gpu_device_realize(DeviceState *qdev, Error **errp); void virtio_gpu_reset(VirtIODevice *vdev); -void virtio_gpu_simple_process_cmd(VirtIOGPU *g, struct virtio_gpu_ctrl_co= mmand *cmd); -void virtio_gpu_update_cursor_data(VirtIOGPU *g, - struct virtio_gpu_scanout *s, - uint32_t resource_id); =20 bool virtio_gpu_check_scanout_bounds(uint32_t scanout_id, uint32_t resourc= e_id, uint32_t width, uint32_t height, --=20 2.56.0.116.g6de20f6092dc From nobody Mon Nov 23 04:44:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794299633; cv=none; d=zohomail.com; s=zohoarc; b=HZJPuPuM7xN2eZ3B+OAY3D1EP5VHUi0dC6S08uN2eiH7/XiYMSIBC2YH0+tsxTnfj7QaJA+QAP7SVwiP2uU2CM6SNHsXCSBySo5lC1iLhKb02FZk03gY3PLBEoeE+HJXYm4BGgtvRcugYDg8Wr8BlXCEHVR3N1Bf7FeO5wP0OMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794299633; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To: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=SzxuNv17Zwp7J0czqBKJdXgYVmX5KppsCEe7IfdrFcA=; b=MEhSxRUFZD/SAbfC/i9LSmQljK0Nw7s2z+9nN7A+HtoBR8g8MJlVbMy2fpH3qt8jx9Wnj/wJ3x8j0QBnrsguweihodDyxVOQkbkXaIaI1Zwyd8lmTelqe6YsTWhFqnGrelr4akYi9eBGlGqcZOd7bho78frGh5HxHq8UaO8VC6s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794299633924925.7835784867132; Tue, 10 Nov 2026 00:33:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQhIP-0005ce-3s; Tue, 10 Nov 2026 03:33:38 -0500 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 1xQhI5-0005Kw-CM for qemu-devel@nongnu.org; Tue, 10 Nov 2026 03:33:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQhI3-0003Ox-Mg for qemu-devel@nongnu.org; Tue, 10 Nov 2026 03:33:17 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-500-kqAXGZtFMGKg2ObbTuskew-1; Tue, 10 Nov 2026 03:33:09 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 001AF18002FB; Tue, 10 Nov 2026 08:33:08 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8C6ED1956086; Tue, 10 Nov 2026 08:33:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794299595; 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: in-reply-to:in-reply-to:references:references; bh=SzxuNv17Zwp7J0czqBKJdXgYVmX5KppsCEe7IfdrFcA=; b=B92TcGlYXZe77LbWGC1TgvGIWWNXPMyYvqcOFFHZT+rGQKpho0R/isFehMG1x7hn941tgJ g5ZVESYKs9Z/Gdkocw56WL7mBZxaHGhlsuQWFwOwDe0grn/EZrzMX4xLlkgoW2VUXhGw3Q gJ5HTsqQlTJ6Z7jcBfiEjUPIMr25SBY= X-MC-Unique: kqAXGZtFMGKg2ObbTuskew-1 X-Mimecast-MFC-AGG-ID: kqAXGZtFMGKg2ObbTuskew_1794299588 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Tue, 10 Nov 2026 12:31:12 +0400 Subject: [PATCH 2/4] virtio-gpu/gl: reject non-32bpp cursor resources MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261110-master-v1-2-7a0505d6c259@redhat.com> References: <20261110-master-v1-0-7a0505d6c259@redhat.com> In-Reply-To: <20261110-master-v1-0-7a0505d6c259@redhat.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , Stefano Garzarella , Gurchetan Singh , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=3512; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=T1QIA9gVvv747WfQ9Sv15OLJzjhIMDR/rCKUQyVrVk0=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBq8ta3lF36q+7XjqKzMY9nhYhZvyY0w87aG08uu 3abx+xdcniJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCavLWtwAKCRDa6OEJdZac 5eNVEAC2sFPdQmN2wlwhCQxIhmrKsYRFly2H6T0QHWTlaN4nzpTPLdYlCcLsFTVS1EydnJkrGwV kWJd0pJcP51jCk2g+UJcOUHE+iremmYDKSdI5Vz+qQq/MZMF348eT7WsUTdHnPsYFQm7ZPoAz1Z 2WRvzFcHdlQCe4/I4j6GaI1HswZdNbIA6+JtLAj0bg0Lfvk2p97DAFV1uhIJGfINdF2zuRbAhph tWaiBYy3FC4WcFlmqjzKkGo42VA3+za0IWqk9+wrMVGBcP4+NUpu79dnyFI1j572oB6yJXXWmTv nZ4uzm2TV2JxvnLMLk5Iv77sZRbJfVA0Uz2J5MFEyyM6624qn7dyZhAFWPYjtqslJsFg1a1okve 0oFVX6B4d3P6vx4T2MQndo0Ccp5IF8JfyXqjF7r4KN7tpW+fjHPnarxQhE3/4BBj+ZcfYQqx+5T 2dLK5FrEd8vIOLjFc4dGimJuflUr7qmvK2zX4lxclDo2Vagi+6NrQLyGxn2pnQaH6iT5MbGRYTa VWZ18NbIoITL+DBpSHlbQEHpPa0kPYtIzb955lg2c7hm/1NAQrjfmKA42o8AhTW25QZjw1+Fgos G6qxAMeuoW2wR+zZU3sg9G8B3WsuniQ9UrXJIjRvHkeuAWgngMvLR5ZsG9u9QecGtxkQTdQ7y9O 99sPxziTYSp0tDw== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1794299635837158500 Cursor pixel data is copied as 32bpp, but the resource format is never checked. virgl_renderer_get_cursor_data() sizes its buffer for the resource's own format, while virtio_gpu_gl_update_cursor_data() copies width * height * 4 bytes from it: a 64x64 R8_UNORM resource gives a 4096 byte buffer and a 16384 byte read, so 12 KiB of host heap past the end of the allocation is sent to a connected VNC client as cursor data. Look up the resource format and refuse anything that is not 32bpp, matching what the non-virgl paths accept. Querying the renderer covers blob resources: a blob carries no format in the virtio command and QEMU stores 0 for it. The virgl and virtio format enums have the same values for the accepted formats. Fixes: CVE-2026-122027 Fixes: 9d9e152136bd ("virtio-gpu: add 3d mode and virgl rendering support.") Reported-by: Fernando Bortotti Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-gl.c | 18 ++++++++++++++++++ include/hw/virtio/virtio-gpu-pixman.h | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c index 2b7a41c46643..c314631b05f3 100644 --- a/hw/display/virtio-gpu-gl.c +++ b/hw/display/virtio-gpu-gl.c @@ -31,6 +31,7 @@ static void virtio_gpu_gl_update_cursor_data(VirtIOGPU *g, uint32_t resource_id) { VirtIOGPUGL *gl =3D VIRTIO_GPU_GL(g); + struct virgl_renderer_resource_info info =3D { 0 }; uint32_t width, height; uint32_t pixels, *data; =20 @@ -38,6 +39,20 @@ static void virtio_gpu_gl_update_cursor_data(VirtIOGPU *= g, return; } =20 + virgl_renderer_force_ctx_0(); + if (virgl_renderer_resource_get_info(resource_id, &info) !=3D 0) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: unknown cursor resource %u\n", + __func__, resource_id); + return; + } + + if (!virtio_gpu_format_is_cursor_capable(info.virgl_format)) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: cursor resource %u has unsupported format %u\n", + __func__, resource_id, info.virgl_format); + return; + } + data =3D virgl_renderer_get_cursor_data(resource_id, &width, &height); if (!data) { return; @@ -45,6 +60,9 @@ static void virtio_gpu_gl_update_cursor_data(VirtIOGPU *g, =20 if (width !=3D s->current_cursor->width || height !=3D s->current_cursor->height) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: cursor resource %u has unsupported dimension %u= x%u\n", + __func__, resource_id, width, height); free(data); return; } diff --git a/include/hw/virtio/virtio-gpu-pixman.h b/include/hw/virtio/virt= io-gpu-pixman.h index 4dba782758dc..d6043d2ca1df 100644 --- a/include/hw/virtio/virtio-gpu-pixman.h +++ b/include/hw/virtio/virtio-gpu-pixman.h @@ -42,4 +42,17 @@ virtio_gpu_get_pixman_format(uint32_t virtio_gpu_format) } } =20 +/* + * Cursor data is copied as 32bpp; formats without a pixman mapping are + * rejected. + */ +static inline bool +virtio_gpu_format_is_cursor_capable(uint32_t format) +{ + pixman_format_code_t pformat; + + pformat =3D virtio_gpu_get_pixman_format(format); + return pformat && PIXMAN_FORMAT_BPP(pformat) =3D=3D 32; +} + #endif --=20 2.56.0.116.g6de20f6092dc From nobody Mon Nov 23 04:44:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794299614; cv=none; d=zohomail.com; s=zohoarc; b=BjqHUbhifMnf21uOedV3uAYnmj/t6j/ZbVi2mRPazlSPUD2VU/XJ/hMT7PoS9uRPxRO/GSxi94XSH5ScU2MMIAp1dEzZ1J/p4x15KD8efSJCQMGhBjvfFf7avzPkNsXgDtRwNHsS51krN2/oIl6WNMS7jLhIVsmJua/3rYYQ8dc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794299614; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To: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=4SHKCVN6tm46hUcxVbYTQ1TsH/L3RAfdeJTsmCZxHRM=; b=LPOI/JujZ3+DjGEhcid6M5EXSu63fP2uZ7pez1xYkIqDTbxanidGc88c+6LayrD4I4TmUDZxVZw3dz1pgDJb7ffzeyw9yscBP4bkHspMwQHNMyEsKdOdR3oUtx1798foKKsagpaK2xPf7JfQ1sIH+NZSF9jGRWeUE/wMrKakhTk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794299614206347.26607231852756; Tue, 10 Nov 2026 00:33:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQhI8-0005PS-Gz; Tue, 10 Nov 2026 03:33:20 -0500 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 1xQhI5-0005KX-29 for qemu-devel@nongnu.org; Tue, 10 Nov 2026 03:33:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQhI3-0003Ot-8W for qemu-devel@nongnu.org; Tue, 10 Nov 2026 03:33:16 -0500 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-12-SiVousk4Mk-3GI035XBsXw-1; Tue, 10 Nov 2026 03:33:13 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A29141955EB5; Tue, 10 Nov 2026 08:33:11 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4E48B195E489; Tue, 10 Nov 2026 08:33:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794299594; 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: in-reply-to:in-reply-to:references:references; bh=4SHKCVN6tm46hUcxVbYTQ1TsH/L3RAfdeJTsmCZxHRM=; b=O2OVg2qztjfIEHkECYBt1taOGAgdAxX5pkinKum6A0zNIpVAvfBfrYOq6UVomn4IusLyZI Qs3QsdvliY/K8N+eCf0HIeQycERAgzvk8KAAozxHYSzYRm1sXRL4kurI7rWCrwJIRXPTdU zq4x4IxsJbi/TC9bIWZ8b6uFPvQ/zOY= X-MC-Unique: SiVousk4Mk-3GI035XBsXw-1 X-Mimecast-MFC-AGG-ID: SiVousk4Mk-3GI035XBsXw_1794299592 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Tue, 10 Nov 2026 12:31:13 +0400 Subject: [PATCH 3/4] virtio-gpu/rutabaga: reject non-32bpp cursor resources MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261110-master-v1-3-7a0505d6c259@redhat.com> References: <20261110-master-v1-0-7a0505d6c259@redhat.com> In-Reply-To: <20261110-master-v1-0-7a0505d6c259@redhat.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , Stefano Garzarella , Gurchetan Singh , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=2852; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=UusCNfK4XOsVd8CJXP7eBLC8Ea5qdSROeOTkGYcRSfc=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBq8ta3PVuuLhd/n9L7E2Vu8XB1HqIY9ufjjfMxl IF+QxbJZJ6JAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCavLWtwAKCRDa6OEJdZac 5U+mD/wLa3XbjpmYktFpJ+RqsJGan/eCEzxZ7JVTYcAetNPVDSJd62OB6gKAGSgHBnkxC3//ykv QNJTt/184pX/615YCFNBgXYEi0Uai70KslY/LNMwg+PivEvBFN2bKxqZGwi+ZNVYWa+wPwkbwyc LQc4bpupiNBMyDFqndwr/dbisZ2Q5WyRIiuONjRK6bMWHbDp88f4QKep0dSYl/Io5xpAwho7NqF zCnAJmv+wNTUBpSoY3xz11pOOqw7CM7T8AFI3fwZ2aK9VOGSGZufFzupkg7kLANTJKFBe4sjkKr jEQEVG5QqDg8caFDvUB8SQXeVJP4tvCUzI1Eo6HANjoAO+VYlscwXWx7DZA7T8F8jb+sHu626ak 1RQmpDrdGC0DZplHmwwylmB2F2EidjsYZfK8Cdgb8a0JJPExmIQ+cTo0++kJiveUaZyK/UL0jRh hg9vqFXTNPkEbV8e6Vlwokd9mFyxL9bdfI2tlZ3caWKkkjTrXN8mi2X6SRTpAGhFZMWghTEbhSa eXlcPcdGHQSOjUk0Kitk5kU2wlwHzXz4NbeKBRjlJazakVbHceEPX5qdLR/P7YSlmRLi7Z6m+ya UmUWVX3c1gCEEDEEh+K5mryvpYHfWywHMG2dPWWg6ZFs95in5CyEP30rT5lsGN3+1iUcaFEwUzV q8CJ+ANNIKGlt4g== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1794299616136158500 The cursor buffer is always 64x64x4, but rutabaga does not check the resource format before the transfer read. Gfxstream copies only as many bytes as the resource format needs, so an R8_UNORM cursor updates the first 4096 bytes of the 16384 byte buffer and leaves the rest untouched, while formats with a larger pixel size do not fit the request and fail. Refuse cursor resources that are not 32bpp, reusing virtio_gpu_get_pixman_format() as the allowlist so the 32bpp formats the other backends accept keep working. res->format is the value passed to rutabaga_resource_create_3d(), so it matches what gfxstream stores. Blob resources carry no format; they were already rejected by the dimension check and stay rejected. Log the dimension mismatch and the transfer failure as well. Fixes: CVE-2026-122027 Fixes: 1dcc6adbc168 ("gfxstream + rutabaga: add initial support for gfxstre= am") Reported-by: Fernando Bortotti Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Akihiko Odaki Reviewed-by: Daniel P. Berrang=C3=A9 --- hw/display/virtio-gpu-rutabaga.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/hw/display/virtio-gpu-rutabaga.c b/hw/display/virtio-gpu-rutab= aga.c index 1312a67d7011..6246aca894b0 100644 --- a/hw/display/virtio-gpu-rutabaga.c +++ b/hw/display/virtio-gpu-rutabaga.c @@ -44,8 +44,18 @@ virtio_gpu_rutabaga_update_cursor(VirtIOGPU *g, struct v= irtio_gpu_scanout *s, return; } =20 + if (!virtio_gpu_format_is_cursor_capable(res->format)) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: cursor resource %u has unsupported format %u\n", + __func__, resource_id, res->format); + return; + } + if (res->width !=3D s->current_cursor->width || res->height !=3D s->current_cursor->height) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: cursor resource %u has unsupported dimension %u= x%u\n", + __func__, resource_id, res->width, res->height); return; } =20 @@ -59,9 +69,12 @@ virtio_gpu_rutabaga_update_cursor(VirtIOGPU *g, struct v= irtio_gpu_scanout *s, transfer_iovec.iov_base =3D s->current_cursor->data; transfer_iovec.iov_len =3D res->width * res->height * 4; =20 - rutabaga_resource_transfer_read(vr->rutabaga, 0, - resource_id, &transfer, - &transfer_iovec); + if (rutabaga_resource_transfer_read(vr->rutabaga, 0, resource_id, + &transfer, &transfer_iovec) !=3D 0= ) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: failed to read cursor resource %u\n", + __func__, resource_id); + } } =20 static void --=20 2.56.0.116.g6de20f6092dc From nobody Mon Nov 23 04:44:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794299627; cv=none; d=zohomail.com; s=zohoarc; b=GSum6r2E7zBdvrtbQBqVkMq/Y4Hvx56MIq98g71CAEA3wGZ40Q0KFmLdybd88KzoqUPGxRV0IOX/IkSHeLu7jjHdhYxn3SCIyFEvlp8mYY7fEf9YUQa1n3tcdnSZPN5+ZWIm6JDSzvtR6LZJp6OcGcbpzcpDskYEWfUXH1wc/Fw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794299627; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To: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=dvYLEn6swAp2cYlML3Of34lA0JyEtQfOMP1ccxl+zUk=; b=ZpT40nRMOTtO7QUl5UtWwSA7/7gwxvLfdR8Uj74gPKblh02y5HqlCEC7AXFxfqe4IPinW7a0Huos2DDcd1Hxz+ZIdWWOD6/5bdeY0Eg+ksbQiCkO98M63n/4LrVdd5oTtiDQnxcXEqvJkY6t2AzJVuKGCkGMF4l9Pbr7nItfJuM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794299627084500.76547138929766; Tue, 10 Nov 2026 00:33:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQhIS-0005sJ-NR; Tue, 10 Nov 2026 03:33:40 -0500 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 1xQhIC-0005Vo-58 for qemu-devel@nongnu.org; Tue, 10 Nov 2026 03:33:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQhIA-0003PT-84 for qemu-devel@nongnu.org; Tue, 10 Nov 2026 03:33:23 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-44--z8GGeGMOhakinWrdhEsvA-1; Tue, 10 Nov 2026 03:33:16 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4435E180055C; Tue, 10 Nov 2026 08:33:15 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 760A018004E9; Tue, 10 Nov 2026 08:33:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794299601; 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: in-reply-to:in-reply-to:references:references; bh=dvYLEn6swAp2cYlML3Of34lA0JyEtQfOMP1ccxl+zUk=; b=U7DwgthPQ/SLcjXXN5UUbRcQVAM1HpL5ANxgCPBCo/YfmUupsmCJs1ikYmabdYaxLrHr4e KvUGu368gEl6rDZ6beOJJK0Jmwo/+H6dKmzGu+C6fOMbBV7/b2D+klGXQkunQ6V2Bxsw9v b6FSqbd+1Fm3POHtDtJvNsf9K0f5tns= X-MC-Unique: -z8GGeGMOhakinWrdhEsvA-1 X-Mimecast-MFC-AGG-ID: -z8GGeGMOhakinWrdhEsvA_1794299595 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Tue, 10 Nov 2026 12:31:14 +0400 Subject: [PATCH 4/4] contrib/vhost-user-gpu: reject non-32bpp cursor resources MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261110-master-v1-4-7a0505d6c259@redhat.com> References: <20261110-master-v1-0-7a0505d6c259@redhat.com> In-Reply-To: <20261110-master-v1-0-7a0505d6c259@redhat.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , Stefano Garzarella , Gurchetan Singh , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=5821; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=Qn0htwnuIGFJEZcglJ8juElzhMKoQ+aGUuk4x1FH/+4=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBq8ta3/8U7RNo6p8xi0N69oZ7wBUJGn+eMZC+FS SaBTz+Ee/iJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCavLWtwAKCRDa6OEJdZac 5ao9D/9Ojtz40OEUjmunIa6dcsry05SD4ePNuxQ923X220d82IlKdzKAL/XMB4iAyy05pLvhVTZ EP/laMNa/tMLaMH8Bg4oOg/YCT5kd7uIv6VOTHofBmyuJcP2eYAO27kgVUQXy0VSGChdtkiETZB t67eYDfp/W3QAEsb8xow1f7j+p0GQm8iNTrwcggvI2EhFHpeZD/c2XVUotebaxEihPzSeG8XYz2 fzmG5L46hBhMnR5RsojjxfSCLCLjFDNRm4+yfU7GsMZPckmwEVsEpcx3nQ2OrdCvSvMeNdkMJua XxxsY6Dja2VsbwEZUhdnZMI9KLCr1duprb3+itnrKdVD9j9jPnDrXO+1HMiuF4I1UR59LjiedZU p5FE2SGMBLyBe8oWaFIJpNW/YzJzRQrnNkGQSMu4fLZHdVGQ3H+of0MBqlZ5f67mkKjEwYniPhk /OKGj7DLI/GMp4mrloSGyj6USkjJpNpnQxPtCPWvdHjoOE83cU/SmRz1nkXBMV9+xVvuNuBxDX3 iklIqwUUaRHnh3BopN+cm4gcH9OC38K/LzGkYKjjP2AYraSilg/UQ8FX6zQANmXnmoZoM7B4SLo d6rs4yDWqbsyib5moZnjwNwAMKJLkT31LemTWlkV7apjeKC/PnpG5Yyxz6s5rxog26iUqtntpkk Cy3L3WlzLcwIAwA== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1794299629240158500 Cursor pixel data is copied as 32bpp, but the resource format is never checked. virgl_renderer_get_cursor_data() sizes its buffer for the resource's own format, while vg_virgl_update_cursor_data() copies 64 * 64 * 4 bytes from it: a 64x64 R8_UNORM resource gives a 4096 byte buffer, so 12 KiB past its end is read and handed to the display backend as cursor pixels. Look up the resource format and refuse anything that is not 32bpp, matching the virtio-gpu backends. While at it, let g_autofree release the buffer: the 64x64 check returned before it was freed, letting a guest grow the backend's memory with repeated UPDATE_CURSOR. Fixes: CVE-2026-122027 Fixes: d52c454aadcd ("contrib: add vhost-user-gpu") Reported-by: Fernando Bortotti Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Akihiko Odaki Reviewed-by: Daniel P. Berrang=C3=A9 --- contrib/vhost-user-gpu/vhost-user-gpu.c | 31 ++++++++++++++++++++---------= -- contrib/vhost-user-gpu/virgl.c | 25 ++++++++++++++++++------- contrib/vhost-user-gpu/virgl.h | 2 +- 3 files changed, 39 insertions(+), 19 deletions(-) diff --git a/contrib/vhost-user-gpu/vhost-user-gpu.c b/contrib/vhost-user-g= pu/vhost-user-gpu.c index f70b34c179f3..b34a1e013b8b 100644 --- a/contrib/vhost-user-gpu/vhost-user-gpu.c +++ b/contrib/vhost-user-gpu/vhost-user-gpu.c @@ -949,19 +949,22 @@ vg_handle_ctrl(VuDev *dev, int qidx) } } =20 -static void +static bool update_cursor_data_simple(VuGpu *g, uint32_t resource_id, gpointer data) { struct virtio_gpu_simple_resource *res; =20 res =3D virtio_gpu_find_resource(g, resource_id); - g_return_if_fail(res !=3D NULL); - g_return_if_fail(pixman_image_get_width(res->image) =3D=3D 64); - g_return_if_fail(pixman_image_get_height(res->image) =3D=3D 64); - g_return_if_fail( - PIXMAN_FORMAT_BPP(pixman_image_get_format(res->image)) =3D=3D 32); + if (!res || !res->image || + pixman_image_get_width(res->image) !=3D 64 || + pixman_image_get_height(res->image) !=3D 64 || + PIXMAN_FORMAT_BPP(pixman_image_get_format(res->image)) !=3D 32) { + g_debug("%s: invalid cursor resource %u", G_STRFUNC, resource_id); + return false; + } =20 memcpy(data, pixman_image_get_data(res->image), 64 * 64 * sizeof(uint3= 2_t)); + return true; } =20 static void @@ -984,6 +987,7 @@ vg_process_cursor_cmd(VuGpu *g, struct virtio_gpu_updat= e_cursor *cursor) break; } case VIRTIO_GPU_CMD_UPDATE_CURSOR: { + bool ok =3D true; VhostUserGpuMsg msg =3D { .request =3D VHOST_USER_GPU_CURSOR_UPDATE, .size =3D sizeof(VhostUserGpuCursorUpdate), @@ -998,12 +1002,17 @@ vg_process_cursor_cmd(VuGpu *g, struct virtio_gpu_up= date_cursor *cursor) } }; g_debug("%s: update", G_STRFUNC); - if (g->virgl) { - vg_virgl_update_cursor_data(g, cursor->resource_id, - msg.payload.cursor_update.data); + if (!cursor->resource_id) { + /* no resource: send a transparent cursor */ + } else if (g->virgl) { + ok =3D vg_virgl_update_cursor_data(g, cursor->resource_id, + msg.payload.cursor_update.dat= a); } else { - update_cursor_data_simple(g, cursor->resource_id, - msg.payload.cursor_update.data); + ok =3D update_cursor_data_simple(g, cursor->resource_id, + msg.payload.cursor_update.data); + } + if (!ok) { + break; } vg_send_msg(g, &msg, -1); break; diff --git a/contrib/vhost-user-gpu/virgl.c b/contrib/vhost-user-gpu/virgl.c index 0ef4b9d8c903..8af5a456ee5b 100644 --- a/contrib/vhost-user-gpu/virgl.c +++ b/contrib/vhost-user-gpu/virgl.c @@ -14,24 +14,35 @@ =20 #include "qemu/osdep.h" #include +#include "hw/virtio/virtio-gpu-pixman.h" #include "virgl.h" =20 #include =20 -void +bool vg_virgl_update_cursor_data(VuGpu *g, uint32_t resource_id, gpointer data) { - uint32_t width, height; - uint32_t *cursor; + struct virgl_renderer_resource_info info =3D { 0 }; + g_autofree uint32_t *cursor =3D NULL; + uint32_t width =3D 0, height =3D 0; + + virgl_renderer_force_ctx_0(); + if (virgl_renderer_resource_get_info(resource_id, &info) !=3D 0 || + !virtio_gpu_format_is_cursor_capable(info.virgl_format)) { + g_debug("%s: invalid cursor resource %u", G_STRFUNC, resource_id); + return false; + } =20 cursor =3D virgl_renderer_get_cursor_data(resource_id, &width, &height= ); - g_return_if_fail(cursor !=3D NULL); - g_return_if_fail(width =3D=3D 64); - g_return_if_fail(height =3D=3D 64); + if (!cursor || width !=3D 64 || height !=3D 64) { + g_debug("%s: failed to read cursor resource %u (%ux%u)", + G_STRFUNC, resource_id, width, height); + return false; + } =20 memcpy(data, cursor, 64 * 64 * sizeof(uint32_t)); - free(cursor); + return true; } =20 static void diff --git a/contrib/vhost-user-gpu/virgl.h b/contrib/vhost-user-gpu/virgl.h index 17078783a50f..40caa766d3fe 100644 --- a/contrib/vhost-user-gpu/virgl.h +++ b/contrib/vhost-user-gpu/virgl.h @@ -20,7 +20,7 @@ bool vg_virgl_init(VuGpu *g); uint32_t vg_virgl_get_num_capsets(void); void vg_virgl_process_cmd(VuGpu *vg, struct virtio_gpu_ctrl_command *cmd); -void vg_virgl_update_cursor_data(VuGpu *g, uint32_t resource_id, +bool vg_virgl_update_cursor_data(VuGpu *g, uint32_t resource_id, gpointer data); =20 #endif --=20 2.56.0.116.g6de20f6092dc