vgacon: Prevent faulty bootparams.screeninfo from causing harm
authorJan H. Schönherr <jschoenh@amazon.de>
Mon, 4 Sep 2017 14:00:50 +0000 (16:00 +0200)
committerBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Mon, 4 Sep 2017 14:00:50 +0000 (16:00 +0200)
If a zero for the number of colums or rows manages to slip through,
gotoxy() will underflow vc->vc_pos, causing the next action on the
referenced memory to end with a page fault.

Make the check in vgacon_startup() more pessimistic to prevent that.

Signed-off-by: Jan H. Schönherr <jschoenh@amazon.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
drivers/video/console/vgacon.c

index dc06cb6a15dc094b4d107c843320f6e97c4e0103..445b1dc5d441a1863ce64cf3807f03d77ae662c7 100644 (file)
@@ -398,9 +398,8 @@ static const char *vgacon_startup(void)
 #endif
        }
 
-       /* boot_params.screen_info initialized? */
-       if ((screen_info.orig_video_mode  == 0) &&
-           (screen_info.orig_video_lines == 0) &&
+       /* boot_params.screen_info reasonably initialized? */
+       if ((screen_info.orig_video_lines == 0) ||
            (screen_info.orig_video_cols  == 0))
                goto no_vga;