Commit 63c5b11
committed
vt: keyboard: avoid signed integer overflow in k_ascii
jira VULN-7723
cve CVE-2020-13974
commit-author Dmitry Torokhov <dmitry.torokhov@gmail.com>
commit b86dab0
When k_ascii is invoked several times in a row there is a potential for
signed integer overflow:
UBSAN: Undefined behaviour in drivers/tty/vt/keyboard.c:888:19 signed integer overflow:
10 * 1111111111 cannot be represented in type 'int'
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.6.11 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
<IRQ>
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0xce/0x128 lib/dump_stack.c:118
ubsan_epilogue+0xe/0x30 lib/ubsan.c:154
handle_overflow+0xdc/0xf0 lib/ubsan.c:184
__ubsan_handle_mul_overflow+0x2a/0x40 lib/ubsan.c:205
k_ascii+0xbf/0xd0 drivers/tty/vt/keyboard.c:888
kbd_keycode drivers/tty/vt/keyboard.c:1477 [inline]
kbd_event+0x888/0x3be0 drivers/tty/vt/keyboard.c:1495
While it can be worked around by using check_mul_overflow()/
check_add_overflow(), it is better to introduce a separate flag to
signal that number pad is being used to compose a symbol, and
change type of the accumulator from signed to unsigned, thus
avoiding undefined behavior when it overflows.
Reported-by: Kyungtae Kim <kt0755@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200525232740.GA262061@dtor-ws
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit b86dab0)
Signed-off-by: Pratham Patel <ppatel@ciq.com>1 parent c3ea26a commit 63c5b11
1 file changed
+16
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
130 | 134 | | |
131 | 135 | | |
132 | 136 | | |
| |||
839 | 843 | | |
840 | 844 | | |
841 | 845 | | |
842 | | - | |
| 846 | + | |
843 | 847 | | |
844 | | - | |
| 848 | + | |
845 | 849 | | |
846 | | - | |
847 | | - | |
| 850 | + | |
| 851 | + | |
848 | 852 | | |
849 | 853 | | |
850 | 854 | | |
| |||
862 | 866 | | |
863 | 867 | | |
864 | 868 | | |
865 | | - | |
| 869 | + | |
866 | 870 | | |
867 | 871 | | |
868 | 872 | | |
| |||
876 | 880 | | |
877 | 881 | | |
878 | 882 | | |
879 | | - | |
880 | | - | |
881 | | - | |
882 | | - | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
883 | 889 | | |
884 | 890 | | |
885 | 891 | | |
| |||
0 commit comments