提交 2f2657e3 编写于 作者: T Tetsuo Handa 提交者: Yang Yingliang

tty: vt: always invoke vc->vc_sw->con_resize callback

stable inclusion
from linux-4.19.192
commit 17d6c58c5fc522561daa4d3fb270edba933ac0a6

--------------------------------

commit ffb324e6 upstream.

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: Nsyzbot <syzbot+1f29e126cf461c4de3b3@syzkaller.appspotmail.com>
Suggested-by: NLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: NTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Tested-by: Nsyzbot <syzbot+1f29e126cf461c4de3b3@syzkaller.appspotmail.com>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 cb173fc2
...@@ -1169,7 +1169,7 @@ static inline int resize_screen(struct vc_data *vc, int width, int height, ...@@ -1169,7 +1169,7 @@ static inline int resize_screen(struct vc_data *vc, int width, int height,
/* Resizes the resolution of the display adapater */ /* Resizes the resolution of the display adapater */
int err = 0; int err = 0;
if (vc->vc_mode != KD_GRAPHICS && vc->vc_sw->con_resize) if (vc->vc_sw->con_resize)
err = vc->vc_sw->con_resize(vc, width, height, user); err = vc->vc_sw->con_resize(vc, width, height, user);
return err; return err;
......
...@@ -1998,7 +1998,7 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width, ...@@ -1998,7 +1998,7 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width,
return -EINVAL; return -EINVAL;
DPRINTK("resize now %ix%i\n", var.xres, var.yres); DPRINTK("resize now %ix%i\n", var.xres, var.yres);
if (con_is_visible(vc)) { if (con_is_visible(vc) && vc->vc_mode == KD_TEXT) {
var.activate = FB_ACTIVATE_NOW | var.activate = FB_ACTIVATE_NOW |
FB_ACTIVATE_FORCE; FB_ACTIVATE_FORCE;
fb_set_var(info, &var); fb_set_var(info, &var);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册