From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3EF3626B2D3; Fri, 7 Aug 2026 15:15:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786115728; cv=none; b=mjB4W204xNHhtKOYRruRGDMERwMyWis6BbJVo81M4GTVeMPPT3WIbzsko3DznGhq0DRpq9kyR1WU8XeBUs8BvIUuE1ElaXrDadPyZ9PAbC7xhpKbCOG1olD6pSDBvl8e4du+2tC+5dIC4KMchNneiXz5cvbAeQ/+M63ECdaKbCE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786115728; c=relaxed/simple; bh=jR/8cCiIAD/4AOl4LxwYx6FKQBfL8bYCVxqSBlNey9A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V6qGy7e12tbznNMvRtoBqgfDnku8POfOFUZfRGBE4sxd2CKKDW0di2NhVboF6K9RGup1B57JX1f/O6Zll9im0uuTSWBfR1951I3HMdmSjVheNkbUedclbmLM7PNhIW9oBB9IRfRsCcyyicsjHZW3+lQcj70/SvWd9H7J0oy4TI8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=LYMr1bwg; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="LYMr1bwg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 999C61F000E9; Fri, 7 Aug 2026 15:15:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786115727; bh=lA7ZVfZeAWaZN95qL64ZPMwZuEPcxVVHxW27iVqEujw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LYMr1bwgdYKH45mueNVdRlPDByC6LCwER84XljlcE7SumUbAX5MYsBXjE0xtfGs2g FFtcve845Wy4c61hrlbTBmOpvFJ+l/oS3TBVitJiinDM+4ycLAoOwbcOUurdlr/Djm kdhUFpChiW23GEaQpaTOk4wd+u31nE/czqhUlgSc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zack Rusin , Ian Forbes Subject: [PATCH 6.18 334/396] drm/vmwgfx: drop dma_buf reference on foreign-fd prime import Date: Fri, 7 Aug 2026 16:38:14 +0200 Message-ID: <20260807143431.494780434@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260807143424.272339768@linuxfoundation.org> References: <20260807143424.272339768@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zack Rusin commit f739416dc555fa205a785e5135d73fa39b26f35d upstream. ttm_prime_fd_to_handle() returns -ENOSYS when the imported fd's dma_buf->ops do not match the ttm_object_device's ops, but does so without releasing the reference acquired by dma_buf_get(). Any unprivileged renderD client passing a non-vmwgfx prime fd through the DRM_VMW_GB_SURFACE_REF{,_EXT} path leaks one dma_buf reference per call and indefinitely pins the foreign exporter's GEM resources. Funnel the error path through the existing dma_buf_put() so the reference is always dropped. Fixes: 65981f7681ab ("drm/ttm: Add a minimal prime implementation for ttm base objects") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4.7 Signed-off-by: Zack Rusin Reviewed-by: Ian Forbes Link: https://patch.msgid.link/20260505222728.519626-6-zack.rusin@broadcom.com Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/vmwgfx/ttm_object.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/gpu/drm/vmwgfx/ttm_object.c +++ b/drivers/gpu/drm/vmwgfx/ttm_object.c @@ -547,14 +547,17 @@ int ttm_prime_fd_to_handle(struct ttm_ob if (IS_ERR(dma_buf)) return PTR_ERR(dma_buf); - if (dma_buf->ops != &tdev->ops) - return -ENOSYS; + if (dma_buf->ops != &tdev->ops) { + ret = -ENOSYS; + goto out; + } prime = (struct ttm_prime_object *) dma_buf->priv; base = &prime->base; *handle = base->handle; ret = ttm_ref_object_add(tfile, base, NULL, false); +out: dma_buf_put(dma_buf); return ret;