Skip to content

Commit d546547

Browse files
Jiri Slabygregkh
authored andcommitted
vt_ioctl: fix GIO_UNIMAP regression
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>
1 parent 82e61c3 commit d546547

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

drivers/tty/vt/vt_ioctl.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -549,17 +549,19 @@ static int vt_io_fontreset(struct console_font_op *op)
549549
}
550550

551551
static inline int do_unimap_ioctl(int cmd, struct unimapdesc __user *user_ud,
552-
struct vc_data *vc)
552+
bool perm, struct vc_data *vc)
553553
{
554554
struct unimapdesc tmp;
555555

556556
if (copy_from_user(&tmp, user_ud, sizeof tmp))
557557
return -EFAULT;
558558
switch (cmd) {
559559
case PIO_UNIMAP:
560+
if (!perm)
561+
return -EPERM;
560562
return con_set_unimap(vc, tmp.entry_ct, tmp.entries);
561563
case GIO_UNIMAP:
562-
if (fg_console != vc->vc_num)
564+
if (!perm && fg_console != vc->vc_num)
563565
return -EPERM;
564566
return con_get_unimap(vc, tmp.entry_ct, &(user_ud->entry_ct),
565567
tmp.entries);
@@ -639,10 +641,7 @@ static int vt_io_ioctl(struct vc_data *vc, unsigned int cmd, void __user *up,
639641

640642
case PIO_UNIMAP:
641643
case GIO_UNIMAP:
642-
if (!perm)
643-
return -EPERM;
644-
645-
return do_unimap_ioctl(cmd, up, vc);
644+
return do_unimap_ioctl(cmd, up, perm, vc);
646645

647646
default:
648647
return -ENOIOCTLCMD;

0 commit comments

Comments
 (0)