Skip to content

Commit 6d389a6

Browse files
Tetsuo Handagregkh
authored andcommitted
vt_ioctl: make VT_RESIZEX behave like VT_RESIZE
commit 988d076 upstream. syzbot is reporting UAF/OOB read at bit_putcs()/soft_cursor() [1][2], for vt_resizex() from ioctl(VT_RESIZEX) allows setting font height larger than actual font height calculated by con_font_set() from ioctl(PIO_FONT). Since fbcon_set_font() from con_font_set() allocates minimal amount of memory based on actual font height calculated by con_font_set(), use of vt_resizex() can cause UAF/OOB read for font data. VT_RESIZEX was introduced in Linux 1.3.3, but it is unclear that what comes to the "+ more" part, and I couldn't find a user of VT_RESIZEX. #define VT_RESIZE 0x5609 /* set kernel's idea of screensize */ #define VT_RESIZEX 0x560A /* set kernel's idea of screensize + more */ So far we are not aware of syzbot reports caused by setting non-zero value to v_vlin parameter. But given that it is possible that nobody is using VT_RESIZEX, we can try removing support for v_clin and v_vlin parameters. Therefore, this patch effectively makes VT_RESIZEX behave like VT_RESIZE, with emitting a message if somebody is still using v_clin and/or v_vlin parameters. [1] https://syzkaller.appspot.com/bug?id=32577e96d88447ded2d3b76d71254fb855245837 [2] https://syzkaller.appspot.com/bug?id=6b8355d27b2b94fb5cedf4655e3a59162d9e48e3 Reported-by: syzbot <syzbot+b308f5fd049fbbc6e74f@syzkaller.appspotmail.com> Reported-by: syzbot <syzbot+16469b5e8e5a72e9131e@syzkaller.appspotmail.com> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: stable <stable@vger.kernel.org> Link: https://lore.kernel.org/r/4933b81b-9b1a-355b-df0e-9b31e8280ab9@i-love.sakura.ne.jp Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a71ec88 commit 6d389a6

1 file changed

Lines changed: 10 additions & 47 deletions

File tree

drivers/tty/vt/vt_ioctl.c

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -773,58 +773,21 @@ static int vt_resizex(struct vc_data *vc, struct vt_consize __user *cs)
773773
if (copy_from_user(&v, cs, sizeof(struct vt_consize)))
774774
return -EFAULT;
775775

776-
/* FIXME: Should check the copies properly */
777-
if (!v.v_vlin)
778-
v.v_vlin = vc->vc_scan_lines;
779-
780-
if (v.v_clin) {
781-
int rows = v.v_vlin / v.v_clin;
782-
if (v.v_rows != rows) {
783-
if (v.v_rows) /* Parameters don't add up */
784-
return -EINVAL;
785-
v.v_rows = rows;
786-
}
787-
}
788-
789-
if (v.v_vcol && v.v_ccol) {
790-
int cols = v.v_vcol / v.v_ccol;
791-
if (v.v_cols != cols) {
792-
if (v.v_cols)
793-
return -EINVAL;
794-
v.v_cols = cols;
795-
}
796-
}
797-
798-
if (v.v_clin > 32)
799-
return -EINVAL;
776+
if (v.v_vlin)
777+
pr_info_once("\"struct vt_consize\"->v_vlin is ignored. Please report if you need this.\n");
778+
if (v.v_clin)
779+
pr_info_once("\"struct vt_consize\"->v_clin is ignored. Please report if you need this.\n");
800780

781+
console_lock();
801782
for (i = 0; i < MAX_NR_CONSOLES; i++) {
802-
struct vc_data *vcp;
783+
vc = vc_cons[i].d;
803784

804-
if (!vc_cons[i].d)
805-
continue;
806-
console_lock();
807-
vcp = vc_cons[i].d;
808-
if (vcp) {
809-
int ret;
810-
int save_scan_lines = vcp->vc_scan_lines;
811-
int save_font_height = vcp->vc_font.height;
812-
813-
if (v.v_vlin)
814-
vcp->vc_scan_lines = v.v_vlin;
815-
if (v.v_clin)
816-
vcp->vc_font.height = v.v_clin;
817-
vcp->vc_resize_user = 1;
818-
ret = vc_resize(vcp, v.v_cols, v.v_rows);
819-
if (ret) {
820-
vcp->vc_scan_lines = save_scan_lines;
821-
vcp->vc_font.height = save_font_height;
822-
console_unlock();
823-
return ret;
824-
}
785+
if (vc) {
786+
vc->vc_resize_user = 1;
787+
vc_resize(vc, v.v_cols, v.v_rows);
825788
}
826-
console_unlock();
827789
}
790+
console_unlock();
828791

829792
return 0;
830793
}

0 commit comments

Comments
 (0)