]> git.baikalelectronics.ru Git - kernel.git/commit
vt: keyboard, reorder user buffer handling in vt_do_kdgkb_ioctl
authorJiri Slaby <jslaby@suse.cz>
Thu, 29 Oct 2020 11:32:16 +0000 (12:32 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Nov 2020 15:43:38 +0000 (16:43 +0100)
commitb1c5bfa415ffc0c4dc48fc323678c85eee87988e
tree41bac874491adee454224fd78c666d8d7564d58e
parentd8f16b5aec15beb7607b4bc88661259588773cb1
vt: keyboard, reorder user buffer handling in vt_do_kdgkb_ioctl

KDGKBSENT (the getter) needs only 'user_kdgkb->kb_func' from the
userspace, i.e. the index. Then it needs a buffer for a local copy of
'kb_string'.

KDSKBSENT (the setter) needs a copy up to the length of
'user_kdgkb->kb_string'.

That means, we obtain the index before the switch-case and use it in
both paths and:
1) allocate full space in the getter case, and
2) copy the string only in the setter case. We do it by strndup_user
   helper now which was not available when this function was written.

Given we copy the two members of 'struct kbsentry' separately, we no
longer need a local definition. Hence we need to change all the sizeofs
here too.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20201029113222.32640-11-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/vt/keyboard.c