From: Jiri Slaby <jirislaby@kernel.org>
To: Hangyu Hua <hbh25y@gmail.com>,
gregkh@linuxfoundation.org, changlianzhi@uniontech.com,
dmitry.torokhov@gmail.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tty: vt: add a bounds checking in vt_do_kdgkb_ioctl()
Date: Thu, 8 Sep 2022 10:10:12 +0200 [thread overview]
Message-ID: <6236da54-c651-9dc7-f5ce-824be96b3e9d@kernel.org> (raw)
In-Reply-To: <20220908075403.27930-1-hbh25y@gmail.com>
On 08. 09. 22, 9:54, Hangyu Hua wrote:
> 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)
kb_func is unsigned char and MAX_NR_FUNC is 256. So this should be
eliminated by the compiler anyway.
But the check might be a good idea if we ever decide to support more
keys. But will/can we? I am not so sure, so adding it right now is kind
of superfluous. In any way we'd need to introduce a completely different
iterface/ioctls.
> + return -EFAULT;
EINVAL would be more appropriate, IMO.
> +
> kb_func = array_index_nospec(kb_func, MAX_NR_FUNC);
>
> switch (cmd) {
thanks,
--
js
suse labs
next prev parent reply other threads:[~2022-09-08 8:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-08 7:54 Hangyu Hua
2022-09-08 8:10 ` Jiri Slaby [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6236da54-c651-9dc7-f5ce-824be96b3e9d@kernel.org \
--to=jirislaby@kernel.org \
--cc=changlianzhi@uniontech.com \
--cc=dmitry.torokhov@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hbh25y@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®