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=1796380774; b=q9hycGBmkMvf88ut8aOE73uVyCc8GLr6e8+80t4fRLX1lUPIv9fRdxlv8G0HJFli6ajc JhEz6t3uYU/r0d+qOInZAfl0yKEqr+ePV3tM7sekRv1zjf8JRy+VVhxE1PCsdB4dMDkam GD43b1LLA4fXtz2/kE7X6esLg237F/3papSpgV0MKzdZ7iQ9jHX/ifzotrqF6o/rrPcRE iY6KtOR6eUpb1K/BHyB09vn6GNgtvZb0356KMunmthzqcjtE6dborMCfFXfFEEDZ1KsfQ SjtZ/APGBhZmE2qm1CopvdUCOwAkZfD0BuMfcuJPNckLLAzO3weZ8huNhtCytjRNRtg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380774; 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=pebR8xcJHmrNCDVBSuq7bBkd8DZEKM0a+RmPHRwgFKI=; b=ZStDgm9kHqqikRhici3qMU6opsLRC9qKZbP59ao50QUMP+s7ENnmgoPL02HSNRLmkRWt lSTbQooSkFJr6WlnX36dDEXziVbgCDk0MmYxtqq8urSVocJw2KIE9+uCs3RO7V77YJ86J jQt6yfBFHsJVR0Ll0mBe/amynKMNxyKlt+2wCzYt0bpbU9j5ZKJx7Lm6L0Grn6Swcef2l hZLGQtYYIlLMUsu5Rh6hapStEUpmJQyGV4GA/DmCcBQV5nfayW81aI3+37lNOAe7dr7hA n5oXHs/NSXpgnrTEmaGV3x/I4GAeYAZKNPG1ISx5SPD5mkiu0ye11FtBriQ64d81kHQ== 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=sRRohahq; 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 83650606A322; Fri, 4 Dec 2026 10:39:34 +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=sRRohahq Received: by smtp.kernel.org (Postfix) with ESMTPSA id F00941F000C2; Fri, 4 Dec 2026 10:39:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380774; bh=pebR8xcJHmrNCDVBSuq7bBkd8DZEKM0a+RmPHRwgFKI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=sRRohahq0IaEAwObmTDv6O+nzXbuJYO0iEq+wisZcDV2ukG4pS+eJ6bOwEMp8/uTN zBuUMYfUsGzFEx/cu3uCAxIDRqaxP2xYQ5eA0+tk4f2i4SFk32wIZ03PR1H8PXAo1n AVGcOR/+2oy3fosF1VnAOUMV9JVw3XgA3FkZAJNU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zack Rusin , Aldo Ariel Panzardo Subject: [PATCH 7.3 419/742] drm/vmwgfx: return an error when a shared GB surface has no backup buffer Date: Fri, 4 Dec 2026 19:04:43 +0900 Message-ID: <20261204100646.235404375@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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 7.3-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 @@ -1720,6 +1720,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; @@ -1758,6 +1759,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;