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=1796383749; b=bMojOW1hJ8rBNSj15qje0Hx5I7YaS23Rc52uVcEWwNtjcuToUMJWjPlRQa+aeoQz94jg Fla5yyDCmP3bdeHQCw3Y8hz/2fs7CZcBIleBggLDI+qINxUm71hWEmxUT1YIBelGwg2D5 syIYQ9tvGuq95o7YJ1YLAtNDtRoVFqo66mrlGnacofDyUfLg6ESDBML7cUqY3K2DU10Uy mOCFZsNB3Yv2Wv2/Hz+o9yunx1X7Dx7bAUg7ZOxDMd7jxkG+xLYOW+m5VPnA6l8Ge45mQ 0FAJmeaNc8p7FLhVJv9hPsfyGm4Hq6xJHRgTiUxRqBsaHnhBsOoa0Nu13zVZYc4JLtA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383749; 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=mLDVAV2y+drt/MxI9JiR1e8d6F/vQA8YuLmkcPgve54=; b=f2SCwfP2LY8gA5L4v1a30kqPzRYdfmQkTTZrRobqUeMVzTKcQFNybu3vWgTdDpxhj4AT 3m6Ha7r8L7SZ6gzPR+EwT5DcIWY+zDg6QmzHExaTyeeUzuhnX3+wu7hEa0W9fpvAgD0fr DXuBBSu2QHIIl8oN6B5p633W0XKdLI7N2Zwj/+fHvXu29dV7PVy/sgT01gofrxZrSXqU7 rCtpxBlO8qkttI2VumEIZjT2Ump4W1Wn/rE6hi3WUwVLbv63kwjcnckO7XbgEHyex0y1l h6XYqWIF3E6rzvt2RFGFRqfYYvKncdiq8aDMPxCd+xQeTpKHc3PcNo7egjoWBUUCw5A== 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=rAlZ9ViI; 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 2CBD3606A322; Fri, 4 Dec 2026 11:29:09 +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=rAlZ9ViI Received: by smtp.kernel.org (Postfix) with ESMTPSA id 965761F000C2; Fri, 4 Dec 2026 11:29:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383749; bh=mLDVAV2y+drt/MxI9JiR1e8d6F/vQA8YuLmkcPgve54=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rAlZ9ViIdcYHuRiOV5Z0KmkGQg90Jphxhg0cw3Q4xHeV2mm4+VlQVafNRHS31ticz RxUkIvX4bVUERw59WaVb9l/6StwJ5LKqcaaZMkagBd7tXCQ5Ymwm3wSl4p6sT8c4KV sl+7QbDGBUAbqVcdVcFc3S09rcVRBcuOUbLSUR2A= 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.12 352/555] drm/vmwgfx: return an error when a shared GB surface has no backup buffer Date: Fri, 4 Dec 2026 19:06:35 +0900 Message-ID: <20261204100623.360677149@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org 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.12-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 @@ -1755,6 +1755,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; @@ -1793,6 +1794,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;