[PATCH 4/5] fbmem: Prevent invalid virtual screen sizes in fb_set_var()
Helge Deller
deller at gmx.de
Wed Jun 29 20:00:23 UTC 2022
Prevent that drivers configure a virtual screen resolution smaller than
the physical screen resolution. This is important, because otherwise we
may access memory outside of the graphics memory area.
Signed-off-by: Helge Deller <deller at gmx.de>
Cc: stable at vger.kernel.org # v5.4+
---
drivers/video/fbdev/core/fbmem.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 324f726739c4..222d94e2e0a2 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -1006,6 +1006,12 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
if (var->xres < 8 || var->yres < 8)
return -EINVAL;
+ /* make sure virtual resolution >= physical resolution */
+ if (WARN_ON(var->xres_virtual < var->xres))
+ var->xres_virtual = var->xres;
+ if (WARN_ON(var->yres_virtual < var->yres))
+ var->yres_virtual = var->yres;
+
/* Too huge resolution causes multiplication overflow. */
if (check_mul_overflow(var->xres, var->yres, &unused) ||
check_mul_overflow(var->xres_virtual, var->yres_virtual, &unused))
--
2.35.3
More information about the dri-devel
mailing list