Skip to content

Commit 8c28051

Browse files
Tetsuo Handadanvet
authored andcommitted
fbmem: don't allow too huge resolutions
syzbot is reporting page fault at vga16fb_fillrect() [1], for vga16fb_check_var() is failing to detect multiplication overflow. if (vxres * vyres > maxmem) { vyres = maxmem / vxres; if (vyres < yres) return -ENOMEM; } Since no module would accept too huge resolutions where multiplication overflow happens, let's reject in the common path. Link: https://syzkaller.appspot.com/bug?extid=04168c8063cfdde1db5e [1] Reported-by: syzbot <[email protected]> Debugged-by: Randy Dunlap <[email protected]> Signed-off-by: Tetsuo Handa <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Cc: [email protected] Signed-off-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 87fd9ef commit 8c28051

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/video/fbdev/core/fbmem.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,7 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
962962
struct fb_var_screeninfo old_var;
963963
struct fb_videomode mode;
964964
struct fb_event event;
965+
u32 unused;
965966

966967
if (var->activate & FB_ACTIVATE_INV_MODE) {
967968
struct fb_videomode mode1, mode2;
@@ -1008,6 +1009,11 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
10081009
if (var->xres < 8 || var->yres < 8)
10091010
return -EINVAL;
10101011

1012+
/* Too huge resolution causes multiplication overflow. */
1013+
if (check_mul_overflow(var->xres, var->yres, &unused) ||
1014+
check_mul_overflow(var->xres_virtual, var->yres_virtual, &unused))
1015+
return -EINVAL;
1016+
10111017
ret = info->fbops->fb_check_var(var, info);
10121018

10131019
if (ret)

0 commit comments

Comments
 (0)