From 4ecd7c697206a152f2e9a9f900f299b18cfbc705 Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Fri, 11 Jun 2021 21:59:05 +0200 Subject: drm/i915/eb: Report EFAULT when writing updated exec_obj offset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was thrown out in commit 2889caa9232109afc8881f29a2205abeb5709d0c Author: Chris Wilson Date: Fri Jun 16 15:05:19 2017 +0100 drm/i915: Eliminate lots of iterations over the execobjects array with the justification that we're already past the point of no return (in a comment, not in the commit message). That's true, but also if userspace is silly and hands us read-only memory, then we'll only notice that when we write to it. So reporting the error is still our duty, not that it's likely - at this point we're dealing with nasty userspace anyway. Also this is what we've been doing for around 8 years before this patch changed it. Signed-off-by: Daniel Vetter Cc: Jon Bloomfield Cc: Chris Wilson Cc: Maarten Lankhorst Cc: Joonas Lahtinen Cc: Daniel Vetter Cc: "Thomas Hellström" Cc: Matthew Auld Cc: Lionel Landwerlin Cc: Dave Airlie Cc: Jason Ekstrand --- drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c index 3753b9661f32..9f8c32c93d82 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c @@ -3590,16 +3590,11 @@ i915_gem_execbuffer2_ioctl(struct drm_device *dev, void *data, err = i915_gem_do_execbuffer(dev, file, args, exec2_list); - /* - * Now that we have begun execution of the batchbuffer, we ignore - * any new error after this point. Also given that we have already - * updated the associated relocations, we try to write out the current - * object locations irrespective of any error. - */ if (args->flags & __EXEC_HAS_RELOC) { struct drm_i915_gem_exec_object2 __user *user_exec_list = u64_to_user_ptr(args->buffers_ptr); unsigned int i; + bool failed = true; /* Copy the new buffer offsets back to the user's exec list. */ /* @@ -3623,9 +3618,12 @@ i915_gem_execbuffer2_ioctl(struct drm_device *dev, void *data, &user_exec_list[i].offset, end_user); } + failed = false; end_user: user_write_access_end(); -end:; +end: + if (failed) + err = -EFAULT; } args->flags &= ~__I915_EXEC_UNKNOWN_FLAGS; -- cgit v1.2.3