[Intel-gfx] [PATCH] drm/i915: Prevent GGTT access if not available for pread/pwrite

Chris Wilson chris at chris-wilson.co.uk
Wed Nov 4 17:10:16 UTC 2020


If there is no mappable GGTT aperture, trying to use it for
copy_(from|to)_user is a dangerous experience. Report ENODEV to indicate
the operation is not supported to the upper layer.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index bb0c12975f38..a1f1ffe18682 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -61,6 +61,9 @@ insert_mappable_node(struct i915_ggtt *ggtt, struct drm_mm_node *node, u32 size)
 {
 	int err;
 
+	if (!i915_ggtt_has_aperture(ggtt))
+		return -ENODEV;
+
 	err = mutex_lock_interruptible(&ggtt->vm.mutex);
 	if (err)
 		return err;
-- 
2.20.1



More information about the Intel-gfx mailing list