summaryrefslogtreecommitdiffstats
path: root/drivers/tty/vt/keyboard.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2020-10-29 12:32:12 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-11-04 16:43:38 +0100
commitee1cf8a58273d53ef56c578810f2a94b1aeb55a4 (patch)
tree7ed8585b881c9cb48d62cb257171110eadcdf29d /drivers/tty/vt/keyboard.c
parentvt: keyboard, extract vt_kdgkbent and vt_kdskbent (diff)
downloadlinux-ee1cf8a58273d53ef56c578810f2a94b1aeb55a4.tar.xz
linux-ee1cf8a58273d53ef56c578810f2a94b1aeb55a4.zip
vt: keyboard, union perm checks in vt_do_kdsk_ioctl
Do the permission check on a single place. That is where perm is really checked. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20201029113222.32640-7-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/vt/keyboard.c')
-rw-r--r--drivers/tty/vt/keyboard.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index c1709b8dbb52..823df9bb52b1 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -2004,16 +2004,13 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
if (copy_from_user(&kbe, user_kbe, sizeof(struct kbentry)))
return -EFAULT;
- if (!capable(CAP_SYS_TTY_CONFIG))
- perm = 0;
-
switch (cmd) {
case KDGKBENT:
return put_user(vt_kdgkbent(kb->kbdmode, kbe.kb_index,
kbe.kb_table),
&user_kbe->kb_value);
case KDSKBENT:
- if (!perm)
+ if (!perm || !capable(CAP_SYS_TTY_CONFIG))
return -EPERM;
return vt_kdskbent(kb->kbdmode, kbe.kb_index, kbe.kb_table,
kbe.kb_value);