All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: Reject unknown legacy bpp and dpeth for drm_mode_addfb ioctl
@ 2018-09-04 20:53 Chris Wilson
  2018-09-04 21:23 ` ✓ Fi.CI.BAT: success for " Patchwork
                   ` (7 more replies)
  0 siblings, 8 replies; 14+ messages in thread
From: Chris Wilson @ 2018-09-04 20:53 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter, intel-gfx

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.

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>
---
So I am presuming that r.pixel_format == 0 is rejected elsewhere for the
internal users (as if any would deliberately provoke the error)!
---
 drivers/gpu/drm/drm_fourcc.c      | 4 ++--
 drivers/gpu/drm/drm_framebuffer.c | 5 ++++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
index 35c1e2742c27..34595c5b55c9 100644
--- a/drivers/gpu/drm/drm_fourcc.c
+++ b/drivers/gpu/drm/drm_fourcc.c
@@ -69,8 +69,8 @@ uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)
 			fmt = DRM_FORMAT_ARGB8888;
 		break;
 	default:
-		DRM_ERROR("bad bpp, assuming x8r8g8b8 pixel format\n");
-		fmt = DRM_FORMAT_XRGB8888;
+		DRM_DEBUG("bad bpp [%d] and depth [%d]\n", bpp, depth);
+		fmt = 0;
 		break;
 	}
 
diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 781af1d42d76..7641bddfe367 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -112,12 +112,15 @@ int drm_mode_addfb(struct drm_device *dev, struct drm_mode_fb_cmd *or,
 	struct drm_mode_fb_cmd2 r = {};
 	int ret;
 
+	r.pixel_format = drm_mode_legacy_fb_format(or->bpp, or->depth);
+	if (!r.pixel_format)
+		return -EINVAL;
+
 	/* convert to new format and call new ioctl */
 	r.fb_id = or->fb_id;
 	r.width = or->width;
 	r.height = or->height;
 	r.pitches[0] = or->pitch;
-	r.pixel_format = drm_mode_legacy_fb_format(or->bpp, or->depth);
 	r.handles[0] = or->handle;
 
 	if (r.pixel_format == DRM_FORMAT_XRGB2101010 &&
-- 
2.19.0.rc1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2018-09-06  7:19 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-04 20:53 [PATCH] drm: Reject unknown legacy bpp and dpeth for drm_mode_addfb ioctl Chris Wilson
2018-09-04 21:23 ` ✓ Fi.CI.BAT: success for " Patchwork
2018-09-04 21:46 ` [PATCH] " Daniel Vetter
2018-09-05 10:10   ` Chris Wilson
2018-09-05  4:16 ` ✓ Fi.CI.IGT: success for " Patchwork
2018-09-05 10:22 ` [PATCH] drm: Reject unknown legacy bpp and depth " Chris Wilson
2018-09-05 10:29   ` Chris Wilson
2018-09-05 14:28   ` Daniel Vetter
2018-09-05 15:31   ` [PATCH v3] " Chris Wilson
2018-09-06  7:19     ` Chris Wilson
2018-09-05 11:55 ` ✓ Fi.CI.BAT: success for drm: Reject unknown legacy bpp and dpeth for drm_mode_addfb ioctl (rev2) Patchwork
2018-09-05 14:55 ` ✓ Fi.CI.IGT: " Patchwork
2018-09-05 16:28 ` ✓ Fi.CI.BAT: success for drm: Reject unknown legacy bpp and dpeth for drm_mode_addfb ioctl (rev3) Patchwork
2018-09-05 22:04 ` ✓ Fi.CI.IGT: " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.