drm/i915: Enforce execobject.alignment to be a power-of-two
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 19 Jun 2015 12:59:46 +0000 (13:59 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 22 Jun 2015 14:13:23 +0000 (16:13 +0200)
Internal requirement for the alignment is that it must be a
power-of-two, so enforce rejection at the user interface to execbuffer
(which allows the caller to specify a stricter-than-expected alignment
criterion).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_gem_execbuffer.c

index edb8c458cbe15d5c29fa89b50a378c8324b8aca7..21f8eb65925165b79c0928441eb8c11a0345ad50 100644 (file)
@@ -957,6 +957,9 @@ validate_exec_list(struct drm_device *dev,
                if (exec[i].flags & invalid_flags)
                        return -EINVAL;
 
+               if (exec[i].alignment && !is_power_of_2(exec[i].alignment))
+                       return -EINVAL;
+
                /* First check for malicious input causing overflow in
                 * the worst case where we need to allocate the entire
                 * relocation tree as a single array.