[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220908075403.27930-1-hbh25y@gmail.com>
Date: Thu, 8 Sep 2022 15:54:03 +0800
From: Hangyu Hua <hbh25y@...il.com>
To: gregkh@...uxfoundation.org, jirislaby@...nel.org,
changlianzhi@...ontech.com, dmitry.torokhov@...il.com
Cc: linux-kernel@...r.kernel.org, Hangyu Hua <hbh25y@...il.com>
Subject: [PATCH] tty: vt: add a bounds checking in vt_do_kdgkb_ioctl()
As array_index_nospec's comments indicateļ¼a bounds checking need to add
before calling array_index_nospec.
Signed-off-by: Hangyu Hua <hbh25y@...il.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
Powered by blists - more mailing lists