public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tty: vt: add a bounds checking in vt_do_kdgkb_ioctl()
@ 2022-09-08  7:54 Hangyu Hua
  2022-09-08  8:10 ` Jiri Slaby
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Hangyu Hua @ 2022-09-08  7:54 UTC (permalink / raw)
  To: gregkh, jirislaby, changlianzhi, dmitry.torokhov; +Cc: linux-kernel, Hangyu Hua

As array_index_nospec's comments indicate,a bounds checking need to add
before calling array_index_nospec.

Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
---
 drivers/tty/vt/keyboard.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index be8313cdbac3..b9845455df79 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -2067,6 +2067,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
 	if (get_user(kb_func, &user_kdgkb->kb_func))
 		return -EFAULT;
 
+	if (kb_func >= MAX_NR_FUNC)
+		return -EFAULT;
+
 	kb_func = array_index_nospec(kb_func, MAX_NR_FUNC);
 
 	switch (cmd) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-09-12 11:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-08  7:54 [PATCH] tty: vt: add a bounds checking in vt_do_kdgkb_ioctl() Hangyu Hua
2022-09-08  8:10 ` Jiri Slaby
2022-09-09  2:02   ` Hangyu Hua
2022-09-08  8:16 ` Greg KH
2022-09-08 13:23 ` kernel test robot
2022-09-12 11:18 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox