From nobody Sat May 30 20:12:58 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1776428908; cv=none; d=zohomail.com; s=zohoarc; b=X+EOwpf4qPmdZW09L8wPYi8E21kKVqvfI26jV3k4Gni2dN3yEHaVpeHx8hnzDW3H1xvb/9LUQy2vU58VO5LLvGQUJu+6sFDpN7e0l9TdvPB+rXV5eoVHHPHJ0v7sS2IBs0TmrHhNNmuyYJJ2ZnlSbVpbJ1hPc7pMz2YbceqY3ug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776428908; h=Content-Type: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=09Ao/kdkItFINOSsUtWmsMGzeiiAB3gnUtxxrN6Tkro=; b=g+/qRq8N4erZskZKTseNzJlh6grKsT/M+mNfVOCwT+zdd2/CRK3aemsnDJF3gXJBBvbvDK+xrIOAx7jjS0WM6Lly75YyJwY1uVLlKap5M7gEls8iYCeL2p20f4t9kwIdRTaDu5rCnciix4sc6APWOc30Wfe8tVMgHAwYE7xNXRA= 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=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776428908055728.6443503034926; Fri, 17 Apr 2026 05:28:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDiIE-0002AD-8F; Fri, 17 Apr 2026 08:27:30 -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 1wDiIC-00029U-JI for qemu-devel@nongnu.org; Fri, 17 Apr 2026 08:27:28 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wDiIB-0002dP-35 for qemu-devel@nongnu.org; Fri, 17 Apr 2026 08:27:28 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-43fe62837baso293370f8f.3 for ; Fri, 17 Apr 2026 05:27:26 -0700 (PDT) Received: from draig.lan ([185.124.0.195]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43fe4e3a381sm4669706f8f.21.2026.04.17.05.27.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Apr 2026 05:27:24 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id BC8A15F94F; Fri, 17 Apr 2026 13:27:22 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1776428845; x=1777033645; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=09Ao/kdkItFINOSsUtWmsMGzeiiAB3gnUtxxrN6Tkro=; b=O5+ev40i379X/kVixTVEp1lkhj2xZMaxUToDVLf31Ly5QBMX+cA6nqIOq9ZgMePNnL uhbheIoKSLJX0fqV8ulKvH8g9Uunayn+QxR1kfL4gb+f3VzCyiQCn+VDZqA9TZip865f iNCqB53u65XryHTcX5U1TKX630+8VO57MVnMsAps3rJEKBZVgWijJT1ULy7kQpA3HwzJ V2xCJ9Xo3d0MahhuoSogpfKjZlEDXdCP/McYTvdASbF8FnLA12bdcZbhswDwl2FrGEO+ 98azor5A3wQX2HGHYBdm/gvwIC1jtnz5HywT+RqcqJTtZN0tvajaJm21935ZRXi/8xmD Yqjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776428845; x=1777033645; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=09Ao/kdkItFINOSsUtWmsMGzeiiAB3gnUtxxrN6Tkro=; b=JSSPsAD4a0V+imELdVkJuI9EQba3VNGIfEmObJ2CiYHFmqoL3VAP4fpcJnhGDqKckL IGeUruzlnuk+i5WSE5YUTGnmwK/zIsejasc5kR5Ni7bNAQ8wkgx43T2folvRnGj/n+ZI dk/RbfUx7ueppZBj8NFstMei0iDPhJqxVM2x5g0uwb9N/eBdwoKIVFFBqB7kVR/ZVr5b 787NkNYnirnd/GXwBKfMNyhZqKOZ3gvzdXGlV1IO6J7CnFf53s8sjskw1JQxou57EBru h/bCRFDhTZYwmWa5SKD3yOCiY/LuUKcpsNKDCfMTi55nvhH/7bsBBBFOPR0JedWh2/kg n5vw== X-Gm-Message-State: AOJu0YyoYfXtHhCbgC+L7/MWDdIkFdYaWkvXRmGED0AtWgoWLNAZ1eXL vMLBl66YTCBmOw07LL6A5WbeKKsTOWsWSg/Z+I7g2xB8GceqG2mML30tC2i+QY1uqBo= X-Gm-Gg: AeBDietl9ZXYhgcfJzndAj7QUUqAVYZdb7fHWJkv50DS941hAPJqbd54MM/iejf3l9e 7sre3AbZMngvCkpFy0wNdCp3mq9Bm9mQjVWxpCKNQseAW5eGMug06/loPCB6q5e/Lob14jwxZ9+ 1FXug7MaH+97z5DdEf/sBqW01KXeQPLHSaRJ78ShbF2dRXsJ/sS+Shtz6ee50is19l9YzG2VMTz YTSBr93oFOEJhaH2Z+wDdWgwcUvEk3cwzDNSX0e7pwvg5xUAc5igiV8n7H52qzezRdC3NoJ2A23 lkoknwzbR8fUU4gHqhaMLlQk2v4LZP0aKPOhM+NeEkI/yB9NECyqZV0ykSaBGlea1jf9vbOutb/ LLcNF0ZMdzRd+Fp14+StTRxQys4nSFkODQs3lhBIx8qn+EFrPXKQH37i2rno+Ol8+GIchevLmON tnkmWZY3Yv+f5iT2EkkB4JwnLTUk4mYGXBVcEj/UGwXJ45 X-Received: by 2002:a05:6000:240e:b0:43d:7594:f378 with SMTP id ffacd0b85a97d-43fe3e0b18emr4094615f8f.41.1776428845051; Fri, 17 Apr 2026 05:27:25 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Manos Pitsidianakis , qemu-stable@nongnu.org, "Michael S. Tsirkin" , Akihiko Odaki , Dmitry Osipenko Subject: [PATCH v2] hw/display: don't accidentally autofree existing virgl resources Date: Fri, 17 Apr 2026 13:27:03 +0100 Message-ID: <20260417122703.845442-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=2a00:1450:4864:20::42c; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42c.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @linaro.org) X-ZM-MESSAGEID: 1776428911616154100 While sanity checking a create blob operation the use of the auto freed res variable could lead to inadvertently freeing an existing blob. Avoid this by in-lining the virtio_gpu_virgl_find_resource() check as the value is not needed anyway. While at it add a comment to the end and use g_steal_pointer to make it clearer the object lifetime exceeds the function bounds if we pass all the checks. Fixes: CVE-2026-6502 Fixes: 7c092f17cce (virtio-gpu: Handle resource blob commands) Message-ID: 20260417094443.785462-1-alex.bennee@linaro.org Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Manos Pitsidianakis Cc: qemu-stable@nongnu.org --- hw/display/virtio-gpu-virgl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index b7a2d160ddd..add85bd4e61 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -830,8 +830,7 @@ static void virgl_cmd_resource_create_blob(VirtIOGPU *g, return; } =20 - res =3D virtio_gpu_virgl_find_resource(g, cblob.resource_id); - if (res) { + if (virtio_gpu_virgl_find_resource(g, cblob.resource_id)) { qemu_log_mask(LOG_GUEST_ERROR, "%s: resource already exists %d\n", __func__, cblob.resource_id); cmd->error =3D VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; @@ -884,8 +883,9 @@ static void virgl_cmd_resource_create_blob(VirtIOGPU *g, =20 res->base.dmabuf_fd =3D info.fd; =20 + /* Now live, cleaned up in virtio_gpu_virgl_resource_unref */ QTAILQ_INSERT_HEAD(&g->reslist, &res->base, next); - res =3D NULL; + g_steal_pointer(&res); } =20 static void virgl_cmd_resource_map_blob(VirtIOGPU *g, --=20 2.47.3