Read-only userptr BOs shouldn't be allowed to have relocation addresses written back to them. Enforce that. The relocation slow path where this could have happened has been in place, reverted and then re-introduced. GPU relocations path protected against this via ppGTT flags was also reverted at point. There's no legimate use-case for this, so instead of trying to track which kernel versions were impacted and which not, just outright reject with EFAULT on all kernels with RO userptr support. Reported-by: Zakaria Belkadi Fixes: 0b100760e3e8 ("drm/i915/userptr: Enable read-only support on gen8+") Cc: # v4.19+ Cc: Matthew Auld Cc: Jani Nikula Cc: Rodrigo Vivi Cc: Tvrtko Ursulin Signed-off-by: Joonas Lahtinen --- drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c index c41e1b9a40bc..7ed23dc392b8 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c @@ -511,6 +511,10 @@ eb_validate_vma(struct i915_execbuffer *eb, if (unlikely(entry->flags & eb->invalid_flags)) return -EINVAL; + if (unlikely(i915_gem_object_is_readonly(vma->obj) && + entry->relocation_count)) + return -EFAULT; + if (unlikely(entry->alignment && !is_power_of_2_u64(entry->alignment))) return -EINVAL; -- 2.56.1