Skip to content

Commit

Permalink
vt_ioctl: fix GIO_UNIMAP regression
Browse files Browse the repository at this point in the history
commit d546547 upstream.

In commit 5ba1278, we shuffled with the check of 'perm'. But my
brain somehow inverted the condition in 'do_unimap_ioctl' (I thought
it is ||, not &&), so GIO_UNIMAP stopped working completely.

Move the 'perm' checks back to do_unimap_ioctl and do them right again.
In fact, this reverts this part of code to the pre-5ba127878722 state.
Except 'perm' is now a bool.

Fixes: 5ba1278 ("vt_ioctl: move perm checks level up")
Cc: stable@vger.kernel.org
Reported-by: Fabian Vogt <fvogt@suse.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20201026055419.30518-1-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Jiri Slaby authored and gregkh committed Nov 5, 2020
1 parent c76b008 commit a9f0d28
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions drivers/tty/vt/vt_ioctl.c
Expand Up @@ -550,17 +550,19 @@ static int vt_io_fontreset(struct console_font_op *op)
}

static inline int do_unimap_ioctl(int cmd, struct unimapdesc __user *user_ud,
struct vc_data *vc)
bool perm, struct vc_data *vc)
{
struct unimapdesc tmp;

if (copy_from_user(&tmp, user_ud, sizeof tmp))
return -EFAULT;
switch (cmd) {
case PIO_UNIMAP:
if (!perm)
return -EPERM;
return con_set_unimap(vc, tmp.entry_ct, tmp.entries);
case GIO_UNIMAP:
if (fg_console != vc->vc_num)
if (!perm && fg_console != vc->vc_num)
return -EPERM;
return con_get_unimap(vc, tmp.entry_ct, &(user_ud->entry_ct),
tmp.entries);
Expand Down Expand Up @@ -640,10 +642,7 @@ static int vt_io_ioctl(struct vc_data *vc, unsigned int cmd, void __user *up,

case PIO_UNIMAP:
case GIO_UNIMAP:
if (!perm)
return -EPERM;

return do_unimap_ioctl(cmd, up, vc);
return do_unimap_ioctl(cmd, up, perm, vc);

default:
return -ENOIOCTLCMD;
Expand Down

0 comments on commit a9f0d28

Please sign in to comment.