Skip to content

Commit ffb324e

Browse files
Tetsuo Handatorvalds
authored andcommitted
tty: vt: always invoke vc->vc_sw->con_resize callback
syzbot is reporting OOB write at vga16fb_imageblit() [1], for resize_screen() from ioctl(VT_RESIZE) returns 0 without checking whether requested rows/columns fit the amount of memory reserved for the graphical screen if current mode is KD_GRAPHICS. ---------- #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/ioctl.h> #include <linux/kd.h> #include <linux/vt.h> int main(int argc, char *argv[]) { const int fd = open("/dev/char/4:1", O_RDWR); struct vt_sizes vt = { 0x4100, 2 }; ioctl(fd, KDSETMODE, KD_GRAPHICS); ioctl(fd, VT_RESIZE, &vt); ioctl(fd, KDSETMODE, KD_TEXT); return 0; } ---------- Allow framebuffer drivers to return -EINVAL, by moving vc->vc_mode != KD_GRAPHICS check from resize_screen() to fbcon_resize(). Link: https://syzkaller.appspot.com/bug?extid=1f29e126cf461c4de3b3 [1] Reported-by: syzbot <[email protected]> Suggested-by: Linus Torvalds <[email protected]> Signed-off-by: Tetsuo Handa <[email protected]> Tested-by: syzbot <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 25a1298 commit ffb324e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

drivers/tty/vt/vt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ static inline int resize_screen(struct vc_data *vc, int width, int height,
11711171
/* Resizes the resolution of the display adapater */
11721172
int err = 0;
11731173

1174-
if (vc->vc_mode != KD_GRAPHICS && vc->vc_sw->con_resize)
1174+
if (vc->vc_sw->con_resize)
11751175
err = vc->vc_sw->con_resize(vc, width, height, user);
11761176

11771177
return err;

drivers/video/fbdev/core/fbcon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2019,7 +2019,7 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width,
20192019
return -EINVAL;
20202020

20212021
pr_debug("resize now %ix%i\n", var.xres, var.yres);
2022-
if (con_is_visible(vc)) {
2022+
if (con_is_visible(vc) && vc->vc_mode == KD_TEXT) {
20232023
var.activate = FB_ACTIVATE_NOW |
20242024
FB_ACTIVATE_FORCE;
20252025
fb_set_var(info, &var);

0 commit comments

Comments
 (0)