]> git.itanic.dy.fi Git - linux-stable/commitdiff
tty: vt: initialize unicode screen buffer
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Tue, 19 Jul 2022 05:49:39 +0000 (14:49 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Jul 2022 12:18:27 +0000 (14:18 +0200)
syzbot reports kernel infoleak at vcs_read() [1], for buffer can be read
immediately after resize operation. Initialize buffer using kzalloc().

  ----------
  #include <fcntl.h>
  #include <unistd.h>
  #include <sys/ioctl.h>
  #include <linux/fb.h>

  int main(int argc, char *argv[])
  {
    struct fb_var_screeninfo var = { };
    const int fb_fd = open("/dev/fb0", 3);
    ioctl(fb_fd, FBIOGET_VSCREENINFO, &var);
    var.yres = 0x21;
    ioctl(fb_fd, FBIOPUT_VSCREENINFO, &var);
    return read(open("/dev/vcsu", O_RDONLY), &var, sizeof(var)) == -1;
  }
  ----------

Link: https://syzkaller.appspot.com/bug?extid=31a641689d43387f05d3
Cc: stable <stable@vger.kernel.org>
Reported-by: syzbot <syzbot+31a641689d43387f05d3@syzkaller.appspotmail.com>
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Link: https://lore.kernel.org/r/4ef053cf-e796-fb5e-58b7-3ae58242a4ad@I-love.SAKURA.ne.jp
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/vt/vt.c

index 1899b8a5d73ee7fb2a2ed2a68a6db44f5527671f..cc8b9a3e58f1e6f13346ca8ed145cccda1bc7ae5 100644 (file)
@@ -344,7 +344,7 @@ static struct uni_screen *vc_uniscr_alloc(unsigned int cols, unsigned int rows)
        /* allocate everything in one go */
        memsize = cols * rows * sizeof(char32_t);
        memsize += rows * sizeof(char32_t *);
-       p = vmalloc(memsize);
+       p = vzalloc(memsize);
        if (!p)
                return NULL;