dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] drm/panfrost,panthor: Refuse to export WB_MMAP BOs
@ 2026-11-19 19:38 Maíra Canal
  2026-11-19 19:38 ` [PATCH 1/6] drm/shmem: Add a drm_gem_shmem_sync() helper Maíra Canal
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Maíra Canal @ 2026-11-19 19:38 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Faith Ekstrand, Boris Brezillon, Rob Herring,
	Steven Price, Adrián Larumbe, Liviu Dudau, Akash Goel,
	Karunika Choo, Lukas Zapolskas, Chris Diamand, Daniel Almeida,
	Alice Ryhl
  Cc: kernel-dev, dri-devel, rust-for-linux, Maíra Canal

This series follows up on the discussion in the V3D cached maps series
[1], about how to handle CPU-cached BOs that are shared through dma-buf.

As pointed by Faith and Boris, when a buffer is shared through dma-buf,
there's no way to ensure that a client will properly bracket their CPU
accesses with DMA_BUF_IOCTL_SYNC. With WC mappings, waiting on fences is
enough to guarantee consistency. However, with WB mappings, a missed sync
can leave dirty cache lines behind, which another client can end up
writing over.

PanVK already keeps WB_MMAP BOs private, so this series only makes the
kernel enforce the same policy on Panfrost and Panthor. As WB_MMAP BOs can
no longer be exported, the custom dma_buf_ops providing begin/end_cpu_access()
are no longer needed for them and are replaced by the default PRIME ops.

- Patch 1 adds the drm_gem_shmem_sync() helper, taken from [2].
- Patches 2 and 5 refuse to export WB_MMAP BOs in Panfrost and Panthor.
- Patches 3 and 6 drop the custom dma_buf_ops from Panfrost and Panthor.
- Patch 4 converts Panfrost to drm_gem_shmem_sync(). V3D will also use it
  to implement its cached maps, which I'll send in a separate series.

Patches 3 and 6 need some extra attention as they aren't a no-op on
IO-coherent GPUs. In this case, all BOs are CPU-mapped WB, and the custom
begin/end_cpu_access() could be used to sync the mappings of non-coherent
importers.

However, I decided to send these patches either way because they only
restore the behavior prior to commits 3ae6637378e6 and 925ad0c26dd8, which
is what we discussed in [1] (IIUC). Also, Mesa writes through the GEM mmap
without DMA_BUF_IOCTL_SYNC, so it never relied on these hooks anyway.

Still, if you think this would be problematic, I can drop patches 3 and 6.

The Panthor changes were tested on hardware, but Panfrost changes were
only compile-tested.

[1] https://lore.kernel.org/dri-devel/20261030-v3d-cached-maps-v1-0-0a6a6b363382@igalia.com/T/
[2] https://lore.kernel.org/dri-devel/20251126124455.3656651-1-boris.brezillon@collabora.com/

Best regards,
- Maíra

---
Faith Ekstrand (1):
      drm/shmem: Add a drm_gem_shmem_sync() helper

Maíra Canal (5):
      drm/panfrost: Refuse to export WB_MMAP BOs
      drm/panfrost: Drop custom dma_buf_ops
      drm/panfrost: Use drm_gem_shmem_sync()
      drm/panthor: Refuse to export WB_MMAP BOs
      drm/panthor: Drop custom dma_buf_ops

 drivers/gpu/drm/drm_gem_shmem_helper.c  |  93 +++++++++++++++
 drivers/gpu/drm/panfrost/panfrost_drv.c |   1 -
 drivers/gpu/drm/panfrost/panfrost_gem.c | 194 ++------------------------------
 drivers/gpu/drm/panfrost/panfrost_gem.h |   3 -
 drivers/gpu/drm/panthor/panthor_drv.c   |   1 -
 drivers/gpu/drm/panthor/panthor_gem.c   | 120 +-------------------
 drivers/gpu/drm/panthor/panthor_gem.h   |   4 -
 include/drm/drm_gem_shmem_helper.h      |  17 +++
 include/uapi/drm/panfrost_drm.h         |   1 +
 include/uapi/drm/panthor_drm.h          |   2 +
 10 files changed, 126 insertions(+), 310 deletions(-)
---
base-commit: 8e2afcd2b57990465f132367fd8fdc2e55c1adad
change-id: 20261119-pan-drop-dma-buf-hooks-98f7f19f3b51


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/6] drm/shmem: Add a drm_gem_shmem_sync() helper
  2026-11-19 19:38 [PATCH 0/6] drm/panfrost,panthor: Refuse to export WB_MMAP BOs Maíra Canal
@ 2026-11-19 19:38 ` Maíra Canal
  2026-11-19 19:55   ` sashiko-bot
  2026-11-19 19:38 ` [PATCH 2/6] drm/panfrost: Refuse to export WB_MMAP BOs Maíra Canal
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 8+ messages in thread
From: Maíra Canal @ 2026-11-19 19:38 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Faith Ekstrand, Boris Brezillon, Rob Herring,
	Steven Price, Adrián Larumbe, Liviu Dudau, Akash Goel,
	Karunika Choo, Lukas Zapolskas, Chris Diamand, Daniel Almeida,
	Alice Ryhl
  Cc: kernel-dev, dri-devel, rust-for-linux, Maíra Canal

From: Faith Ekstrand <faith.ekstrand@collabora.com>

This enables syncing mapped GEM objects between the CPU and GPU via calls
to dma_sync_*().  It's a bit annoying as it requires walking the sg_table
so it's best if every driver doesn't hand-roll it.

Signed-off-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Steven Price <steven.price@arm.com>
[mcanal: rebased on top of drm-misc-next and fixed a kernel-doc nit]
Signed-off-by: Maíra Canal <mcanal@igalia.com>
---
 drivers/gpu/drm/drm_gem_shmem_helper.c | 93 ++++++++++++++++++++++++++++++++++
 include/drm/drm_gem_shmem_helper.h     | 17 +++++++
 2 files changed, 110 insertions(+)

diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
index d654a22a30de..72933ed28373 100644
--- a/drivers/gpu/drm/drm_gem_shmem_helper.c
+++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
@@ -790,6 +790,99 @@ int drm_gem_shmem_mmap(struct drm_gem_shmem_object *shmem, struct vm_area_struct
 }
 EXPORT_SYMBOL_GPL(drm_gem_shmem_mmap);
 
+/**
+ * drm_gem_shmem_sync - Sync CPU-mapped data
+ * @shmem: shmem GEM object
+ * @offset: Offset into the GEM object
+ * @size: Size of the area to sync
+ * @type: Type of synchronization
+ *
+ * Returns:
+ * 0 on success or a negative error code on failure.
+ */
+int drm_gem_shmem_sync(struct drm_gem_shmem_object *shmem, size_t offset,
+		       size_t size, enum drm_gem_shmem_sync_type type)
+{
+	const struct drm_device *dev = shmem->base.dev;
+	struct sg_table *sgt;
+	struct scatterlist *sgl;
+	unsigned int count;
+
+	/* Make sure the range is in bounds. */
+	if (offset + size < offset || offset + size > shmem->base.size)
+		return -EINVAL;
+
+	/* Disallow CPU-cache maintenance on imported buffers. */
+	if (drm_gem_is_imported(&shmem->base))
+		return -EINVAL;
+
+	switch (type) {
+	case DRM_GEM_SHMEM_SYNC_CPU_CACHE_FLUSH:
+	case DRM_GEM_SHMEM_SYNC_CPU_CACHE_FLUSH_AND_INVALIDATE:
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
+	/* Don't bother if it's WC-mapped */
+	if (shmem->map_wc)
+		return 0;
+
+	/* Nothing to do if the size is zero. */
+	if (size == 0)
+		return 0;
+
+	sgt = drm_gem_shmem_get_pages_sgt(shmem);
+	if (IS_ERR(sgt))
+		return PTR_ERR(sgt);
+
+	for_each_sgtable_dma_sg(sgt, sgl, count) {
+		if (size == 0)
+			break;
+
+		dma_addr_t paddr = sg_dma_address(sgl);
+		size_t len = sg_dma_len(sgl);
+
+		if (len <= offset) {
+			offset -= len;
+			continue;
+		}
+
+		paddr += offset;
+		len -= offset;
+		len = min_t(size_t, len, size);
+		size -= len;
+		offset = 0;
+
+		/* It's unclear whether dma_sync_xxx() is the right API to do CPU
+		 * cache maintenance given an IOMMU can register their own
+		 * implementation doing more than just CPU cache flushes/invalidation,
+		 * and what we really care about here is CPU caches only, but that's
+		 * the best we have that is both arch-agnostic and does at least the
+		 * CPU cache maintenance on a <page,offset,size> tuple.
+		 *
+		 * Also, I wish we could do a single
+		 *
+		 *	dma_sync_single_for_device(BIDIR)
+		 *
+		 * and get a flush+invalidate, but that's not how it's implemented
+		 * in practice (at least on arm64), so we have to make it
+		 *
+		 *	dma_sync_single_for_device(TO_DEVICE)
+		 *	dma_sync_single_for_cpu(FROM_DEVICE)
+		 *
+		 * for the flush+invalidate case.
+		 */
+		dma_sync_single_for_device(dev->dev, paddr, len, DMA_TO_DEVICE);
+		if (type == DRM_GEM_SHMEM_SYNC_CPU_CACHE_FLUSH_AND_INVALIDATE)
+			dma_sync_single_for_cpu(dev->dev, paddr, len, DMA_FROM_DEVICE);
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(drm_gem_shmem_sync);
+
 /**
  * drm_gem_shmem_print_info() - Print &drm_gem_shmem_object info for debugfs
  * @shmem: shmem GEM object
diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h
index bcbb92f3fe9b..a5def70fae7a 100644
--- a/include/drm/drm_gem_shmem_helper.h
+++ b/include/drm/drm_gem_shmem_helper.h
@@ -122,6 +122,23 @@ void drm_gem_shmem_vunmap_locked(struct drm_gem_shmem_object *shmem,
 				 struct iosys_map *map);
 int drm_gem_shmem_mmap(struct drm_gem_shmem_object *shmem, struct vm_area_struct *vma);
 
+/**
+ * enum drm_gem_shmem_sync_type - Type of synchronization
+ */
+enum drm_gem_shmem_sync_type {
+	/** @DRM_GEM_SHMEM_SYNC_CPU_CACHE_FLUSH: Flush CPU caches */
+	DRM_GEM_SHMEM_SYNC_CPU_CACHE_FLUSH = 0,
+
+	/**
+	 * @DRM_GEM_SHMEM_SYNC_CPU_CACHE_FLUSH_AND_INVALIDATE: Flush and
+	 * invalidate CPU caches
+	 */
+	DRM_GEM_SHMEM_SYNC_CPU_CACHE_FLUSH_AND_INVALIDATE,
+};
+
+int drm_gem_shmem_sync(struct drm_gem_shmem_object *shmem, size_t offset,
+		       size_t size, enum drm_gem_shmem_sync_type type);
+
 int drm_gem_shmem_pin_locked(struct drm_gem_shmem_object *shmem);
 void drm_gem_shmem_unpin_locked(struct drm_gem_shmem_object *shmem);
 

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/6] drm/panfrost: Refuse to export WB_MMAP BOs
  2026-11-19 19:38 [PATCH 0/6] drm/panfrost,panthor: Refuse to export WB_MMAP BOs Maíra Canal
  2026-11-19 19:38 ` [PATCH 1/6] drm/shmem: Add a drm_gem_shmem_sync() helper Maíra Canal
@ 2026-11-19 19:38 ` Maíra Canal
  2026-11-19 19:38 ` [PATCH 3/6] drm/panfrost: Drop custom dma_buf_ops Maíra Canal
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Maíra Canal @ 2026-11-19 19:38 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Faith Ekstrand, Boris Brezillon, Rob Herring,
	Steven Price, Adrián Larumbe, Liviu Dudau, Akash Goel,
	Karunika Choo, Lukas Zapolskas, Chris Diamand, Daniel Almeida,
	Alice Ryhl
  Cc: kernel-dev, dri-devel, rust-for-linux, Maíra Canal

When a buffer is shared through dma-buf, clients are expected to bracket
their CPU accesses with DMA_BUF_IOCTL_SYNC, but there's no way to ensure
they do. With WC mappings, there are no CPU cache lines to maintain, so
waiting on fences is enough. With WB mappings, a missed sync can leave
dirty cache lines behind, which may later be written back over data the
GPU produced for another client.

To avoid this, don't allow WB_MMAP BOs to be shared. PanVK already keeps
WB_MMAP BOs private, so this makes the kernel follow the same policy.

Suggested-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Maíra Canal <mcanal@igalia.com>
---
 drivers/gpu/drm/panfrost/panfrost_gem.c | 4 ++++
 include/uapi/drm/panfrost_drm.h         | 1 +
 2 files changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c
index 518f24549b9d..c7160223ea17 100644
--- a/drivers/gpu/drm/panfrost/panfrost_gem.c
+++ b/drivers/gpu/drm/panfrost/panfrost_gem.c
@@ -391,6 +391,10 @@ panfrost_gem_prime_export(struct drm_gem_object *obj, int flags)
 		.resv = obj->resv,
 	};
 
+	/* WB_MMAP BOs can't be shared. */
+	if (to_panfrost_bo(obj)->wb_mmap)
+		return ERR_PTR(-EINVAL);
+
 	return drm_gem_dmabuf_export(dev, &exp_info);
 }
 
diff --git a/include/uapi/drm/panfrost_drm.h b/include/uapi/drm/panfrost_drm.h
index 7831c48c59c0..2cc44591e82b 100644
--- a/include/uapi/drm/panfrost_drm.h
+++ b/include/uapi/drm/panfrost_drm.h
@@ -126,6 +126,7 @@ struct drm_panfrost_wait_bo {
 
 /* Valid flags to pass to drm_panfrost_create_bo.
  * PANFROST_BO_WB_MMAP can't be set if PANFROST_BO_HEAP is.
+ * Also, PANFROST_BO_WB_MMAP BOs can't be exported.
  */
 #define PANFROST_BO_NOEXEC	1
 #define PANFROST_BO_HEAP	2

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/6] drm/panfrost: Drop custom dma_buf_ops
  2026-11-19 19:38 [PATCH 0/6] drm/panfrost,panthor: Refuse to export WB_MMAP BOs Maíra Canal
  2026-11-19 19:38 ` [PATCH 1/6] drm/shmem: Add a drm_gem_shmem_sync() helper Maíra Canal
  2026-11-19 19:38 ` [PATCH 2/6] drm/panfrost: Refuse to export WB_MMAP BOs Maíra Canal
@ 2026-11-19 19:38 ` Maíra Canal
  2026-11-19 19:38 ` [PATCH 4/6] drm/panfrost: Use drm_gem_shmem_sync() Maíra Canal
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Maíra Canal @ 2026-11-19 19:38 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Faith Ekstrand, Boris Brezillon, Rob Herring,
	Steven Price, Adrián Larumbe, Liviu Dudau, Akash Goel,
	Karunika Choo, Lukas Zapolskas, Chris Diamand, Daniel Almeida,
	Alice Ryhl
  Cc: kernel-dev, dri-devel, rust-for-linux, Maíra Canal

The custom dma_buf_ops were added to provide CPU cache maintenance in
begin/end_cpu_access() for WB_MMAP BOs. As those can no longer be
exported, use the default PRIME ops.

On IO-coherent GPUs, all BOs are CPU-mapped WB, so exported BOs lose
begin/end_cpu_access() cache maintenance for non-coherent importers.
This restores the behavior prior to commit 3ae6637378e6 ("drm/panfrost:
Provide a custom dma_buf implementation").

Suggested-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Maíra Canal <mcanal@igalia.com>
---
 drivers/gpu/drm/panfrost/panfrost_drv.c |   1 -
 drivers/gpu/drm/panfrost/panfrost_gem.c | 118 +-------------------------------
 drivers/gpu/drm/panfrost/panfrost_gem.h |   3 -
 3 files changed, 1 insertion(+), 121 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c
index eeda113037fe..0a6ff8bec66d 100644
--- a/drivers/gpu/drm/panfrost/panfrost_drv.c
+++ b/drivers/gpu/drm/panfrost/panfrost_drv.c
@@ -824,7 +824,6 @@ static const struct drm_driver panfrost_drm_driver = {
 	.minor			= 7,
 
 	.gem_create_object	= panfrost_gem_create_object,
-	.gem_prime_import	= panfrost_gem_prime_import,
 	.gem_prime_import_sg_table = panfrost_gem_prime_import_sg_table,
 #ifdef CONFIG_DEBUG_FS
 	.debugfs_init = panfrost_device_debugfs_init,
diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c
index c7160223ea17..7d04793cc6ce 100644
--- a/drivers/gpu/drm/panfrost/panfrost_gem.c
+++ b/drivers/gpu/drm/panfrost/panfrost_gem.c
@@ -289,130 +289,14 @@ static size_t panfrost_gem_rss(struct drm_gem_object *obj)
 	return 0;
 }
 
-static struct sg_table *
-panfrost_gem_prime_map_dma_buf(struct dma_buf_attachment *attach,
-			       enum dma_data_direction dir)
-{
-	struct sg_table *sgt = drm_gem_map_dma_buf(attach, dir);
-
-	if (!IS_ERR(sgt))
-		attach->priv = sgt;
-
-	return sgt;
-}
-
-static void
-panfrost_gem_prime_unmap_dma_buf(struct dma_buf_attachment *attach,
-				 struct sg_table *sgt,
-				 enum dma_data_direction dir)
-{
-	attach->priv = NULL;
-	drm_gem_unmap_dma_buf(attach, sgt, dir);
-}
-
-static int
-panfrost_gem_prime_begin_cpu_access(struct dma_buf *dma_buf,
-				    enum dma_data_direction dir)
-{
-	struct drm_gem_object *obj = dma_buf->priv;
-	struct drm_device *dev = obj->dev;
-	struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);
-	struct dma_buf_attachment *attach;
-
-	dma_resv_lock(obj->resv, NULL);
-	if (shmem->sgt)
-		dma_sync_sgtable_for_cpu(dev->dev, shmem->sgt, dir);
-
-	if (shmem->vaddr)
-		invalidate_kernel_vmap_range(shmem->vaddr, shmem->base.size);
-
-	list_for_each_entry(attach, &dma_buf->attachments, node) {
-		struct sg_table *sgt = attach->priv;
-
-		if (sgt)
-			dma_sync_sgtable_for_cpu(attach->dev, sgt, dir);
-	}
-	dma_resv_unlock(obj->resv);
-
-	return 0;
-}
-
-static int
-panfrost_gem_prime_end_cpu_access(struct dma_buf *dma_buf,
-				  enum dma_data_direction dir)
-{
-	struct drm_gem_object *obj = dma_buf->priv;
-	struct drm_device *dev = obj->dev;
-	struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);
-	struct dma_buf_attachment *attach;
-
-	dma_resv_lock(obj->resv, NULL);
-	list_for_each_entry(attach, &dma_buf->attachments, node) {
-		struct sg_table *sgt = attach->priv;
-
-		if (sgt)
-			dma_sync_sgtable_for_device(attach->dev, sgt, dir);
-	}
-
-	if (shmem->vaddr)
-		flush_kernel_vmap_range(shmem->vaddr, shmem->base.size);
-
-	if (shmem->sgt)
-		dma_sync_sgtable_for_device(dev->dev, shmem->sgt, dir);
-
-	dma_resv_unlock(obj->resv);
-	return 0;
-}
-
-static const struct dma_buf_ops panfrost_dma_buf_ops = {
-	.attach = drm_gem_map_attach,
-	.detach = drm_gem_map_detach,
-	.map_dma_buf = panfrost_gem_prime_map_dma_buf,
-	.unmap_dma_buf = panfrost_gem_prime_unmap_dma_buf,
-	.release = drm_gem_dmabuf_release,
-	.mmap = drm_gem_dmabuf_mmap,
-	.vmap = drm_gem_dmabuf_vmap,
-	.vunmap = drm_gem_dmabuf_vunmap,
-	.begin_cpu_access = panfrost_gem_prime_begin_cpu_access,
-	.end_cpu_access = panfrost_gem_prime_end_cpu_access,
-};
-
 static struct dma_buf *
 panfrost_gem_prime_export(struct drm_gem_object *obj, int flags)
 {
-	struct drm_device *dev = obj->dev;
-	struct dma_buf_export_info exp_info = {
-		.exp_name = KBUILD_MODNAME,
-		.owner = THIS_MODULE,
-		.ops = &panfrost_dma_buf_ops,
-		.size = obj->size,
-		.flags = flags,
-		.priv = obj,
-		.resv = obj->resv,
-	};
-
 	/* WB_MMAP BOs can't be shared. */
 	if (to_panfrost_bo(obj)->wb_mmap)
 		return ERR_PTR(-EINVAL);
 
-	return drm_gem_dmabuf_export(dev, &exp_info);
-}
-
-struct drm_gem_object *
-panfrost_gem_prime_import(struct drm_device *dev,
-			  struct dma_buf *dma_buf)
-{
-	struct drm_gem_object *obj = dma_buf->priv;
-
-	if (dma_buf->ops == &panfrost_dma_buf_ops && obj->dev == dev) {
-		/* Importing dmabuf exported from our own gem increases
-		 * refcount on gem itself instead of f_count of dmabuf.
-		 */
-		drm_gem_object_get(obj);
-		return obj;
-	}
-
-	return drm_gem_prime_import(dev, dma_buf);
+	return drm_gem_prime_export(obj, flags);
 }
 
 static const struct drm_gem_object_funcs panfrost_gem_funcs = {
diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.h b/drivers/gpu/drm/panfrost/panfrost_gem.h
index 3008afcf4bff..b80bd5f2295f 100644
--- a/drivers/gpu/drm/panfrost/panfrost_gem.h
+++ b/drivers/gpu/drm/panfrost/panfrost_gem.h
@@ -138,9 +138,6 @@ struct drm_gem_object *
 panfrost_gem_prime_import_sg_table(struct drm_device *dev,
 				   struct dma_buf_attachment *attach,
 				   struct sg_table *sgt);
-struct drm_gem_object *
-panfrost_gem_prime_import(struct drm_device *dev,
-			  struct dma_buf *dma_buf);
 
 struct panfrost_gem_object *
 panfrost_gem_create(struct drm_device *dev, size_t size, u32 flags);

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/6] drm/panfrost: Use drm_gem_shmem_sync()
  2026-11-19 19:38 [PATCH 0/6] drm/panfrost,panthor: Refuse to export WB_MMAP BOs Maíra Canal
                   ` (2 preceding siblings ...)
  2026-11-19 19:38 ` [PATCH 3/6] drm/panfrost: Drop custom dma_buf_ops Maíra Canal
@ 2026-11-19 19:38 ` Maíra Canal
  2026-11-19 19:38 ` [PATCH 5/6] drm/panthor: Refuse to export WB_MMAP BOs Maíra Canal
  2026-11-19 19:38 ` [PATCH 6/6] drm/panthor: Drop custom dma_buf_ops Maíra Canal
  5 siblings, 0 replies; 8+ messages in thread
From: Maíra Canal @ 2026-11-19 19:38 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Faith Ekstrand, Boris Brezillon, Rob Herring,
	Steven Price, Adrián Larumbe, Liviu Dudau, Akash Goel,
	Karunika Choo, Lukas Zapolskas, Chris Diamand, Daniel Almeida,
	Alice Ryhl
  Cc: kernel-dev, dri-devel, rust-for-linux, Maíra Canal

panfrost_gem_sync() has the same code as the function drm_gem_shmem_sync().
Translate the UAPI sync type to the common shmem type and use the shmem
helper instead.

Signed-off-by: Maíra Canal <mcanal@igalia.com>
---
 drivers/gpu/drm/panfrost/panfrost_gem.c | 74 +++------------------------------
 1 file changed, 5 insertions(+), 69 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c
index 7d04793cc6ce..5b4401b967aa 100644
--- a/drivers/gpu/drm/panfrost/panfrost_gem.c
+++ b/drivers/gpu/drm/panfrost/panfrost_gem.c
@@ -443,84 +443,20 @@ int
 panfrost_gem_sync(struct drm_gem_object *obj, u32 type, u32 offset, u32 size)
 {
 	struct panfrost_gem_object *bo = to_panfrost_bo(obj);
-	struct drm_gem_shmem_object *shmem = &bo->base;
-	const struct drm_device *dev = shmem->base.dev;
-	struct sg_table *sgt;
-	struct scatterlist *sgl;
-	unsigned int count;
-
-	/* Make sure the range is in bounds. */
-	if (offset + size < offset || offset + size > shmem->base.size)
-		return -EINVAL;
-
-	/* Disallow CPU-cache maintenance on imported buffers. */
-	if (drm_gem_is_imported(&shmem->base))
-		return -EINVAL;
+	enum drm_gem_shmem_sync_type shmem_type;
 
 	switch (type) {
 	case PANFROST_BO_SYNC_CPU_CACHE_FLUSH:
+		shmem_type = DRM_GEM_SHMEM_SYNC_CPU_CACHE_FLUSH;
+		break;
 	case PANFROST_BO_SYNC_CPU_CACHE_FLUSH_AND_INVALIDATE:
+		shmem_type = DRM_GEM_SHMEM_SYNC_CPU_CACHE_FLUSH_AND_INVALIDATE;
 		break;
-
 	default:
 		return -EINVAL;
 	}
 
-	/* Don't bother if it's WC-mapped */
-	if (shmem->map_wc)
-		return 0;
-
-	/* Nothing to do if the size is zero. */
-	if (size == 0)
-		return 0;
-
-	sgt = drm_gem_shmem_get_pages_sgt(shmem);
-	if (IS_ERR(sgt))
-		return PTR_ERR(sgt);
-
-	for_each_sgtable_dma_sg(sgt, sgl, count) {
-		if (size == 0)
-			break;
-
-		dma_addr_t paddr = sg_dma_address(sgl);
-		size_t len = sg_dma_len(sgl);
-
-		if (len <= offset) {
-			offset -= len;
-			continue;
-		}
-
-		paddr += offset;
-		len -= offset;
-		len = min_t(size_t, len, size);
-		size -= len;
-		offset = 0;
-
-		/* It's unclear whether dma_sync_xxx() is the right API to do CPU
-		 * cache maintenance given an IOMMU can register their own
-		 * implementation doing more than just CPU cache flushes/invalidation,
-		 * and what we really care about here is CPU caches only, but that's
-		 * the best we have that is both arch-agnostic and does at least the
-		 * CPU cache maintenance on a <page,offset,size> tuple.
-		 *
-		 * Also, I wish we could do a single
-		 *
-		 *      dma_sync_single_for_device(BIDIR)
-		 *
-		 * and get a flush+invalidate, but that's not how it's implemented
-		 * in practice (at least on arm64), so we have to make it
-		 *
-		 *      dma_sync_single_for_device(TO_DEVICE)
-		 *      dma_sync_single_for_cpu(FROM_DEVICE)
-		 *
-		 * for the flush+invalidate case.
-		 */
-		dma_sync_single_for_device(dev->dev, paddr, len, DMA_TO_DEVICE);
-		if (type == PANFROST_BO_SYNC_CPU_CACHE_FLUSH_AND_INVALIDATE)
-			dma_sync_single_for_cpu(dev->dev, paddr, len, DMA_FROM_DEVICE);
-	}
-
-	return 0;
+	return drm_gem_shmem_sync(&bo->base, offset, size, shmem_type);
 }
 
 void

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/6] drm/panthor: Refuse to export WB_MMAP BOs
  2026-11-19 19:38 [PATCH 0/6] drm/panfrost,panthor: Refuse to export WB_MMAP BOs Maíra Canal
                   ` (3 preceding siblings ...)
  2026-11-19 19:38 ` [PATCH 4/6] drm/panfrost: Use drm_gem_shmem_sync() Maíra Canal
@ 2026-11-19 19:38 ` Maíra Canal
  2026-11-19 19:38 ` [PATCH 6/6] drm/panthor: Drop custom dma_buf_ops Maíra Canal
  5 siblings, 0 replies; 8+ messages in thread
From: Maíra Canal @ 2026-11-19 19:38 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Faith Ekstrand, Boris Brezillon, Rob Herring,
	Steven Price, Adrián Larumbe, Liviu Dudau, Akash Goel,
	Karunika Choo, Lukas Zapolskas, Chris Diamand, Daniel Almeida,
	Alice Ryhl
  Cc: kernel-dev, dri-devel, rust-for-linux, Maíra Canal

When a buffer is shared through dma-buf, clients are expected to bracket
their CPU accesses with DMA_BUF_IOCTL_SYNC, but there's no way to ensure
they do. With WC mappings, there are no CPU cache lines to maintain, so
waiting on fences is enough. With WB mappings, a missed sync can leave
dirty cache lines behind, which may later be written back over data the
GPU produced for another client.

To avoid this, don't allow WB_MMAP BOs to be shared. PanVK already keeps
WB_MMAP BOs private, so this makes the kernel enforce the same policy.

Suggested-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Maíra Canal <mcanal@igalia.com>
---
 drivers/gpu/drm/panthor/panthor_gem.c | 4 ++++
 include/uapi/drm/panthor_drm.h        | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/panthor/panthor_gem.c b/drivers/gpu/drm/panthor/panthor_gem.c
index 22b57ab6f929..730567d97f46 100644
--- a/drivers/gpu/drm/panthor/panthor_gem.c
+++ b/drivers/gpu/drm/panthor/panthor_gem.c
@@ -577,6 +577,10 @@ panthor_gem_prime_export(struct drm_gem_object *obj, int flags)
 	if (to_panthor_bo(obj)->exclusive_vm_root_gem)
 		return ERR_PTR(-EINVAL);
 
+	/* WB_MMAP BOs can't be shared. */
+	if (to_panthor_bo(obj)->flags & DRM_PANTHOR_BO_WB_MMAP)
+		return ERR_PTR(-EINVAL);
+
 	return drm_gem_dmabuf_export(dev, &exp_info);
 }
 
diff --git a/include/uapi/drm/panthor_drm.h b/include/uapi/drm/panthor_drm.h
index a2ff0f4ec691..8f3a3e680264 100644
--- a/include/uapi/drm/panthor_drm.h
+++ b/include/uapi/drm/panthor_drm.h
@@ -771,6 +771,8 @@ enum drm_panthor_bo_flags {
 	 * CPU map the buffer object in userspace by forcing the "Write-Back
 	 * Cacheable" cacheability attribute. The mapping otherwise uses the
 	 * "Non-Cacheable" attribute if the GPU is not IO coherent.
+	 *
+	 * Buffer objects created with this flag can't be exported.
 	 */
 	DRM_PANTHOR_BO_WB_MMAP = (1 << 1),
 };

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 6/6] drm/panthor: Drop custom dma_buf_ops
  2026-11-19 19:38 [PATCH 0/6] drm/panfrost,panthor: Refuse to export WB_MMAP BOs Maíra Canal
                   ` (4 preceding siblings ...)
  2026-11-19 19:38 ` [PATCH 5/6] drm/panthor: Refuse to export WB_MMAP BOs Maíra Canal
@ 2026-11-19 19:38 ` Maíra Canal
  5 siblings, 0 replies; 8+ messages in thread
From: Maíra Canal @ 2026-11-19 19:38 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Faith Ekstrand, Boris Brezillon, Rob Herring,
	Steven Price, Adrián Larumbe, Liviu Dudau, Akash Goel,
	Karunika Choo, Lukas Zapolskas, Chris Diamand, Daniel Almeida,
	Alice Ryhl
  Cc: kernel-dev, dri-devel, rust-for-linux, Maíra Canal

The custom dma_buf_ops were added to provide CPU cache maintenance in
begin/end_cpu_access() for WB_MMAP BOs. As those can no longer be
exported, use the default PRIME ops.

On IO-coherent GPUs, all BOs are CPU-mapped WB, so exported BOs lose
begin/end_cpu_access() cache maintenance for non-coherent importers.
This restores the behavior prior to commit 925ad0c26dd8 ("drm/panthor:
Provide a custom dma_buf implementation").

Suggested-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Maíra Canal <mcanal@igalia.com>
---
 drivers/gpu/drm/panthor/panthor_drv.c |   1 -
 drivers/gpu/drm/panthor/panthor_gem.c | 118 +---------------------------------
 drivers/gpu/drm/panthor/panthor_gem.h |   4 --
 3 files changed, 1 insertion(+), 122 deletions(-)

diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
index dc8d0191aef4..8712587b37d6 100644
--- a/drivers/gpu/drm/panthor/panthor_drv.c
+++ b/drivers/gpu/drm/panthor/panthor_drv.c
@@ -1801,7 +1801,6 @@ static const struct drm_driver panthor_drm_driver = {
 	.minor = 9,
 
 	.gem_prime_import_sg_table = panthor_gem_prime_import_sg_table,
-	.gem_prime_import = panthor_gem_prime_import,
 #ifdef CONFIG_DEBUG_FS
 	.debugfs_init = panthor_debugfs_init,
 #endif
diff --git a/drivers/gpu/drm/panthor/panthor_gem.c b/drivers/gpu/drm/panthor/panthor_gem.c
index 730567d97f46..af8c94031d14 100644
--- a/drivers/gpu/drm/panthor/panthor_gem.c
+++ b/drivers/gpu/drm/panthor/panthor_gem.c
@@ -471,108 +471,9 @@ static void panthor_gem_free_object(struct drm_gem_object *obj)
 	drm_gem_object_put(vm_root_gem);
 }
 
-static struct sg_table *
-panthor_gem_prime_map_dma_buf(struct dma_buf_attachment *attach,
-			      enum dma_data_direction dir)
-{
-	struct sg_table *sgt = drm_gem_map_dma_buf(attach, dir);
-
-	if (!IS_ERR(sgt))
-		attach->priv = sgt;
-
-	return sgt;
-}
-
-static void
-panthor_gem_prime_unmap_dma_buf(struct dma_buf_attachment *attach,
-				struct sg_table *sgt,
-				enum dma_data_direction dir)
-{
-	attach->priv = NULL;
-	drm_gem_unmap_dma_buf(attach, sgt, dir);
-}
-
-static int
-panthor_gem_prime_begin_cpu_access(struct dma_buf *dma_buf,
-				   enum dma_data_direction dir)
-{
-	struct drm_gem_object *obj = dma_buf->priv;
-	struct drm_device *dev = obj->dev;
-	struct panthor_gem_object *bo = to_panthor_bo(obj);
-	struct dma_buf_attachment *attach;
-
-	dma_resv_lock(obj->resv, NULL);
-	if (bo->dmap.sgt)
-		dma_sync_sgtable_for_cpu(drm_dev_dma_dev(dev), bo->dmap.sgt, dir);
-
-	if (bo->cmap.vaddr)
-		invalidate_kernel_vmap_range(bo->cmap.vaddr, bo->base.size);
-
-	list_for_each_entry(attach, &dma_buf->attachments, node) {
-		struct sg_table *sgt = attach->priv;
-
-		if (sgt)
-			dma_sync_sgtable_for_cpu(attach->dev, sgt, dir);
-	}
-	dma_resv_unlock(obj->resv);
-
-	return 0;
-}
-
-static int
-panthor_gem_prime_end_cpu_access(struct dma_buf *dma_buf,
-				 enum dma_data_direction dir)
-{
-	struct drm_gem_object *obj = dma_buf->priv;
-	struct drm_device *dev = obj->dev;
-	struct panthor_gem_object *bo = to_panthor_bo(obj);
-	struct dma_buf_attachment *attach;
-
-	dma_resv_lock(obj->resv, NULL);
-	list_for_each_entry(attach, &dma_buf->attachments, node) {
-		struct sg_table *sgt = attach->priv;
-
-		if (sgt)
-			dma_sync_sgtable_for_device(attach->dev, sgt, dir);
-	}
-
-	if (bo->cmap.vaddr)
-		flush_kernel_vmap_range(bo->cmap.vaddr, bo->base.size);
-
-	if (bo->dmap.sgt)
-		dma_sync_sgtable_for_device(drm_dev_dma_dev(dev), bo->dmap.sgt, dir);
-
-	dma_resv_unlock(obj->resv);
-	return 0;
-}
-
-static const struct dma_buf_ops panthor_dma_buf_ops = {
-	.attach = drm_gem_map_attach,
-	.detach = drm_gem_map_detach,
-	.map_dma_buf = panthor_gem_prime_map_dma_buf,
-	.unmap_dma_buf = panthor_gem_prime_unmap_dma_buf,
-	.release = drm_gem_dmabuf_release,
-	.mmap = drm_gem_dmabuf_mmap,
-	.vmap = drm_gem_dmabuf_vmap,
-	.vunmap = drm_gem_dmabuf_vunmap,
-	.begin_cpu_access = panthor_gem_prime_begin_cpu_access,
-	.end_cpu_access = panthor_gem_prime_end_cpu_access,
-};
-
 static struct dma_buf *
 panthor_gem_prime_export(struct drm_gem_object *obj, int flags)
 {
-	struct drm_device *dev = obj->dev;
-	struct dma_buf_export_info exp_info = {
-		.exp_name = KBUILD_MODNAME,
-		.owner = THIS_MODULE,
-		.ops = &panthor_dma_buf_ops,
-		.size = obj->size,
-		.flags = flags,
-		.priv = obj,
-		.resv = obj->resv,
-	};
-
 	/* We can't export GEMs that have an exclusive VM. */
 	if (to_panthor_bo(obj)->exclusive_vm_root_gem)
 		return ERR_PTR(-EINVAL);
@@ -581,24 +482,7 @@ panthor_gem_prime_export(struct drm_gem_object *obj, int flags)
 	if (to_panthor_bo(obj)->flags & DRM_PANTHOR_BO_WB_MMAP)
 		return ERR_PTR(-EINVAL);
 
-	return drm_gem_dmabuf_export(dev, &exp_info);
-}
-
-struct drm_gem_object *
-panthor_gem_prime_import(struct drm_device *dev,
-			 struct dma_buf *dma_buf)
-{
-	struct drm_gem_object *obj = dma_buf->priv;
-
-	if (dma_buf->ops == &panthor_dma_buf_ops && obj->dev == dev) {
-		/* Importing dmabuf exported from our own gem increases
-		 * refcount on gem itself instead of f_count of dmabuf.
-		 */
-		drm_gem_object_get(obj);
-		return obj;
-	}
-
-	return drm_gem_prime_import(dev, dma_buf);
+	return drm_gem_prime_export(obj, flags);
 }
 
 static void panthor_gem_print_info(struct drm_printer *p, unsigned int indent,
diff --git a/drivers/gpu/drm/panthor/panthor_gem.h b/drivers/gpu/drm/panthor/panthor_gem.h
index 5ae37d0d3646..444ef9f66adf 100644
--- a/drivers/gpu/drm/panthor/panthor_gem.h
+++ b/drivers/gpu/drm/panthor/panthor_gem.h
@@ -274,10 +274,6 @@ void panthor_gem_kernel_bo_set_label(struct panthor_kernel_bo *bo, const char *l
 int panthor_gem_sync(struct drm_gem_object *obj,
 		     u32 type, u64 offset, u64 size);
 
-struct drm_gem_object *
-panthor_gem_prime_import(struct drm_device *dev,
-			 struct dma_buf *dma_buf);
-
 static inline u64
 panthor_kernel_bo_gpuva(struct panthor_kernel_bo *bo)
 {

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/6] drm/shmem: Add a drm_gem_shmem_sync() helper
  2026-11-19 19:38 ` [PATCH 1/6] drm/shmem: Add a drm_gem_shmem_sync() helper Maíra Canal
@ 2026-11-19 19:55   ` sashiko-bot
  0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-11-19 19:55 UTC (permalink / raw)
  To: Maíra Canal; +Cc: dri-devel, ojeda, gary

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/shmem: unlocked sgt traversal in drm_gem_shmem_sync()
  causes UAF
- [Medium] drm/shmem: drm_gem_shmem_sync() populates pages on purged or
  unbacked BOs
--

commit 9fdf5667225c80a2c62b9b65dbf8c174b87f854f
Author: Faith Ekstrand <faith.ekstrand@collabora.com>

drm/shmem: Add a drm_gem_shmem_sync() helper

This commit adds a drm_gem_shmem_sync() helper to flush or invalidate CPU
caches for a range of a shmem GEM object by walking its scatter-gather table
and calling dma_sync_single_for_device() and dma_sync_single_for_cpu().

> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
> index d654a22a30ded..72933ed283731 100644
> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
> @@ -790,6 +790,99 @@ int drm_gem_shmem_mmap(struct drm_gem_shmem_object *shmem, struct vm_area_struct
>  }
>  EXPORT_SYMBOL_GPL(drm_gem_shmem_mmap);
>  
> +/**
> + * drm_gem_shmem_sync - Sync CPU-mapped data
> + * @shmem: shmem GEM object
> + * @offset: Offset into the GEM object
> + * @size: Size of the area to sync
> + * @type: Type of synchronization
> + *
> + * Returns:
> + * 0 on success or a negative error code on failure.
> + */
> +int drm_gem_shmem_sync(struct drm_gem_shmem_object *shmem, size_t offset,
> +		       size_t size, enum drm_gem_shmem_sync_type type)
> +{
> +	const struct drm_device *dev = shmem->base.dev;
> +	struct sg_table *sgt;
> +	struct scatterlist *sgl;
> +	unsigned int count;
> +
> +	/* Make sure the range is in bounds. */
> +	if (offset + size < offset || offset + size > shmem->base.size)
> +		return -EINVAL;
> +
> +	/* Disallow CPU-cache maintenance on imported buffers. */
> +	if (drm_gem_is_imported(&shmem->base))
> +		return -EINVAL;
> +
> +	switch (type) {
> +	case DRM_GEM_SHMEM_SYNC_CPU_CACHE_FLUSH:
> +	case DRM_GEM_SHMEM_SYNC_CPU_CACHE_FLUSH_AND_INVALIDATE:
> +		break;
> +
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	/* Don't bother if it's WC-mapped */
> +	if (shmem->map_wc)
> +		return 0;
> +
> +	/* Nothing to do if the size is zero. */
> +	if (size == 0)
> +		return 0;
> +
> +	sgt = drm_gem_shmem_get_pages_sgt(shmem);
> +	if (IS_ERR(sgt))
> +		return PTR_ERR(sgt);

[Severity: Medium]
Should drm_gem_shmem_sync() populate backing pages and a scatter-gather
table when shmem->pages is NULL or the object has been purged?

Calling drm_gem_shmem_get_pages_sgt() on an unbacked object allocates and
DMA-maps pages when there is no CPU-cached data to sync.  If the object was
already purged (shmem->madv < 0), drm_gem_shmem_get_pages_sgt() allocates a
new shmem->sgt and pages (or takes another reference on truncated pages
kept alive by an open VMA), and because drm_gem_shmem_is_purgeable()
requires shmem->madv > 0, the newly populated pages and sgt can never be
purged again until the GEM object is freed.

> +
> +	for_each_sgtable_dma_sg(sgt, sgl, count) {
> +		if (size == 0)
> +			break;
> +
> +		dma_addr_t paddr = sg_dma_address(sgl);
> +		size_t len = sg_dma_len(sgl);
> +
> +		if (len <= offset) {
> +			offset -= len;
> +			continue;
> +		}
> +
> +		paddr += offset;
> +		len -= offset;
> +		len = min_t(size_t, len, size);
> +		size -= len;
> +		offset = 0;
[ ... ]
> +		dma_sync_single_for_device(dev->dev, paddr, len, DMA_TO_DEVICE);
> +		if (type == DRM_GEM_SHMEM_SYNC_CPU_CACHE_FLUSH_AND_INVALIDATE)
> +			dma_sync_single_for_cpu(dev->dev, paddr, len, DMA_FROM_DEVICE);
> +	}

[Severity: High]
Can sgt be unmapped and freed while drm_gem_shmem_sync() is walking it?

drm_gem_shmem_get_pages_sgt() unlocks shmem->base.resv before returning
sgt, and does not increment shmem->pages_pin_count.  If the buffer is
marked purgeable (shmem->madv > 0, pages_pin_count == 0), a concurrent
shrinker can purge it while the loop runs:

CPU0                                  CPU1
drm_gem_shmem_sync()
  drm_gem_shmem_get_pages_sgt()
    dma_resv_lock_interruptible(...)
    drm_gem_shmem_get_pages_sgt_locked()
    dma_resv_unlock(...)
                                      ...
                                        drm_gem_shmem_purge_locked()
                                          dma_unmap_sgtable(..., shmem->sgt, ...)
                                          sg_free_table(shmem->sgt)
                                          kfree(shmem->sgt)
  for_each_sgtable_dma_sg(sgt, ...)
    sg_dma_address(sgl)  <-- use-after-free

Holding shmem->base.resv across drm_gem_shmem_get_pages_sgt_locked() and
the scatterlist walk would prevent concurrent purging or sgt teardown.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119-pan-drop-dma-buf-hooks-v1-0-6c6f1629e7f9@igalia.com?part=1

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-11-19 19:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 19:38 [PATCH 0/6] drm/panfrost,panthor: Refuse to export WB_MMAP BOs Maíra Canal
2026-11-19 19:38 ` [PATCH 1/6] drm/shmem: Add a drm_gem_shmem_sync() helper Maíra Canal
2026-11-19 19:55   ` sashiko-bot
2026-11-19 19:38 ` [PATCH 2/6] drm/panfrost: Refuse to export WB_MMAP BOs Maíra Canal
2026-11-19 19:38 ` [PATCH 3/6] drm/panfrost: Drop custom dma_buf_ops Maíra Canal
2026-11-19 19:38 ` [PATCH 4/6] drm/panfrost: Use drm_gem_shmem_sync() Maíra Canal
2026-11-19 19:38 ` [PATCH 5/6] drm/panthor: Refuse to export WB_MMAP BOs Maíra Canal
2026-11-19 19:38 ` [PATCH 6/6] drm/panthor: Drop custom dma_buf_ops Maíra Canal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox