From: Nicolas Pitre <nicolas.pitre@linaro.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Dave Mielke <Dave@mielke.cc>, linux-kernel@vger.kernel.org
Subject: [PATCH 4/6] vcsa: clamp header values when they don't fit
Date: Tue, 8 Jan 2019 22:55:02 -0500 [thread overview]
Message-ID: <20190109035504.8413-5-nicolas.pitre@linaro.org> (raw)
In-Reply-To: <20190109035504.8413-1-nicolas.pitre@linaro.org>
The /dev/vcsa* devices have a fixed char-sized header that stores the
screen geometry and cursor location. Let's make sure it doesn't contain
random garbage when those values exceed 255. If ever it becomes necessary
to convey larger screen info to user space then a larger header in the
not-yet-implemented /dev/vcsua* devices should be considered.
Signed-off-by: Nicolas Pitre <nico@linaro.org>
---
drivers/tty/vt/vc_screen.c | 5 +++--
drivers/tty/vt/vt.c | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c
index 2384ea85ff..3dba60825c 100644
--- a/drivers/tty/vt/vc_screen.c
+++ b/drivers/tty/vt/vc_screen.c
@@ -335,8 +335,9 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
if (p < HEADER_SIZE) {
size_t tmp_count;
- con_buf0[0] = (char)vc->vc_rows;
- con_buf0[1] = (char)vc->vc_cols;
+ /* clamp header values if they don't fit */
+ con_buf0[0] = min(vc->vc_rows, 0xFFu);
+ con_buf0[1] = min(vc->vc_cols, 0xFFu);
getconsxy(vc, con_buf0 + 2);
con_buf_start += p;
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index bba75560d1..f519c22e70 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -4591,8 +4591,9 @@ EXPORT_SYMBOL_GPL(screen_pos);
void getconsxy(struct vc_data *vc, unsigned char *p)
{
- p[0] = vc->vc_x;
- p[1] = vc->vc_y;
+ /* clamp values if they don't fit */
+ p[0] = min(vc->vc_x, 0xFFu);
+ p[1] = min(vc->vc_y, 0xFFu);
}
void putconsxy(struct vc_data *vc, unsigned char *p)
--
2.20.1
next prev parent reply other threads:[~2019-01-09 3:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-09 3:54 [PATCH 0/6] assorted console/vt/vcs fixes Nicolas Pitre
2019-01-09 3:54 ` [PATCH 1/6] vt: make vt_console_print() compatible with the unicode screen buffer Nicolas Pitre
2019-01-09 3:55 ` [PATCH 2/6] vt: always call notifier with the console lock held Nicolas Pitre
2019-01-09 3:55 ` [PATCH 3/6] vt: invoke notifier on screen size change Nicolas Pitre
2019-01-09 3:55 ` Nicolas Pitre [this message]
2019-01-09 3:55 ` [PATCH 5/6] vcs: poll(): cope with a deallocated vt Nicolas Pitre
2019-01-10 0:13 ` Nicolas Pitre
2019-01-09 3:55 ` [PATCH 6/6] vcs: fasync(): make it consistent with poll() Nicolas Pitre
2019-01-18 12:49 ` [PATCH 0/6] assorted console/vt/vcs fixes 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=20190109035504.8413-5-nicolas.pitre@linaro.org \
--to=nicolas.pitre@linaro.org \
--cc=Dave@mielke.cc \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®