drm/i915: Avoid truncation before clamping userspace's priority value
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 8 Feb 2018 08:51:51 +0000 (08:51 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Thu, 8 Feb 2018 11:30:00 +0000 (11:30 +0000)
Userspace provides a 64b value for the priority, we need to be careful
to preserve the full range before validation to prevent truncation (and
letting an illegal value pass).

Reported-by: Antonio Argenziano <antonio.argenziano@intel.com>
Fixes: ac14fbd460d0 ("drm/i915/scheduler: Support user-defined priorities")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Antonio Argenziano <antonio.argenziano@intel.com>
Cc: Michal Winiarski <michal.winiarski@intel.com>
Cc: Mika Kuoppala <mika.kuoppala@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180208085151.11480-1-chris@chris-wilson.co.uk
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
drivers/gpu/drm/i915/i915_gem_context.c

index dd9efb9d0e0b52d1e1946f0c5fe90e180ae9e88a..7ccba6c786ae44a5cb81bd84eeca234f2037f24f 100644 (file)
@@ -804,7 +804,7 @@ int i915_gem_context_setparam_ioctl(struct drm_device *dev, void *data,
 
        case I915_CONTEXT_PARAM_PRIORITY:
                {
-                       int priority = args->value;
+                       s64 priority = args->value;
 
                        if (args->size)
                                ret = -EINVAL;