Thread (19 messages) 19 messages, 5 authors, 2022-08-05
STALE1444d

[PATCH] tty: vt: selection: Add check for valid tiocl_selection values

From: Helge Deller <deller@gmx.de>
Date: 2022-07-30 18:49:53
Also in: dri-devel, lkml
Subsystem: the rest, tty layer and serial drivers · Maintainers: Linus Torvalds, Greg Kroah-Hartman, Jiri Slaby

The line and column numbers for the selection need to start at 1.
Add the checks to prevent invalid input.

Signed-off-by: Helge Deller <deller@gmx.de>
Reported-by: syzbot+14b0e8f3fd1612e35350@syzkaller.appspotmail.com
diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
index f7755e73696e..58692a9b4097 100644
--- a/drivers/tty/vt/selection.c
+++ b/drivers/tty/vt/selection.c
@@ -326,6 +326,9 @@ static int vc_selection(struct vc_data *vc, struct tiocl_selection *v,
 		return 0;
 	}

+	if (!v->xs || !v->ys || !v->xe || !v->ye)
+		return -EINVAL;
+
 	v->xs = min_t(u16, v->xs - 1, vc->vc_cols - 1);
 	v->ys = min_t(u16, v->ys - 1, vc->vc_rows - 1);
 	v->xe = min_t(u16, v->xe - 1, vc->vc_cols - 1);
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help