drm/vmwgfx: drop dma_buf reference on foreign-fd prime import
PATCH 1/1 drm/vmwgfx: drop dma_buf reference on foreign-fd prime import
From: Zack Rusin <[email protected]>
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.
---
Backport fix for CVE-2026-80888
drivers/gpu/drm/vmwgfx/ttm_object.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/vmwgfx/ttm_object.c +5 -2
@@ -658,14 +658,17 @@ int ttm_prime_fd_to_handle(struct ttm_object_file *tfile,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,TTM_REF_USAGE ,NULL , false); +out:dma_buf_put (dma_buf);return ret;
Signature · 1 line
2.43.0
Quoted 3 lines
ttm_prime_fd_to_handle()returns-ENOSYSwhen the imported fd'sdma_buf->opsdo not match the ttm_object_device's ops, but does so without releasing the reference acquired bydma_buf_get().
Queued for 5.15 and 5.10, thanks.
Signature · 2 lines
Thanks, Sasha