From: Linus Torvalds
stable inclusion
from linux-4.19.206
commit 0776c1a20babb4ad0b7ce7f2f4e0806a97663187
category: bugfix
issue: #I4CC82
CVE: CVE-2021-3753
--------------------------------
commit 2287a51ba822384834dafc1c798453375d1107c7 upstream.
As per the long-suffering comment.
Reported-by: Minh Yuan
Cc: Greg Kroah-Hartman
Cc: Jiri Slaby
Signed-off-by: Linus Torvalds
Signed-off-by: Greg Kroah-Hartman
Signed-off-by: Yang Yingliang
Reviewed-by: Xiu Jianfeng
Signed-off-by: Yang Yingliang
Signed-off-by: Yu Changchun
---
drivers/tty/vt/vt_ioctl.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c
index 2e959563af53..13675008d1c7 100644
--- a/drivers/tty/vt/vt_ioctl.c
+++ b/drivers/tty/vt/vt_ioctl.c
@@ -484,16 +484,19 @@ int vt_ioctl(struct tty_struct *tty,
ret = -EINVAL;
goto out;
}
- /* FIXME: this needs the console lock extending */
- if (vc->vc_mode == (unsigned char) arg)
+ console_lock();
+ if (vc->vc_mode == (unsigned char) arg) {
+ console_unlock();
break;
+ }
vc->vc_mode = (unsigned char) arg;
- if (console != fg_console)
+ if (console != fg_console) {
+ console_unlock();
break;
+ }
/*
* explicitly blank/unblank the screen if switching modes
*/
- console_lock();
if (arg == KD_TEXT)
do_unblank_screen(1);
else
--
2.22.0