All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: fb-helper: Validate requested pixel format against bpp
@ 2018-10-03 11:04 ` Eugeniy Paltsev
  0 siblings, 0 replies; 17+ messages in thread
From: Eugeniy Paltsev @ 2018-10-03 11:04 UTC (permalink / raw)
  To: dri-devel
  Cc: linux-snps-arc, linux-kernel, Gustavo Padovan, Maarten Lankhorst,
	Sean Paul, David Airlie, Alexey Brodkin, stable, Eugeniy Paltsev

Validate requested pixel format against bits_per_pixel to reject
invalid formats with subcomponents length sum is greater than requested
bits_per_pixel.

weston 5.0.0 with fbdev backend tries to set up an ARGB x8r8g8b8 pixel
format without bits_per_pixel updating. So it can request
x8r8g8b8 with 16 bpp which is obviously incorrect and should be
rejected.

Cc: stable@vger.kernel.org
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
---
 drivers/gpu/drm/drm_fb_helper.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 16ec93b75dbf..4f39da07f053 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1610,6 +1610,13 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
 		return -EINVAL;
 	}
 
+	if ((var->green.length + var->blue.length + var->red.length +
+	    var->transp.length) > var->bits_per_pixel) {
+		DRM_DEBUG("fb requested pixel format can't fit in %d bpp\n",
+			  var->bits_per_pixel);
+		return -EINVAL;
+	}
+
 	switch (var->bits_per_pixel) {
 	case 16:
 		depth = (var->green.length == 6) ? 16 : 15;
-- 
2.14.4


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

end of thread, other threads:[~2018-10-03 22:40 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-03 11:04 [PATCH] drm: fb-helper: Validate requested pixel format against bpp Eugeniy Paltsev
2018-10-03 11:04 ` Eugeniy Paltsev
2018-10-03 11:36 ` Daniel Vetter
2018-10-03 11:36   ` Daniel Vetter
2018-10-03 12:30   ` Ville Syrjälä
2018-10-03 12:30     ` Ville Syrjälä
2018-10-03 12:30     ` Ville Syrjälä
2018-10-03 14:30     ` Eugeniy Paltsev
2018-10-03 14:30       ` Eugeniy Paltsev
2018-10-03 14:30       ` Eugeniy Paltsev
2018-10-03 15:29       ` Daniel Vetter
2018-10-03 15:29         ` Daniel Vetter
2018-10-03 15:29         ` Daniel Vetter
2018-10-03 15:51         ` Ville Syrjälä
2018-10-03 15:51           ` Ville Syrjälä
2018-10-03 15:51           ` Ville Syrjälä
2018-10-03 15:51           ` Ville Syrjälä

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.