Skip to content

Commit f3af1b6

Browse files
Jiri Slabygregkh
authored andcommitted
tty: keyboard, do not speculate on func_table index
It is very unlikely for processor to speculate on the func_table index. The index is uchar and func_table is of size 256. So the compiler would need to screw up and generate a really bad code. But to stay on the safe side, forbid speculation on this user passed index. Signed-off-by: Jiri Slaby <[email protected]> Cc: Jiri Kosina <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7df5081 commit f3af1b6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/tty/vt/keyboard.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <linux/tty.h>
3333
#include <linux/tty_flip.h>
3434
#include <linux/mm.h>
35+
#include <linux/nospec.h>
3536
#include <linux/string.h>
3637
#include <linux/init.h>
3738
#include <linux/slab.h>
@@ -2019,7 +2020,7 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
20192020
goto reterr;
20202021
}
20212022
kbs->kb_string[sizeof(kbs->kb_string)-1] = '\0';
2022-
i = kbs->kb_func;
2023+
i = array_index_nospec(kbs->kb_func, MAX_NR_FUNC);
20232024

20242025
switch (cmd) {
20252026
case KDGKBSENT:

0 commit comments

Comments
 (0)