vt_kdsetmode: extend console locking
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 30 Aug 2021 15:55:18 +0000 (08:55 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Sep 2021 07:44:40 +0000 (09:44 +0200)
commit 2287a51ba822384834dafc1c798453375d1107c7 upstream.

As per the long-suffering comment.

Reported-by: Minh Yuan <yuanmingbuaa@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/vt/vt_ioctl.c

index 9206fd24893539ead17a0ab1770d7b2e86a321b0..e1c1627a3356b3265df8fbd02c9c9aea11a7a903 100644 (file)
@@ -487,16 +487,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