drm/i915: Reject undefined colorkey flags
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 6 Feb 2018 20:43:33 +0000 (22:43 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Fri, 9 Feb 2018 16:03:36 +0000 (18:03 +0200)
Check that userspace isn't passing in garbage in the colorkey
ioctl flags.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180206204333.4399-1-ville.syrjala@linux.intel.com
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
drivers/gpu/drm/i915/intel_sprite.c

index 32f10621fac814a90045a6d5edaa8f0b93bed48d..d8900d09bef7219ed436d879b6241739c4ef35d0 100644 (file)
@@ -1073,6 +1073,9 @@ int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
        /* ignore the pointless "none" flag */
        set->flags &= ~I915_SET_COLORKEY_NONE;
 
+       if (set->flags & ~(I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE))
+               return -EINVAL;
+
        /* Make sure we don't try to enable both src & dest simultaneously */
        if ((set->flags & (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) == (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE))
                return -EINVAL;