[vz7,v2,2/4] tty: limit terminal size to 4M chars

Submitted by Oleg Babin on May 8, 2018, 7:05 p.m.

Details

Message ID 1525806318-605691-3-git-send-email-obabin@virtuozzo.com
State New
Series "avoid kmalloc for high order memory allocations"
Headers show

Commit Message

Oleg Babin May 8, 2018, 7:05 p.m.
From: Dmitry Vyukov <dvyukov@google.com>

Size of kmalloc() in vc_do_resize() is controlled by user.
Too large kmalloc() size triggers WARNING message on console.
Put a reasonable upper bound on terminal size to prevent WARNINGs.

Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
CC: David Rientjes <rientjes@google.com>
Cc: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Peter Hurley <peter@hurleysoftware.com>
Cc: linux-kernel@vger.kernel.org
Cc: syzkaller@googlegroups.com
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ms commit 32b2921e6a7461fe63b71217067a6cf4bddb132f
Signed-off-by: Oleg Babin <obabin@virtuozzo.com>
---
 drivers/tty/vt/vt.c | 2 ++
 1 file changed, 2 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index fbc6290..b49abe5 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -871,6 +871,8 @@  static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
 	if (new_cols == vc->vc_cols && new_rows == vc->vc_rows)
 		return 0;
 
+	if (new_screen_size > (4 << 20))
+		return -EINVAL;
 	newscreen = kmalloc(new_screen_size, GFP_USER);
 	if (!newscreen)
 		return -ENOMEM;