From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796386535; b=mkPmhFBlotVlOP13wsGEWVD6t2PfsoCdwN8BS4/yEFFOafORmODz6xh5k4rvcdxm8JiS yDX5RgNAnRyCjTknnXagVTd9xIa0TdmGG99vm+3YOmuSgyW57TUWoXwblZQAL2Kr+AN+X Qy49pmrQ+KSeLZV/6EHTbRI1OlquIOeGn4UjKVEvZAV9B5wGqAWD92eLEPBFMOvbJ0m5U TSMOWqNU8C6m1lqHxPYC3+JeYnmgEFjP94pvCziJZxZ1rGorqFmeiX4OWbmR9eXiGiNre 4lAMtONkTJvHfLw1NDltOp+fCT+hSxfHM4Yc2Ey5AoJRTBJ1m/x6P2eeSARGs4wmJ+g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386535; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=UGjY0mT1Xsbc37tNhyke8IgtSLeRMR5xyWchL7lRiyA=; b=4ija3QJdByYldDT+GoS40L5MJnJng+KB3P2+0oxK4T+kUu55UA8DePOSOETSZeivBvQf kEADdht30rAoTE5ppVcPSOtybl1KyAaEU9h91XF4G/I0SmHo8AJRSUQEO9jnDEbk942n9 3uB9bKoe+2niMPaK5natNSMD9wOBElVvSUmUWgaGD4ZbzDnsT95xyT9APgTi6BkgdAQFH 51xLOuaKH1Cfr91JGMBD1Mublk3rSxWoJDtXTcksXtIaX8ZylECPlq7Pmb+KHlKi1/8tf OcgSEQUNk1ST+LJ5CyVJhxoVw+xEMDV4b0P59caNKyYECAINsy9LAt1dsfYbnTHJNcA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=IXPJ1H4x; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BFCF4606A338; Fri, 4 Dec 2026 12:15:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=IXPJ1H4x Received: by smtp.kernel.org (Postfix) with ESMTPSA id 375A11F00939; Fri, 4 Dec 2026 12:15:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386535; bh=UGjY0mT1Xsbc37tNhyke8IgtSLeRMR5xyWchL7lRiyA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IXPJ1H4xsXzaip+NGB9IzBdO03APIQjlqlX8LFKC2g3bQC84BiV9Owo8CJaXnh6JR CM/0oXbUovvWYWrSu6ilHQjYvsswAKArXd88+YJr7C8Hqc+X7rjTfWuftdPPgymvep GX3gbwtMdMkKIBFm1+oCHz3tABQtHg5YXVCxxLK0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zack Rusin , Aldo Ariel Panzardo Subject: [PATCH 6.6 1004/1167] drm/vmwgfx: return an error when a shared GB surface has no backup buffer Date: Fri, 4 Dec 2026 19:07:11 +0900 Message-ID: <20261204100728.360504297@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Aldo Ariel Panzardo commit 3a2f97af36754b64083d463a4cee0af26826bec8 upstream. vmw_gb_surface_reference_internal() rejects a surface that has no backup buffer by logging an error and jumping to out_bad_resource, but it never sets ret on that path. ret is still 0 from the earlier successful vmw_surface_handle_reference(), so the ioctl returns success while leaving the reply structure unfilled — user space is handed a "successful" reply that was never produced. DRM_VMW_GB_SURFACE_REF is DRM_RENDER_ALLOW, so an unprivileged local user can reach it. Set ret to -EINVAL and, on the error paths, drop the reference that vmw_surface_handle_reference() took; once the ioctl fails user space no longer releases it via DRM_VMW_UNREF_SURFACE. The unref is guarded by ret so the shared success fall-through keeps the reference the caller still owns, and it also plugs the same leak on the drm_gem_handle_create() failure path. Fixes: 14b1c33e8429 ("drm/vmwgfx: Add new ioctl for GB surface create and reference") Cc: stable@vger.kernel.org Suggested-by: Zack Rusin Signed-off-by: Aldo Ariel Panzardo Reviewed-by: Zack Rusin [zack: aligned a continuation line with the open parenthesis] Signed-off-by: Zack Rusin Link: https://patch.msgid.link/20261007212051.2574235-2-qwe.aldo@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c @@ -1623,6 +1623,7 @@ vmw_gb_surface_reference_internal(struct srf = &user_srf->srf; if (!srf->res.guest_memory_bo) { DRM_ERROR("Shared GB surface is missing a backup buffer.\n"); + ret = -EINVAL; goto out_bad_resource; } metadata = &srf->metadata; @@ -1661,6 +1662,9 @@ vmw_gb_surface_reference_internal(struct rep->creq.must_be_zero = 0; out_bad_resource: + if (ret) + ttm_ref_object_base_unref(vmw_fpriv(file_priv)->tfile, + base->handle); ttm_base_object_unref(&base); return ret;