Skip to content

Commit db2aa2c

Browse files
SravanKumar247opsiff
authored andcommitted
fbdev: Fix vmalloc out-of-bounds write in fast_imageblit
commit af0db3c1f898144846d4c172531a199bb3ca375d upstream. This issue triggers when a userspace program does an ioctl FBIOPUT_CON2FBMAP by passing console number and frame buffer number. Ideally this maps console to frame buffer and updates the screen if console is visible. As part of mapping it has to do resize of console according to frame buffer info. if this resize fails and returns from vc_do_resize() and continues further. At this point console and new frame buffer are mapped and sets display vars. Despite failure still it continue to proceed updating the screen at later stages where vc_data is related to previous frame buffer and frame buffer info and display vars are mapped to new frame buffer and eventully leading to out-of-bounds write in fast_imageblit(). This bheviour is excepted only when fg_console is equal to requested console which is a visible console and updates screen with invalid struct references in fbcon_putcs(). Reported-and-tested-by: syzbot+c4b7aa0513823e2ea880@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=c4b7aa0513823e2ea880 Signed-off-by: Sravan Kumar Gundu <sravankumarlpu@gmail.com> Cc: stable@vger.kernel.org Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit ed9b8e5016230868c8d813d9179523f729fec8c6)
1 parent d755b6c commit db2aa2c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/video/fbdev/core/fbcon.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,8 @@ static void con2fb_init_display(struct vc_data *vc, struct fb_info *info,
826826
fg_vc->vc_rows);
827827
}
828828

829-
update_screen(vc_cons[fg_console].d);
829+
if (fg_console != unit)
830+
update_screen(vc_cons[fg_console].d);
830831
}
831832

832833
/**
@@ -1363,6 +1364,7 @@ static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var,
13631364
struct vc_data *svc;
13641365
struct fbcon_ops *ops = info->fbcon_par;
13651366
int rows, cols;
1367+
unsigned long ret = 0;
13661368

13671369
p = &fb_display[unit];
13681370

@@ -1413,11 +1415,10 @@ static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var,
14131415
rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
14141416
cols /= vc->vc_font.width;
14151417
rows /= vc->vc_font.height;
1416-
vc_resize(vc, cols, rows);
1418+
ret = vc_resize(vc, cols, rows);
14171419

1418-
if (con_is_visible(vc)) {
1420+
if (con_is_visible(vc) && !ret)
14191421
update_screen(vc);
1420-
}
14211422
}
14221423

14231424
static __inline__ void ywrap_up(struct vc_data *vc, int count)

0 commit comments

Comments
 (0)