diff mbox

vgacon: Prevent faulty bootparams.screeninfo from causing harm

Message ID 1503858209-14909-1-git-send-email-jschoenh@amazon.de (mailing list archive)
State New, archived
Headers show

Commit Message

Jan H. Schönherr Aug. 27, 2017, 6:23 p.m. UTC
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>
---
 drivers/video/console/vgacon.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Bartlomiej Zolnierkiewicz Sept. 4, 2017, 1:30 p.m. UTC | #1
On Sunday, August 27, 2017 08:23:29 PM Jan H. Schönherr wrote:
> 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>

Patch queued for 4.14, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index dc06cb6..445b1dc 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -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;