Revert "drm/tegra: Use dma_buf from GEM object instance"
PATCH 1/1 Revert "drm/tegra: Use dma_buf from GEM object instance"
This reverts commit 482c7e296edc0f594e8869a789a40be53c49bd6a.
The dma_buf field in struct drm_gem_object is not stable over the object instance's lifetime. The field becomes NULL when user space releases the final GEM handle on the buffer object. This resulted in a NULL-pointer deref.
Workarounds in commit 5307dce878d4 ("drm/gem: Acquire references on GEM handles for framebuffers") and commit f6bfc9afc751 ("drm/framebuffer:
Acquire internal references on GEM handles") only solved the problem partially. They especially don't work for buffer objects without a DRM framebuffer associated.
Hence, this revert to going back to using .import_attach->dmabuf.
--- drivers/gpu/drm/tegra/gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tegra/gem.c +1 -1
@@ -526,7 +526,7 @@ void tegra_bo_free_object(struct drm_gem_object *gem)if (drm_gem_is_imported (gem)) {dma_buf_unmap_attachment_unlocked (gem->import_attach, bo->sgt,DMA_TO_DEVICE ); -dma_buf_detach (gem->dma_buf, gem->import_attach); +dma_buf_detach (gem->import_attach->dmabuf, gem->import_attach); } }
Signature · 1 line
2.50.0
Quoted 13 lines · Thomas Zimmermann
This reverts commit
482c7e296edc0f594e8869a789a40be53c49bd6a.The
dma_buffield in structdrm_gem_objectis not stable over the object instance's lifetime. The field becomes NULL when user space releases the final GEM handle on the buffer object. This resulted in a NULL-pointer deref.Workarounds in commit
5307dce878d4("drm/gem: Acquire references on GEM handles for framebuffers") and commitf6bfc9afc751("drm/framebuffer:
Acquire internal references on GEM handles") only solved the problem partially. They especially don't work for buffer objects without a DRM framebuffer associated.
Quoted 3 lines
Hence, this revert to going back to using .import_attach->dmabuf.
Signed-off-by Thomas Zimmermann <[email protected]>
Quoted 20 lines
--- drivers/gpu/drm/tegra/gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/tegra/gem.c +1
-1@@ -526,7 +526,7 @@ void tegra_bo_free_object(struct drm_gem_object *gem)if (drm_gem_is_imported (gem)) {dma_buf_unmap_attachment_unlocked (gem->import_attach, bo->sgt,DMA_TO_DEVICE ); -dma_buf_detach (gem->dma_buf, gem->import_attach); +dma_buf_detach (gem->import_attach->dmabuf, gem->import_attach); } }Signature · 1 line
2.50.0
Signature · 3 lines
Simona Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Hi Thierry,
can I take this patch into drm-misc-fixes?
Best regards
Thomas
Am 15.07.25 um 10:45 schrieb Thomas Zimmermann:
Quoted 33 lines
This reverts commit
482c7e296edc0f594e8869a789a40be53c49bd6a.The
dma_buffield in structdrm_gem_objectis not stable over the object instance's lifetime. The field becomes NULL when user space releases the final GEM handle on the buffer object. This resulted in a NULL-pointer deref.Workarounds in commit
5307dce878d4("drm/gem: Acquire references on GEM handles for framebuffers") and commitf6bfc9afc751("drm/framebuffer:
Acquire internal references on GEM handles") only solved the problem partially. They especially don't work for buffer objects without a DRM framebuffer associated.Hence, this revert to going back to using .import_attach->dmabuf.
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/tegra/gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/tegra/gem.c +1
-1@@ -526,7 +526,7 @@ void tegra_bo_free_object(struct drm_gem_object *gem)if (drm_gem_is_imported (gem)) {dma_buf_unmap_attachment_unlocked (gem->import_attach, bo->sgt,DMA_TO_DEVICE ); -dma_buf_detach (gem->dma_buf, gem->import_attach); +dma_buf_detach (gem->import_attach->dmabuf, gem->import_attach); } }
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)
Hi
Am 12.08.25 um 11:12 schrieb Thomas Zimmermann:
Quoted 3 lines
Hi Thierry,
can I take this patch into drm-misc-fixes?
I'm merging this patch into drm-misc-fixes to get the upstream bug fixed.
Best regards
Thomas
Quoted 40 lines
Best regards
ThomasAm 15.07.25 um 10:45 schrieb Thomas Zimmermann:
Quoted 34 lines
This reverts commit
482c7e296edc0f594e8869a789a40be53c49bd6a.The
dma_buffield in structdrm_gem_objectis not stable over the object instance's lifetime. The field becomes NULL when user space releases the final GEM handle on the buffer object. This resulted in a NULL-pointer deref.Workarounds in commit
5307dce878d4("drm/gem: Acquire references on GEM handles for framebuffers") and commitf6bfc9afc751("drm/framebuffer:
Acquire internal references on GEM handles") only solved the problem partially. They especially don't work for buffer objects without a DRM framebuffer associated.Hence, this revert to going back to using .import_attach->dmabuf.
Signed-off-by Thomas Zimmermann <[email protected]>---
drivers/gpu/drm/tegra/gem.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/tegra/gem.c +1
-1@@ -526,7 +526,7 @@ void tegra_bo_free_object(struct drm_gem_object *gem) if (drm_gem_is_imported(gem)) {dma_buf_unmap_attachment_unlocked (gem->import_attach, bo->sgt, DMA_TO_DEVICE); - dma_buf_detach(gem->dma_buf, gem->import_attach); + dma_buf_detach(gem->import_attach->dmabuf, gem->import_attach); }}
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)