]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.45/tty-vt.c-fix-tiocl_blankscreen-console-blanking-if-blankinterval-0.patch
Linux 4.14.121
[thirdparty/kernel/stable-queue.git] / releases / 4.19.45 / tty-vt.c-fix-tiocl_blankscreen-console-blanking-if-blankinterval-0.patch
1 From 75ddbc1fb11efac87b611d48e9802f6fe2bb2163 Mon Sep 17 00:00:00 2001
2 From: Yifeng Li <tomli@tomli.me>
3 Date: Tue, 5 Mar 2019 07:02:49 +0800
4 Subject: tty: vt.c: Fix TIOCL_BLANKSCREEN console blanking if blankinterval == 0
5
6 From: Yifeng Li <tomli@tomli.me>
7
8 commit 75ddbc1fb11efac87b611d48e9802f6fe2bb2163 upstream.
9
10 Previously, in the userspace, it was possible to use the "setterm" command
11 from util-linux to blank the VT console by default, using the following
12 command.
13
14 According to the man page,
15
16 > The force option keeps the screen blank even if a key is pressed.
17
18 It was implemented by calling TIOCL_BLANKSCREEN.
19
20 case BLANKSCREEN:
21 ioctlarg = TIOCL_BLANKSCREEN;
22 if (ioctl(STDIN_FILENO, TIOCLINUX, &ioctlarg))
23 warn(_("cannot force blank"));
24 break;
25
26 However, after Linux 4.12, this command ceased to work anymore, which is
27 unexpected. By inspecting the kernel source, it shows that the issue was
28 triggered by the side-effect from commit a4199f5eb809 ("tty: Disable
29 default console blanking interval").
30
31 The console blanking is implemented by function do_blank_screen() in vt.c:
32 "blank_state" will be initialized to "blank_normal_wait" in con_init() if
33 AND ONLY IF ("blankinterval" > 0). If "blankinterval" is 0, "blank_state"
34 will be "blank_off" (== 0), and a call to do_blank_screen() will always
35 abort, even if a forced blanking is required from the user by calling
36 TIOCL_BLANKSCREEN, the console won't be blanked.
37
38 This behavior is unexpected from a user's point-of-view, since it's not
39 mentioned in any documentation. The setterm man page suggests it will
40 always work, and the kernel comments in uapi/linux/tiocl.h says
41
42 > /* keep screen blank even if a key is pressed */
43 > #define TIOCL_BLANKSCREEN 14
44
45 To fix it, we simply remove the "blank_state != blank_off" check, as
46 pointed out by Nicolas Pitre, this check doesn't logically make sense
47 and it's safe to remove.
48
49 Suggested-by: Nicolas Pitre <nicolas.pitre@linaro.org>
50 Fixes: a4199f5eb809 ("tty: Disable default console blanking interval")
51 Signed-off-by: Yifeng Li <tomli@tomli.me>
52 Cc: stable <stable@vger.kernel.org>
53 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
54
55 ---
56 drivers/tty/vt/vt.c | 2 --
57 1 file changed, 2 deletions(-)
58
59 --- a/drivers/tty/vt/vt.c
60 +++ b/drivers/tty/vt/vt.c
61 @@ -4155,8 +4155,6 @@ void do_blank_screen(int entering_gfx)
62 return;
63 }
64
65 - if (blank_state != blank_normal_wait)
66 - return;
67 blank_state = blank_off;
68
69 /* don't blank graphics */