Re: Bug report - slab-out-of-bounds in vcs_scr_readw

From: Nicolas Pitre
Date: Tue Nov 05 2019 - 04:33:23 EST


On Tue, 5 Nov 2019, Jiri Slaby wrote:

> Because unicode uses 4 bytes. The issue is that there is no handling for
> unicode in vcs_write at all. (Compare with vcs_read.)

Exact.

----- >8

Subject: [PATCH] vcs: prevent write access to vcsu devices

Commit d21b0be246bf ("vt: introduce unicode mode for /dev/vcs") guarded
against using devices containing attributes as this is not yet
implemented. It however failed to guard against writes to any devices
as this is also unimplemented.

Signed-off-by: Nicolas Pitre <npitre@xxxxxxxxxxxx>
Cc: <stable@xxxxxxxxxxxxxxx> # v4.19+

diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c
index fa07d79027..ef19b95b73 100644
--- a/drivers/tty/vt/vc_screen.c
+++ b/drivers/tty/vt/vc_screen.c
@@ -456,6 +456,9 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
size_t ret;
char *con_buf;

+ if (use_unicode(inode))
+ return -EOPNOTSUPP;
+
con_buf = (char *) __get_free_page(GFP_KERNEL);
if (!con_buf)
return -ENOMEM;