drm: Reject unknown legacy bpp and depth for drm_mode_addfb ioctl
authorChris Wilson <chris@chris-wilson.co.uk>
Wed, 5 Sep 2018 15:31:16 +0000 (16:31 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Thu, 6 Sep 2018 07:07:41 +0000 (08:07 +0100)
commit70109354fed232dfce8fb2c7cadf635acbe03e19
tree4a5332f978526920d708dab36d30393dbbdb7dbd
parent6960e6da9cec3f6638121527c728305827ec12ab
drm: Reject unknown legacy bpp and depth for drm_mode_addfb ioctl

Since this is handling user provided bpp and depth, we need to sanity
check and propagate the EINVAL back rather than assume what the insane
client intended and fill the logs with DRM_ERROR.

v2: Check both bpp and depth match the builtin pixel format, and
introduce a canonical DRM_FORMAT_INVALID to reserve 0 against any future
fourcc.

v3: Mark up DRM_FORMAT_C8 as being {bpp:8, depth:8}

Testcase: igt/kms_addfb_basic/legacy-format
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20180905153116.28924-1-chris@chris-wilson.co.uk
drivers/gpu/drm/drm_fourcc.c
drivers/gpu/drm/drm_framebuffer.c
include/uapi/drm/drm_fourcc.h