vt: Clear selection before changing the font
commit 566f9c9f89337792070b5a6062dff448b3e7977f upstream. 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>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
7fd8d33adb
commit
989201bb8c
@@ -4671,9 +4671,11 @@ static int con_font_set(struct vc_data *vc, struct console_font_op *op)
|
|||||||
console_lock();
|
console_lock();
|
||||||
if (vc->vc_mode != KD_TEXT)
|
if (vc->vc_mode != KD_TEXT)
|
||||||
rc = -EINVAL;
|
rc = -EINVAL;
|
||||||
else if (vc->vc_sw->con_font_set)
|
else if (vc->vc_sw->con_font_set) {
|
||||||
|
if (vc_is_sel(vc))
|
||||||
|
clear_selection();
|
||||||
rc = vc->vc_sw->con_font_set(vc, &font, op->flags);
|
rc = vc->vc_sw->con_font_set(vc, &font, op->flags);
|
||||||
else
|
} else
|
||||||
rc = -ENOSYS;
|
rc = -ENOSYS;
|
||||||
console_unlock();
|
console_unlock();
|
||||||
kfree(font.data);
|
kfree(font.data);
|
||||||
@@ -4700,9 +4702,11 @@ static int con_font_default(struct vc_data *vc, struct console_font_op *op)
|
|||||||
console_unlock();
|
console_unlock();
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (vc->vc_sw->con_font_default)
|
if (vc->vc_sw->con_font_default) {
|
||||||
|
if (vc_is_sel(vc))
|
||||||
|
clear_selection();
|
||||||
rc = vc->vc_sw->con_font_default(vc, &font, s);
|
rc = vc->vc_sw->con_font_default(vc, &font, s);
|
||||||
else
|
} else
|
||||||
rc = -ENOSYS;
|
rc = -ENOSYS;
|
||||||
console_unlock();
|
console_unlock();
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
|
Reference in New Issue
Block a user