* [PATCH v2 0/7] drm: Revert general use of struct drm_gem_object.dma_buf
@ 2025-07-15 8:07 Thomas Zimmermann
2025-07-15 8:07 ` [PATCH v2 1/7] Revert "drm/virtio: Use dma_buf from GEM object instance" Thomas Zimmermann
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Thomas Zimmermann @ 2025-07-15 8:07 UTC (permalink / raw)
To: simona, airlied, christian.koenig, torvalds, maarten.lankhorst,
mripard, l.stach, linux+etnaviv, kraxel, christian.gmeiner,
dmitry.osipenko, gurchetansingh, olvaffe, zack.rusin
Cc: bcm-kernel-feedback-list, dri-devel, etnaviv, virtualization,
intel-gfx, Thomas Zimmermann
Revert the use of drm_gem_object.dma_buf back to .import_attach->dmabuf
in the affected places. Separates references to imported and exported DMA
bufs within a GEM object; as before.
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.
v2:
- extended commit messages (Sima)
- drop the GEM-handle changes to be resolved separately
Thomas Zimmermann (7):
Revert "drm/virtio: Use dma_buf from GEM object instance"
Revert "drm/vmwgfx: Use dma_buf from GEM object instance"
Revert "drm/etnaviv: Use dma_buf from GEM object instance"
Revert "drm/prime: Use dma_buf from GEM object instance"
Revert "drm/gem-framebuffer: Use dma_buf from GEM object instance"
Revert "drm/gem-shmem: Use dma_buf from GEM object instance"
Revert "drm/gem-dma: Use dma_buf from GEM object instance"
drivers/gpu/drm/drm_gem_dma_helper.c | 2 +-
drivers/gpu/drm/drm_gem_framebuffer_helper.c | 8 ++++++--
drivers/gpu/drm/drm_gem_shmem_helper.c | 4 ++--
drivers/gpu/drm/drm_prime.c | 8 +++++++-
drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c | 4 ++--
drivers/gpu/drm/virtio/virtgpu_prime.c | 5 +++--
drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 6 +++---
7 files changed, 24 insertions(+), 13 deletions(-)
--
2.50.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/7] Revert "drm/virtio: Use dma_buf from GEM object instance"
2025-07-15 8:07 [PATCH v2 0/7] drm: Revert general use of struct drm_gem_object.dma_buf Thomas Zimmermann
@ 2025-07-15 8:07 ` Thomas Zimmermann
2025-07-15 8:07 ` [PATCH v2 2/7] Revert "drm/vmwgfx: " Thomas Zimmermann
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Thomas Zimmermann @ 2025-07-15 8:07 UTC (permalink / raw)
To: simona, airlied, christian.koenig, torvalds, maarten.lankhorst,
mripard, l.stach, linux+etnaviv, kraxel, christian.gmeiner,
dmitry.osipenko, gurchetansingh, olvaffe, zack.rusin
Cc: bcm-kernel-feedback-list, dri-devel, etnaviv, virtualization,
intel-gfx, Thomas Zimmermann, Simona Vetter
This reverts commit 415cb45895f43015515473fbc40563ca5eec9a7c.
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.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Simona Vetter <simona.vetter@ffwll.ch>
---
drivers/gpu/drm/virtio/virtgpu_prime.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c
index 722cde5e2d86..97aaee26cb02 100644
--- a/drivers/gpu/drm/virtio/virtgpu_prime.c
+++ b/drivers/gpu/drm/virtio/virtgpu_prime.c
@@ -204,15 +204,16 @@ static void virtgpu_dma_buf_free_obj(struct drm_gem_object *obj)
{
struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj);
struct virtio_gpu_device *vgdev = obj->dev->dev_private;
+ struct dma_buf_attachment *attach = obj->import_attach;
if (drm_gem_is_imported(obj)) {
- struct dma_buf *dmabuf = bo->dma_buf;
+ struct dma_buf *dmabuf = attach->dmabuf;
dma_resv_lock(dmabuf->resv, NULL);
virtgpu_dma_buf_unmap(bo);
dma_resv_unlock(dmabuf->resv);
- dma_buf_detach(dmabuf, obj->import_attach);
+ dma_buf_detach(dmabuf, attach);
dma_buf_put(dmabuf);
}
--
2.50.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/7] Revert "drm/vmwgfx: Use dma_buf from GEM object instance"
2025-07-15 8:07 [PATCH v2 0/7] drm: Revert general use of struct drm_gem_object.dma_buf Thomas Zimmermann
2025-07-15 8:07 ` [PATCH v2 1/7] Revert "drm/virtio: Use dma_buf from GEM object instance" Thomas Zimmermann
@ 2025-07-15 8:07 ` Thomas Zimmermann
2025-07-15 8:07 ` [PATCH v2 3/7] Revert "drm/etnaviv: " Thomas Zimmermann
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Thomas Zimmermann @ 2025-07-15 8:07 UTC (permalink / raw)
To: simona, airlied, christian.koenig, torvalds, maarten.lankhorst,
mripard, l.stach, linux+etnaviv, kraxel, christian.gmeiner,
dmitry.osipenko, gurchetansingh, olvaffe, zack.rusin
Cc: bcm-kernel-feedback-list, dri-devel, etnaviv, virtualization,
intel-gfx, Thomas Zimmermann, Simona Vetter
This reverts commit aec8a40228acb385d60feec59b54573d307e60f3.
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.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Simona Vetter <simona.vetter@ffwll.ch>
---
drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c
index 7057d852951b..eedf1fe60be7 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c
@@ -85,10 +85,10 @@ static int vmw_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map)
int ret;
if (drm_gem_is_imported(obj)) {
- ret = dma_buf_vmap(obj->dma_buf, map);
+ ret = dma_buf_vmap(obj->import_attach->dmabuf, map);
if (!ret) {
if (drm_WARN_ON(obj->dev, map->is_iomem)) {
- dma_buf_vunmap(obj->dma_buf, map);
+ dma_buf_vunmap(obj->import_attach->dmabuf, map);
return -EIO;
}
}
@@ -102,7 +102,7 @@ static int vmw_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map)
static void vmw_gem_vunmap(struct drm_gem_object *obj, struct iosys_map *map)
{
if (drm_gem_is_imported(obj))
- dma_buf_vunmap(obj->dma_buf, map);
+ dma_buf_vunmap(obj->import_attach->dmabuf, map);
else
drm_gem_ttm_vunmap(obj, map);
}
--
2.50.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 3/7] Revert "drm/etnaviv: Use dma_buf from GEM object instance"
2025-07-15 8:07 [PATCH v2 0/7] drm: Revert general use of struct drm_gem_object.dma_buf Thomas Zimmermann
2025-07-15 8:07 ` [PATCH v2 1/7] Revert "drm/virtio: Use dma_buf from GEM object instance" Thomas Zimmermann
2025-07-15 8:07 ` [PATCH v2 2/7] Revert "drm/vmwgfx: " Thomas Zimmermann
@ 2025-07-15 8:07 ` Thomas Zimmermann
2025-07-15 8:07 ` [PATCH v2 4/7] Revert "drm/prime: " Thomas Zimmermann
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Thomas Zimmermann @ 2025-07-15 8:07 UTC (permalink / raw)
To: simona, airlied, christian.koenig, torvalds, maarten.lankhorst,
mripard, l.stach, linux+etnaviv, kraxel, christian.gmeiner,
dmitry.osipenko, gurchetansingh, olvaffe, zack.rusin
Cc: bcm-kernel-feedback-list, dri-devel, etnaviv, virtualization,
intel-gfx, Thomas Zimmermann, Simona Vetter
This reverts commit e91eb3ae415472b28211d7fed07fa283845b311e.
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.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Simona Vetter <simona.vetter@ffwll.ch>
---
drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
index 917ad527c961..40a50c60dfff 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
@@ -65,7 +65,7 @@ static void etnaviv_gem_prime_release(struct etnaviv_gem_object *etnaviv_obj)
struct iosys_map map = IOSYS_MAP_INIT_VADDR(etnaviv_obj->vaddr);
if (etnaviv_obj->vaddr)
- dma_buf_vunmap_unlocked(etnaviv_obj->base.dma_buf, &map);
+ dma_buf_vunmap_unlocked(etnaviv_obj->base.import_attach->dmabuf, &map);
/* Don't drop the pages for imported dmabuf, as they are not
* ours, just free the array we allocated:
@@ -82,7 +82,7 @@ static void *etnaviv_gem_prime_vmap_impl(struct etnaviv_gem_object *etnaviv_obj)
lockdep_assert_held(&etnaviv_obj->lock);
- ret = dma_buf_vmap(etnaviv_obj->base.dma_buf, &map);
+ ret = dma_buf_vmap(etnaviv_obj->base.import_attach->dmabuf, &map);
if (ret)
return NULL;
return map.vaddr;
--
2.50.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 4/7] Revert "drm/prime: Use dma_buf from GEM object instance"
2025-07-15 8:07 [PATCH v2 0/7] drm: Revert general use of struct drm_gem_object.dma_buf Thomas Zimmermann
` (2 preceding siblings ...)
2025-07-15 8:07 ` [PATCH v2 3/7] Revert "drm/etnaviv: " Thomas Zimmermann
@ 2025-07-15 8:07 ` Thomas Zimmermann
2025-07-15 8:07 ` [PATCH v2 5/7] Revert "drm/gem-framebuffer: " Thomas Zimmermann
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Thomas Zimmermann @ 2025-07-15 8:07 UTC (permalink / raw)
To: simona, airlied, christian.koenig, torvalds, maarten.lankhorst,
mripard, l.stach, linux+etnaviv, kraxel, christian.gmeiner,
dmitry.osipenko, gurchetansingh, olvaffe, zack.rusin
Cc: bcm-kernel-feedback-list, dri-devel, etnaviv, virtualization,
intel-gfx, Thomas Zimmermann, Simona Vetter
This reverts commit f83a9b8c7fd0557b0c50784bfdc1bbe9140c9bf8.
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.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Simona Vetter <simona.vetter@ffwll.ch>
---
drivers/gpu/drm/drm_prime.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index b703f83874e1..a23fc712a8b7 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -453,7 +453,13 @@ struct dma_buf *drm_gem_prime_handle_to_dmabuf(struct drm_device *dev,
}
mutex_lock(&dev->object_name_lock);
- /* re-export the original imported/exported object */
+ /* re-export the original imported object */
+ if (obj->import_attach) {
+ dmabuf = obj->import_attach->dmabuf;
+ get_dma_buf(dmabuf);
+ goto out_have_obj;
+ }
+
if (obj->dma_buf) {
get_dma_buf(obj->dma_buf);
dmabuf = obj->dma_buf;
--
2.50.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 5/7] Revert "drm/gem-framebuffer: Use dma_buf from GEM object instance"
2025-07-15 8:07 [PATCH v2 0/7] drm: Revert general use of struct drm_gem_object.dma_buf Thomas Zimmermann
` (3 preceding siblings ...)
2025-07-15 8:07 ` [PATCH v2 4/7] Revert "drm/prime: " Thomas Zimmermann
@ 2025-07-15 8:07 ` Thomas Zimmermann
2025-07-15 8:07 ` [PATCH v2 6/7] Revert "drm/gem-shmem: " Thomas Zimmermann
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Thomas Zimmermann @ 2025-07-15 8:07 UTC (permalink / raw)
To: simona, airlied, christian.koenig, torvalds, maarten.lankhorst,
mripard, l.stach, linux+etnaviv, kraxel, christian.gmeiner,
dmitry.osipenko, gurchetansingh, olvaffe, zack.rusin
Cc: bcm-kernel-feedback-list, dri-devel, etnaviv, virtualization,
intel-gfx, Thomas Zimmermann, Simona Vetter
This reverts commit cce16fcd7446dcff7480cd9d2b6417075ed81065.
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.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Simona Vetter <simona.vetter@ffwll.ch>
---
drivers/gpu/drm/drm_gem_framebuffer_helper.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem_framebuffer_helper.c b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
index 618ce725cd75..fefb2a0f6b40 100644
--- a/drivers/gpu/drm/drm_gem_framebuffer_helper.c
+++ b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
@@ -420,6 +420,7 @@ EXPORT_SYMBOL(drm_gem_fb_vunmap);
static void __drm_gem_fb_end_cpu_access(struct drm_framebuffer *fb, enum dma_data_direction dir,
unsigned int num_planes)
{
+ struct dma_buf_attachment *import_attach;
struct drm_gem_object *obj;
int ret;
@@ -428,9 +429,10 @@ static void __drm_gem_fb_end_cpu_access(struct drm_framebuffer *fb, enum dma_dat
obj = drm_gem_fb_get_obj(fb, num_planes);
if (!obj)
continue;
+ import_attach = obj->import_attach;
if (!drm_gem_is_imported(obj))
continue;
- ret = dma_buf_end_cpu_access(obj->dma_buf, dir);
+ ret = dma_buf_end_cpu_access(import_attach->dmabuf, dir);
if (ret)
drm_err(fb->dev, "dma_buf_end_cpu_access(%u, %d) failed: %d\n",
ret, num_planes, dir);
@@ -453,6 +455,7 @@ static void __drm_gem_fb_end_cpu_access(struct drm_framebuffer *fb, enum dma_dat
*/
int drm_gem_fb_begin_cpu_access(struct drm_framebuffer *fb, enum dma_data_direction dir)
{
+ struct dma_buf_attachment *import_attach;
struct drm_gem_object *obj;
unsigned int i;
int ret;
@@ -463,9 +466,10 @@ int drm_gem_fb_begin_cpu_access(struct drm_framebuffer *fb, enum dma_data_direct
ret = -EINVAL;
goto err___drm_gem_fb_end_cpu_access;
}
+ import_attach = obj->import_attach;
if (!drm_gem_is_imported(obj))
continue;
- ret = dma_buf_begin_cpu_access(obj->dma_buf, dir);
+ ret = dma_buf_begin_cpu_access(import_attach->dmabuf, dir);
if (ret)
goto err___drm_gem_fb_end_cpu_access;
}
--
2.50.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 6/7] Revert "drm/gem-shmem: Use dma_buf from GEM object instance"
2025-07-15 8:07 [PATCH v2 0/7] drm: Revert general use of struct drm_gem_object.dma_buf Thomas Zimmermann
` (4 preceding siblings ...)
2025-07-15 8:07 ` [PATCH v2 5/7] Revert "drm/gem-framebuffer: " Thomas Zimmermann
@ 2025-07-15 8:07 ` Thomas Zimmermann
2025-07-15 8:07 ` [PATCH v2 7/7] Revert "drm/gem-dma: " Thomas Zimmermann
2025-07-15 8:43 ` [PATCH v2 0/7] drm: Revert general use of struct drm_gem_object.dma_buf Christian König
7 siblings, 0 replies; 9+ messages in thread
From: Thomas Zimmermann @ 2025-07-15 8:07 UTC (permalink / raw)
To: simona, airlied, christian.koenig, torvalds, maarten.lankhorst,
mripard, l.stach, linux+etnaviv, kraxel, christian.gmeiner,
dmitry.osipenko, gurchetansingh, olvaffe, zack.rusin
Cc: bcm-kernel-feedback-list, dri-devel, etnaviv, virtualization,
intel-gfx, Thomas Zimmermann, Simona Vetter
This reverts commit 1a148af06000e545e714fe3210af3d77ff903c11.
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.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Simona Vetter <simona.vetter@ffwll.ch>
---
drivers/gpu/drm/drm_gem_shmem_helper.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
index 8ac0b1fa5287..5d1349c34afd 100644
--- a/drivers/gpu/drm/drm_gem_shmem_helper.c
+++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
@@ -351,7 +351,7 @@ int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem,
dma_resv_assert_held(obj->resv);
if (drm_gem_is_imported(obj)) {
- ret = dma_buf_vmap(obj->dma_buf, map);
+ ret = dma_buf_vmap(obj->import_attach->dmabuf, map);
} else {
pgprot_t prot = PAGE_KERNEL;
@@ -413,7 +413,7 @@ void drm_gem_shmem_vunmap_locked(struct drm_gem_shmem_object *shmem,
dma_resv_assert_held(obj->resv);
if (drm_gem_is_imported(obj)) {
- dma_buf_vunmap(obj->dma_buf, map);
+ dma_buf_vunmap(obj->import_attach->dmabuf, map);
} else {
dma_resv_assert_held(shmem->base.resv);
--
2.50.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 7/7] Revert "drm/gem-dma: Use dma_buf from GEM object instance"
2025-07-15 8:07 [PATCH v2 0/7] drm: Revert general use of struct drm_gem_object.dma_buf Thomas Zimmermann
` (5 preceding siblings ...)
2025-07-15 8:07 ` [PATCH v2 6/7] Revert "drm/gem-shmem: " Thomas Zimmermann
@ 2025-07-15 8:07 ` Thomas Zimmermann
2025-07-15 8:43 ` [PATCH v2 0/7] drm: Revert general use of struct drm_gem_object.dma_buf Christian König
7 siblings, 0 replies; 9+ messages in thread
From: Thomas Zimmermann @ 2025-07-15 8:07 UTC (permalink / raw)
To: simona, airlied, christian.koenig, torvalds, maarten.lankhorst,
mripard, l.stach, linux+etnaviv, kraxel, christian.gmeiner,
dmitry.osipenko, gurchetansingh, olvaffe, zack.rusin
Cc: bcm-kernel-feedback-list, dri-devel, etnaviv, virtualization,
intel-gfx, Thomas Zimmermann, Simona Vetter
This reverts commit e8afa1557f4f963c9a511bd2c6074a941c308685.
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.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Simona Vetter <simona.vetter@ffwll.ch>
---
drivers/gpu/drm/drm_gem_dma_helper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_gem_dma_helper.c b/drivers/gpu/drm/drm_gem_dma_helper.c
index b7f033d4352a..4f0320df858f 100644
--- a/drivers/gpu/drm/drm_gem_dma_helper.c
+++ b/drivers/gpu/drm/drm_gem_dma_helper.c
@@ -230,7 +230,7 @@ void drm_gem_dma_free(struct drm_gem_dma_object *dma_obj)
if (drm_gem_is_imported(gem_obj)) {
if (dma_obj->vaddr)
- dma_buf_vunmap_unlocked(gem_obj->dma_buf, &map);
+ dma_buf_vunmap_unlocked(gem_obj->import_attach->dmabuf, &map);
drm_prime_gem_destroy(gem_obj, dma_obj->sgt);
} else if (dma_obj->vaddr) {
if (dma_obj->map_noncoherent)
--
2.50.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/7] drm: Revert general use of struct drm_gem_object.dma_buf
2025-07-15 8:07 [PATCH v2 0/7] drm: Revert general use of struct drm_gem_object.dma_buf Thomas Zimmermann
` (6 preceding siblings ...)
2025-07-15 8:07 ` [PATCH v2 7/7] Revert "drm/gem-dma: " Thomas Zimmermann
@ 2025-07-15 8:43 ` Christian König
7 siblings, 0 replies; 9+ messages in thread
From: Christian König @ 2025-07-15 8:43 UTC (permalink / raw)
To: Thomas Zimmermann, simona, airlied, torvalds, maarten.lankhorst,
mripard, l.stach, linux+etnaviv, kraxel, christian.gmeiner,
dmitry.osipenko, gurchetansingh, olvaffe, zack.rusin
Cc: bcm-kernel-feedback-list, dri-devel, etnaviv, virtualization,
intel-gfx
If it helps Acked-by: Christian König <christian.koenig@amd.com> for the entire series.
Regards,
Christian.
On 15.07.25 10:07, Thomas Zimmermann wrote:
> Revert the use of drm_gem_object.dma_buf back to .import_attach->dmabuf
> in the affected places. Separates references to imported and exported DMA
> bufs within a GEM object; as before.
>
> 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.
>
> v2:
> - extended commit messages (Sima)
> - drop the GEM-handle changes to be resolved separately
>
> Thomas Zimmermann (7):
> Revert "drm/virtio: Use dma_buf from GEM object instance"
> Revert "drm/vmwgfx: Use dma_buf from GEM object instance"
> Revert "drm/etnaviv: Use dma_buf from GEM object instance"
> Revert "drm/prime: Use dma_buf from GEM object instance"
> Revert "drm/gem-framebuffer: Use dma_buf from GEM object instance"
> Revert "drm/gem-shmem: Use dma_buf from GEM object instance"
> Revert "drm/gem-dma: Use dma_buf from GEM object instance"
>
> drivers/gpu/drm/drm_gem_dma_helper.c | 2 +-
> drivers/gpu/drm/drm_gem_framebuffer_helper.c | 8 ++++++--
> drivers/gpu/drm/drm_gem_shmem_helper.c | 4 ++--
> drivers/gpu/drm/drm_prime.c | 8 +++++++-
> drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c | 4 ++--
> drivers/gpu/drm/virtio/virtgpu_prime.c | 5 +++--
> drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 6 +++---
> 7 files changed, 24 insertions(+), 13 deletions(-)
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-07-15 8:43 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-15 8:07 [PATCH v2 0/7] drm: Revert general use of struct drm_gem_object.dma_buf Thomas Zimmermann
2025-07-15 8:07 ` [PATCH v2 1/7] Revert "drm/virtio: Use dma_buf from GEM object instance" Thomas Zimmermann
2025-07-15 8:07 ` [PATCH v2 2/7] Revert "drm/vmwgfx: " Thomas Zimmermann
2025-07-15 8:07 ` [PATCH v2 3/7] Revert "drm/etnaviv: " Thomas Zimmermann
2025-07-15 8:07 ` [PATCH v2 4/7] Revert "drm/prime: " Thomas Zimmermann
2025-07-15 8:07 ` [PATCH v2 5/7] Revert "drm/gem-framebuffer: " Thomas Zimmermann
2025-07-15 8:07 ` [PATCH v2 6/7] Revert "drm/gem-shmem: " Thomas Zimmermann
2025-07-15 8:07 ` [PATCH v2 7/7] Revert "drm/gem-dma: " Thomas Zimmermann
2025-07-15 8:43 ` [PATCH v2 0/7] drm: Revert general use of struct drm_gem_object.dma_buf Christian König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox