dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] drm/fb-helper: add virtual screen size check to drm_fb_helper_check_var()
@ 2022-08-11 14:48 Andrey Strachuk
  2022-08-11 14:54 ` Geert Uytterhoeven
  0 siblings, 1 reply; 5+ messages in thread
From: Andrey Strachuk @ 2022-08-11 14:48 UTC (permalink / raw)
  To: Maarten Lankhorst
  Cc: ldv-project, Andrey Strachuk, Thomas Zimmermann, David Airlie,
	Helge Deller, linux-kernel, Geert Uytterhoeven, dri-devel

Add virtual screen size check to drm_fb_helper_check_var() in
order to validate userspace input.

Found by Linux Verification Center (linuxtesting.org) with syzkaller.

Signed-off-by: Andrey Strachuk <strochuk@ispras.ru>
Fixes: 785b93ef8c30 ("drm/kms: move driver specific fb common code to helper functions (v2)")
---
 drivers/gpu/drm/drm_fb_helper.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 2d4cee6a10ff..5c8b211769eb 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1355,6 +1355,12 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
 	    (drm_format_info_block_height(fb->format, 0) > 1))
 		return -EINVAL;
 
+	/* verify that virtual resolution >= physical resolution */
+	if (var->xres_virtual < var->xres)
+		var->xres_virtual = var->xres;
+	if (var->yres_virtual < var->yres)
+		var->yres_virtual = var->yres;
+
 	/*
 	 * Changes struct fb_var_screeninfo are currently not pushed back
 	 * to KMS, hence fail if different settings are requested.
-- 
2.25.1


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

end of thread, other threads:[~2022-09-07 17:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-11 14:48 [PATCH v2] drm/fb-helper: add virtual screen size check to drm_fb_helper_check_var() Andrey Strachuk
2022-08-11 14:54 ` Geert Uytterhoeven
2022-08-11 20:59   ` [ldv-project] " Alexey Khoroshilov
2022-09-06 19:54     ` Daniel Vetter
2022-09-07 17:20       ` Alexey Khoroshilov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).