linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	syzbot <syzbot+b308f5fd049fbbc6e74f@syzkaller.appspotmail.com>,
	syzbot <syzbot+16469b5e8e5a72e9131e@syzkaller.appspotmail.com>,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Subject: [PATCH 5.9 10/15] vt_ioctl: make VT_RESIZEX behave like VT_RESIZE
Date: Fri, 16 Oct 2020 11:08:12 +0200	[thread overview]
Message-ID: <20201016090437.674530384@linuxfoundation.org> (raw)
In-Reply-To: <20201016090437.170032996@linuxfoundation.org>

From: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>

commit 988d0763361bb65690d60e2bc53a6b72777040c3 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>

---
 drivers/tty/vt/vt_ioctl.c |   57 ++++++++--------------------------------------
 1 file changed, 10 insertions(+), 47 deletions(-)

--- a/drivers/tty/vt/vt_ioctl.c
+++ b/drivers/tty/vt/vt_ioctl.c
@@ -773,58 +773,21 @@ static int vt_resizex(struct vc_data *vc
 	if (copy_from_user(&v, cs, sizeof(struct vt_consize)))
 		return -EFAULT;
 
-	/* FIXME: Should check the copies properly */
-	if (!v.v_vlin)
-		v.v_vlin = vc->vc_scan_lines;
-
-	if (v.v_clin) {
-		int rows = v.v_vlin / v.v_clin;
-		if (v.v_rows != rows) {
-			if (v.v_rows) /* Parameters don't add up */
-				return -EINVAL;
-			v.v_rows = rows;
-		}
-	}
-
-	if (v.v_vcol && v.v_ccol) {
-		int cols = v.v_vcol / v.v_ccol;
-		if (v.v_cols != cols) {
-			if (v.v_cols)
-				return -EINVAL;
-			v.v_cols = cols;
-		}
-	}
-
-	if (v.v_clin > 32)
-		return -EINVAL;
+	if (v.v_vlin)
+		pr_info_once("\"struct vt_consize\"->v_vlin is ignored. Please report if you need this.\n");
+	if (v.v_clin)
+		pr_info_once("\"struct vt_consize\"->v_clin is ignored. Please report if you need this.\n");
 
+	console_lock();
 	for (i = 0; i < MAX_NR_CONSOLES; i++) {
-		struct vc_data *vcp;
-
-		if (!vc_cons[i].d)
-			continue;
-		console_lock();
-		vcp = vc_cons[i].d;
-		if (vcp) {
-			int ret;
-			int save_scan_lines = vcp->vc_scan_lines;
-			int save_font_height = vcp->vc_font.height;
+		vc = vc_cons[i].d;
 
-			if (v.v_vlin)
-				vcp->vc_scan_lines = v.v_vlin;
-			if (v.v_clin)
-				vcp->vc_font.height = v.v_clin;
-			vcp->vc_resize_user = 1;
-			ret = vc_resize(vcp, v.v_cols, v.v_rows);
-			if (ret) {
-				vcp->vc_scan_lines = save_scan_lines;
-				vcp->vc_font.height = save_font_height;
-				console_unlock();
-				return ret;
-			}
+		if (vc) {
+			vc->vc_resize_user = 1;
+			vc_resize(vc, v.v_cols, v.v_rows);
 		}
-		console_unlock();
 	}
+	console_unlock();
 
 	return 0;
 }



  parent reply	other threads:[~2020-10-16  9:11 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-16  9:08 [PATCH 5.9 00/15] 5.9.1-rc1 review Greg Kroah-Hartman
2020-10-16  9:08 ` [PATCH 5.9 01/15] Bluetooth: A2MP: Fix not initializing all members Greg Kroah-Hartman
2020-10-16  9:08 ` [PATCH 5.9 02/15] Bluetooth: L2CAP: Fix calling sk_filter on non-socket based channel Greg Kroah-Hartman
2020-10-16  9:08 ` [PATCH 5.9 03/15] Bluetooth: MGMT: Fix not checking if BT_HS is enabled Greg Kroah-Hartman
2020-10-16  9:08 ` [PATCH 5.9 04/15] media: usbtv: Fix refcounting mixup Greg Kroah-Hartman
2020-10-16  9:08 ` [PATCH 5.9 05/15] USB: serial: option: add Cellient MPL200 card Greg Kroah-Hartman
2020-10-16  9:08 ` [PATCH 5.9 06/15] USB: serial: option: Add Telit FT980-KS composition Greg Kroah-Hartman
2020-10-16  9:08 ` [PATCH 5.9 07/15] staging: comedi: check validity of wMaxPacketSize of usb endpoints found Greg Kroah-Hartman
2020-10-16  9:08 ` [PATCH 5.9 08/15] USB: serial: pl2303: add device-id for HP GC device Greg Kroah-Hartman
2020-10-16  9:08 ` [PATCH 5.9 09/15] USB: serial: ftdi_sio: add support for FreeCalypso JTAG+UART adapters Greg Kroah-Hartman
2020-10-16  9:08 ` Greg Kroah-Hartman [this message]
2020-10-16  9:08 ` [PATCH 5.9 11/15] reiserfs: Initialize inode keys properly Greg Kroah-Hartman
2020-10-16  9:08 ` [PATCH 5.9 12/15] reiserfs: Fix oops during mount Greg Kroah-Hartman
2020-10-16  9:08 ` [PATCH 5.9 13/15] Revert "drm/amdgpu: Fix NULL dereference in dpm sysfs handlers" Greg Kroah-Hartman
2020-10-16  9:08 ` [PATCH 5.9 14/15] crypto: bcm - Verify GCM/CCM key length in setkey Greg Kroah-Hartman
2020-10-16  9:08 ` [PATCH 5.9 15/15] crypto: qat - check cipher length for aead AES-CBC-HMAC-SHA Greg Kroah-Hartman
2020-10-16 12:21 ` [PATCH 5.9 00/15] 5.9.1-rc1 review Jeffrin Jose T
2020-10-16 16:45 ` Jon Hunter
2020-10-17 11:34   ` Greg Kroah-Hartman
2020-10-16 19:03 ` Naresh Kamboju
2020-10-17 11:34   ` Greg Kroah-Hartman
2020-10-16 21:09 ` Guenter Roeck
2020-10-17 11:34   ` Greg Kroah-Hartman
2020-10-17 16:02 ` Shuah Khan
2020-10-18  6:00   ` Greg Kroah-Hartman
2020-10-19 17:02 ` [tip: perf/urgent] Linux 5.9.1 tip-bot2 for Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201016090437.674530384@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+16469b5e8e5a72e9131e@syzkaller.appspotmail.com \
    --cc=syzbot+b308f5fd049fbbc6e74f@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).