Skip to content

Commit 566f9c9

Browse files
hdellergregkh
authored andcommitted
vt: Clear selection before changing the font
When changing the console font with ioctl(KDFONTOP) the new font size can be bigger than the previous font. A previous selection may thus now be outside of the new screen size and thus trigger out-of-bounds accesses to graphics memory if the selection is removed in vc_do_resize(). Prevent such out-of-memory accesses by dropping the selection before the various con_font_set() console handlers are called. Reported-by: syzbot+14b0e8f3fd1612e35350@syzkaller.appspotmail.com Cc: stable <stable@kernel.org> Tested-by: Khalid Masum <khalid.masum.92@gmail.com> Signed-off-by: Helge Deller <deller@gmx.de> Link: https://lore.kernel.org/r/YuV9apZGNmGfjcor@p100 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b5a5b9d commit 566f9c9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/tty/vt/vt.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4662,9 +4662,11 @@ static int con_font_set(struct vc_data *vc, struct console_font_op *op)
46624662
console_lock();
46634663
if (vc->vc_mode != KD_TEXT)
46644664
rc = -EINVAL;
4665-
else if (vc->vc_sw->con_font_set)
4665+
else if (vc->vc_sw->con_font_set) {
4666+
if (vc_is_sel(vc))
4667+
clear_selection();
46664668
rc = vc->vc_sw->con_font_set(vc, &font, op->flags);
4667-
else
4669+
} else
46684670
rc = -ENOSYS;
46694671
console_unlock();
46704672
kfree(font.data);
@@ -4691,9 +4693,11 @@ static int con_font_default(struct vc_data *vc, struct console_font_op *op)
46914693
console_unlock();
46924694
return -EINVAL;
46934695
}
4694-
if (vc->vc_sw->con_font_default)
4696+
if (vc->vc_sw->con_font_default) {
4697+
if (vc_is_sel(vc))
4698+
clear_selection();
46954699
rc = vc->vc_sw->con_font_default(vc, &font, s);
4696-
else
4700+
} else
46974701
rc = -ENOSYS;
46984702
console_unlock();
46994703
if (!rc) {

0 commit comments

Comments
 (0)