vt_ioctl: eliminate ret & breaks in vt_ioctl
This is still a leftover from BKL, when we locked it around vt_ioctl's code. We can return instead of breaks in the switch loop. And we can return in case of errors too. This allows for sifting of the code to the left in some cases. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20200615074910.19267-29-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
c5c717e7a5
commit
0ce8179e24
|
@ -357,7 +357,7 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
unsigned int uival;
|
unsigned int uival;
|
||||||
void __user *up = (void __user *)arg;
|
void __user *up = (void __user *)arg;
|
||||||
int i, perm;
|
int i, perm;
|
||||||
int ret = 0;
|
int ret;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* To have permissions to do most of the vt ioctls, we either have
|
* To have permissions to do most of the vt ioctls, we either have
|
||||||
|
@ -369,8 +369,7 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case TIOCLINUX:
|
case TIOCLINUX:
|
||||||
ret = tioclinux(tty, arg);
|
return tioclinux(tty, arg);
|
||||||
break;
|
|
||||||
case KIOCSOUND:
|
case KIOCSOUND:
|
||||||
if (!perm)
|
if (!perm)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
@ -408,8 +407,7 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
* this is naïve.
|
* this is naïve.
|
||||||
*/
|
*/
|
||||||
ucval = KB_101;
|
ucval = KB_101;
|
||||||
ret = put_user(ucval, (char __user *)arg);
|
return put_user(ucval, (char __user *)arg);
|
||||||
break;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These cannot be implemented on any machine that implements
|
* These cannot be implemented on any machine that implements
|
||||||
|
@ -426,18 +424,15 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
*
|
*
|
||||||
* These are locked internally via sys_ioperm
|
* These are locked internally via sys_ioperm
|
||||||
*/
|
*/
|
||||||
if (arg < GPFIRST || arg > GPLAST) {
|
if (arg < GPFIRST || arg > GPLAST)
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
break;
|
|
||||||
}
|
return ksys_ioperm(arg, 1, (cmd == KDADDIO)) ? -ENXIO : 0;
|
||||||
ret = ksys_ioperm(arg, 1, (cmd == KDADDIO)) ? -ENXIO : 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case KDENABIO:
|
case KDENABIO:
|
||||||
case KDDISABIO:
|
case KDDISABIO:
|
||||||
ret = ksys_ioperm(GPFIRST, GPNUM,
|
return ksys_ioperm(GPFIRST, GPNUM,
|
||||||
(cmd == KDENABIO)) ? -ENXIO : 0;
|
(cmd == KDENABIO)) ? -ENXIO : 0;
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Linux m68k/i386 interface for setting the keyboard delay/repeat rate */
|
/* Linux m68k/i386 interface for setting the keyboard delay/repeat rate */
|
||||||
|
@ -449,15 +444,14 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
if (!capable(CAP_SYS_TTY_CONFIG))
|
if (!capable(CAP_SYS_TTY_CONFIG))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
if (copy_from_user(&kbrep, up, sizeof(struct kbd_repeat))) {
|
if (copy_from_user(&kbrep, up, sizeof(struct kbd_repeat)))
|
||||||
ret = -EFAULT;
|
return -EFAULT;
|
||||||
break;
|
|
||||||
}
|
|
||||||
ret = kbd_rate(&kbrep);
|
ret = kbd_rate(&kbrep);
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
return ret;
|
||||||
if (copy_to_user(up, &kbrep, sizeof(struct kbd_repeat)))
|
if (copy_to_user(up, &kbrep, sizeof(struct kbd_repeat)))
|
||||||
ret = -EFAULT;
|
return -EFAULT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,8 +475,7 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
case KD_TEXT:
|
case KD_TEXT:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
/* FIXME: this needs the console lock extending */
|
/* FIXME: this needs the console lock extending */
|
||||||
if (vc->vc_mode == (unsigned char) arg)
|
if (vc->vc_mode == (unsigned char) arg)
|
||||||
|
@ -511,51 +504,45 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
* these work like a combination of mmap and KDENABIO.
|
* these work like a combination of mmap and KDENABIO.
|
||||||
* this could be easily finished.
|
* this could be easily finished.
|
||||||
*/
|
*/
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
break;
|
|
||||||
|
|
||||||
case KDSKBMODE:
|
case KDSKBMODE:
|
||||||
if (!perm)
|
if (!perm)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
ret = vt_do_kdskbmode(console, arg);
|
ret = vt_do_kdskbmode(console, arg);
|
||||||
if (ret == 0)
|
if (ret)
|
||||||
tty_ldisc_flush(tty);
|
return ret;
|
||||||
|
tty_ldisc_flush(tty);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KDGKBMODE:
|
case KDGKBMODE:
|
||||||
uival = vt_do_kdgkbmode(console);
|
uival = vt_do_kdgkbmode(console);
|
||||||
ret = put_user(uival, (int __user *)arg);
|
return put_user(uival, (int __user *)arg);
|
||||||
break;
|
|
||||||
|
|
||||||
/* this could be folded into KDSKBMODE, but for compatibility
|
/* this could be folded into KDSKBMODE, but for compatibility
|
||||||
reasons it is not so easy to fold KDGKBMETA into KDGKBMODE */
|
reasons it is not so easy to fold KDGKBMETA into KDGKBMODE */
|
||||||
case KDSKBMETA:
|
case KDSKBMETA:
|
||||||
ret = vt_do_kdskbmeta(console, arg);
|
return vt_do_kdskbmeta(console, arg);
|
||||||
break;
|
|
||||||
|
|
||||||
case KDGKBMETA:
|
case KDGKBMETA:
|
||||||
/* FIXME: should review whether this is worth locking */
|
/* FIXME: should review whether this is worth locking */
|
||||||
uival = vt_do_kdgkbmeta(console);
|
uival = vt_do_kdgkbmeta(console);
|
||||||
setint:
|
setint:
|
||||||
ret = put_user(uival, (int __user *)arg);
|
return put_user(uival, (int __user *)arg);
|
||||||
break;
|
|
||||||
|
|
||||||
case KDGETKEYCODE:
|
case KDGETKEYCODE:
|
||||||
case KDSETKEYCODE:
|
case KDSETKEYCODE:
|
||||||
if(!capable(CAP_SYS_TTY_CONFIG))
|
if(!capable(CAP_SYS_TTY_CONFIG))
|
||||||
perm = 0;
|
perm = 0;
|
||||||
ret = vt_do_kbkeycode_ioctl(cmd, up, perm);
|
return vt_do_kbkeycode_ioctl(cmd, up, perm);
|
||||||
break;
|
|
||||||
|
|
||||||
case KDGKBENT:
|
case KDGKBENT:
|
||||||
case KDSKBENT:
|
case KDSKBENT:
|
||||||
ret = vt_do_kdsk_ioctl(cmd, up, perm, console);
|
return vt_do_kdsk_ioctl(cmd, up, perm, console);
|
||||||
break;
|
|
||||||
|
|
||||||
case KDGKBSENT:
|
case KDGKBSENT:
|
||||||
case KDSKBSENT:
|
case KDSKBSENT:
|
||||||
ret = vt_do_kdgkb_ioctl(cmd, up, perm);
|
return vt_do_kdgkb_ioctl(cmd, up, perm);
|
||||||
break;
|
|
||||||
|
|
||||||
/* Diacritical processing. Handled in keyboard.c as it has
|
/* Diacritical processing. Handled in keyboard.c as it has
|
||||||
to operate on the keyboard locks and structures */
|
to operate on the keyboard locks and structures */
|
||||||
|
@ -563,8 +550,7 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
case KDGKBDIACRUC:
|
case KDGKBDIACRUC:
|
||||||
case KDSKBDIACR:
|
case KDSKBDIACR:
|
||||||
case KDSKBDIACRUC:
|
case KDSKBDIACRUC:
|
||||||
ret = vt_do_diacrit(cmd, up, perm);
|
return vt_do_diacrit(cmd, up, perm);
|
||||||
break;
|
|
||||||
|
|
||||||
/* the ioctls below read/set the flags usually shown in the leds */
|
/* the ioctls below read/set the flags usually shown in the leds */
|
||||||
/* don't use them - they will go away without warning */
|
/* don't use them - they will go away without warning */
|
||||||
|
@ -572,8 +558,7 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
case KDSKBLED:
|
case KDSKBLED:
|
||||||
case KDGETLED:
|
case KDGETLED:
|
||||||
case KDSETLED:
|
case KDSETLED:
|
||||||
ret = vt_do_kdskled(console, cmd, arg, perm);
|
return vt_do_kdskled(console, cmd, arg, perm);
|
||||||
break;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A process can indicate its willingness to accept signals
|
* A process can indicate its willingness to accept signals
|
||||||
|
@ -583,20 +568,17 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
* See also the kbrequest field of inittab(5).
|
* See also the kbrequest field of inittab(5).
|
||||||
*/
|
*/
|
||||||
case KDSIGACCEPT:
|
case KDSIGACCEPT:
|
||||||
{
|
|
||||||
if (!perm || !capable(CAP_KILL))
|
if (!perm || !capable(CAP_KILL))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
if (!valid_signal(arg) || arg < 1 || arg == SIGKILL)
|
if (!valid_signal(arg) || arg < 1 || arg == SIGKILL)
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
else {
|
|
||||||
spin_lock_irq(&vt_spawn_con.lock);
|
spin_lock_irq(&vt_spawn_con.lock);
|
||||||
put_pid(vt_spawn_con.pid);
|
put_pid(vt_spawn_con.pid);
|
||||||
vt_spawn_con.pid = get_pid(task_pid(current));
|
vt_spawn_con.pid = get_pid(task_pid(current));
|
||||||
vt_spawn_con.sig = arg;
|
vt_spawn_con.sig = arg;
|
||||||
spin_unlock_irq(&vt_spawn_con.lock);
|
spin_unlock_irq(&vt_spawn_con.lock);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case VT_SETMODE:
|
case VT_SETMODE:
|
||||||
{
|
{
|
||||||
|
@ -604,14 +586,11 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
|
|
||||||
if (!perm)
|
if (!perm)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
if (copy_from_user(&tmp, up, sizeof(struct vt_mode))) {
|
if (copy_from_user(&tmp, up, sizeof(struct vt_mode)))
|
||||||
ret = -EFAULT;
|
return -EFAULT;
|
||||||
goto out;
|
if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS)
|
||||||
}
|
return -EINVAL;
|
||||||
if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS) {
|
|
||||||
ret = -EINVAL;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
console_lock();
|
console_lock();
|
||||||
vc->vt_mode = tmp;
|
vc->vt_mode = tmp;
|
||||||
/* the frsig is ignored, so we set it to 0 */
|
/* the frsig is ignored, so we set it to 0 */
|
||||||
|
@ -635,7 +614,7 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
|
|
||||||
rc = copy_to_user(up, &tmp, sizeof(struct vt_mode));
|
rc = copy_to_user(up, &tmp, sizeof(struct vt_mode));
|
||||||
if (rc)
|
if (rc)
|
||||||
ret = -EFAULT;
|
return -EFAULT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -650,18 +629,16 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
unsigned short state, mask;
|
unsigned short state, mask;
|
||||||
|
|
||||||
if (put_user(fg_console + 1, &vtstat->v_active))
|
if (put_user(fg_console + 1, &vtstat->v_active))
|
||||||
ret = -EFAULT;
|
return -EFAULT;
|
||||||
else {
|
|
||||||
state = 1; /* /dev/tty0 is always open */
|
state = 1; /* /dev/tty0 is always open */
|
||||||
console_lock(); /* required by vt_in_use() */
|
console_lock(); /* required by vt_in_use() */
|
||||||
for (i = 0, mask = 2; i < MAX_NR_CONSOLES && mask;
|
for (i = 0, mask = 2; i < MAX_NR_CONSOLES && mask;
|
||||||
++i, mask <<= 1)
|
++i, mask <<= 1)
|
||||||
if (vt_in_use(i))
|
if (vt_in_use(i))
|
||||||
state |= mask;
|
state |= mask;
|
||||||
console_unlock();
|
console_unlock();
|
||||||
ret = put_user(state, &vtstat->v_state);
|
return put_user(state, &vtstat->v_state);
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -685,56 +662,54 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
if (!perm)
|
if (!perm)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
if (arg == 0 || arg > MAX_NR_CONSOLES)
|
if (arg == 0 || arg > MAX_NR_CONSOLES)
|
||||||
ret = -ENXIO;
|
return -ENXIO;
|
||||||
else {
|
|
||||||
arg--;
|
arg--;
|
||||||
console_lock();
|
console_lock();
|
||||||
ret = vc_allocate(arg);
|
ret = vc_allocate(arg);
|
||||||
console_unlock();
|
console_unlock();
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
return ret;
|
||||||
set_console(arg);
|
set_console(arg);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_SETACTIVATE:
|
case VT_SETACTIVATE:
|
||||||
{
|
{
|
||||||
struct vt_setactivate vsa;
|
struct vt_setactivate vsa;
|
||||||
|
struct vc_data *nvc;
|
||||||
|
|
||||||
if (!perm)
|
if (!perm)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
if (copy_from_user(&vsa, (struct vt_setactivate __user *)arg,
|
if (copy_from_user(&vsa, (struct vt_setactivate __user *)arg,
|
||||||
sizeof(struct vt_setactivate))) {
|
sizeof(struct vt_setactivate)))
|
||||||
ret = -EFAULT;
|
return -EFAULT;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
if (vsa.console == 0 || vsa.console > MAX_NR_CONSOLES)
|
if (vsa.console == 0 || vsa.console > MAX_NR_CONSOLES)
|
||||||
ret = -ENXIO;
|
return -ENXIO;
|
||||||
else {
|
|
||||||
vsa.console = array_index_nospec(vsa.console,
|
vsa.console = array_index_nospec(vsa.console,
|
||||||
MAX_NR_CONSOLES + 1);
|
MAX_NR_CONSOLES + 1);
|
||||||
vsa.console--;
|
vsa.console--;
|
||||||
console_lock();
|
console_lock();
|
||||||
ret = vc_allocate(vsa.console);
|
ret = vc_allocate(vsa.console);
|
||||||
if (ret == 0) {
|
if (ret) {
|
||||||
struct vc_data *nvc;
|
|
||||||
/* This is safe providing we don't drop the
|
|
||||||
console sem between vc_allocate and
|
|
||||||
finishing referencing nvc */
|
|
||||||
nvc = vc_cons[vsa.console].d;
|
|
||||||
nvc->vt_mode = vsa.mode;
|
|
||||||
nvc->vt_mode.frsig = 0;
|
|
||||||
put_pid(nvc->vt_pid);
|
|
||||||
nvc->vt_pid = get_pid(task_pid(current));
|
|
||||||
}
|
|
||||||
console_unlock();
|
console_unlock();
|
||||||
if (ret)
|
return ret;
|
||||||
break;
|
|
||||||
/* Commence switch and lock */
|
|
||||||
/* Review set_console locks */
|
|
||||||
set_console(vsa.console);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This is safe providing we don't drop the
|
||||||
|
console sem between vc_allocate and
|
||||||
|
finishing referencing nvc */
|
||||||
|
nvc = vc_cons[vsa.console].d;
|
||||||
|
nvc->vt_mode = vsa.mode;
|
||||||
|
nvc->vt_mode.frsig = 0;
|
||||||
|
put_pid(nvc->vt_pid);
|
||||||
|
nvc->vt_pid = get_pid(task_pid(current));
|
||||||
|
console_unlock();
|
||||||
|
|
||||||
|
/* Commence switch and lock */
|
||||||
|
/* Review set_console locks */
|
||||||
|
set_console(vsa.console);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -745,10 +720,8 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
if (!perm)
|
if (!perm)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
if (arg == 0 || arg > MAX_NR_CONSOLES)
|
if (arg == 0 || arg > MAX_NR_CONSOLES)
|
||||||
ret = -ENXIO;
|
return -ENXIO;
|
||||||
else
|
return vt_waitactive(arg);
|
||||||
ret = vt_waitactive(arg);
|
|
||||||
break;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If a vt is under process control, the kernel will not switch to it
|
* If a vt is under process control, the kernel will not switch to it
|
||||||
|
@ -767,8 +740,7 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
console_lock();
|
console_lock();
|
||||||
if (vc->vt_mode.mode != VT_PROCESS) {
|
if (vc->vt_mode.mode != VT_PROCESS) {
|
||||||
console_unlock();
|
console_unlock();
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Switching-from response
|
* Switching-from response
|
||||||
|
@ -792,7 +764,7 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
ret = vc_allocate(newvt);
|
ret = vc_allocate(newvt);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
console_unlock();
|
console_unlock();
|
||||||
break;
|
return ret;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* When we actually do the console switch,
|
* When we actually do the console switch,
|
||||||
|
@ -808,8 +780,10 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
/*
|
/*
|
||||||
* If it's just an ACK, ignore it
|
* If it's just an ACK, ignore it
|
||||||
*/
|
*/
|
||||||
if (arg != VT_ACKACQ)
|
if (arg != VT_ACKACQ) {
|
||||||
ret = -EINVAL;
|
console_unlock();
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
console_unlock();
|
console_unlock();
|
||||||
break;
|
break;
|
||||||
|
@ -818,40 +792,38 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
* Disallocate memory associated to VT (but leave VT1)
|
* Disallocate memory associated to VT (but leave VT1)
|
||||||
*/
|
*/
|
||||||
case VT_DISALLOCATE:
|
case VT_DISALLOCATE:
|
||||||
if (arg > MAX_NR_CONSOLES) {
|
if (arg > MAX_NR_CONSOLES)
|
||||||
ret = -ENXIO;
|
return -ENXIO;
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (arg == 0)
|
if (arg == 0)
|
||||||
vt_disallocate_all();
|
vt_disallocate_all();
|
||||||
else
|
else
|
||||||
ret = vt_disallocate(--arg);
|
return vt_disallocate(--arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_RESIZE:
|
case VT_RESIZE:
|
||||||
{
|
{
|
||||||
struct vt_sizes __user *vtsizes = up;
|
struct vt_sizes __user *vtsizes = up;
|
||||||
struct vc_data *vc;
|
struct vc_data *vc;
|
||||||
|
|
||||||
ushort ll,cc;
|
ushort ll,cc;
|
||||||
|
|
||||||
if (!perm)
|
if (!perm)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
if (get_user(ll, &vtsizes->v_rows) ||
|
if (get_user(ll, &vtsizes->v_rows) ||
|
||||||
get_user(cc, &vtsizes->v_cols))
|
get_user(cc, &vtsizes->v_cols))
|
||||||
ret = -EFAULT;
|
return -EFAULT;
|
||||||
else {
|
|
||||||
console_lock();
|
|
||||||
for (i = 0; i < MAX_NR_CONSOLES; i++) {
|
|
||||||
vc = vc_cons[i].d;
|
|
||||||
|
|
||||||
if (vc) {
|
console_lock();
|
||||||
vc->vc_resize_user = 1;
|
for (i = 0; i < MAX_NR_CONSOLES; i++) {
|
||||||
/* FIXME: review v tty lock */
|
vc = vc_cons[i].d;
|
||||||
vc_resize(vc_cons[i].d, cc, ll);
|
|
||||||
}
|
if (vc) {
|
||||||
|
vc->vc_resize_user = 1;
|
||||||
|
/* FIXME: review v tty lock */
|
||||||
|
vc_resize(vc_cons[i].d, cc, ll);
|
||||||
}
|
}
|
||||||
console_unlock();
|
|
||||||
}
|
}
|
||||||
|
console_unlock();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -905,7 +877,7 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case PIO_FONT: {
|
case PIO_FONT:
|
||||||
if (!perm)
|
if (!perm)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
op.op = KD_FONT_OP_SET;
|
op.op = KD_FONT_OP_SET;
|
||||||
|
@ -914,98 +886,77 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
op.height = 0;
|
op.height = 0;
|
||||||
op.charcount = 256;
|
op.charcount = 256;
|
||||||
op.data = up;
|
op.data = up;
|
||||||
ret = con_font_op(vc_cons[fg_console].d, &op);
|
return con_font_op(vc_cons[fg_console].d, &op);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GIO_FONT: {
|
case GIO_FONT:
|
||||||
op.op = KD_FONT_OP_GET;
|
op.op = KD_FONT_OP_GET;
|
||||||
op.flags = KD_FONT_FLAG_OLD;
|
op.flags = KD_FONT_FLAG_OLD;
|
||||||
op.width = 8;
|
op.width = 8;
|
||||||
op.height = 32;
|
op.height = 32;
|
||||||
op.charcount = 256;
|
op.charcount = 256;
|
||||||
op.data = up;
|
op.data = up;
|
||||||
ret = con_font_op(vc_cons[fg_console].d, &op);
|
return con_font_op(vc_cons[fg_console].d, &op);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case PIO_CMAP:
|
case PIO_CMAP:
|
||||||
if (!perm)
|
if (!perm)
|
||||||
ret = -EPERM;
|
return -EPERM;
|
||||||
else
|
return con_set_cmap(up);
|
||||||
ret = con_set_cmap(up);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GIO_CMAP:
|
case GIO_CMAP:
|
||||||
ret = con_get_cmap(up);
|
return con_get_cmap(up);
|
||||||
break;
|
|
||||||
|
|
||||||
case PIO_FONTX:
|
case PIO_FONTX:
|
||||||
case GIO_FONTX:
|
case GIO_FONTX:
|
||||||
ret = do_fontx_ioctl(cmd, up, perm, &op);
|
return do_fontx_ioctl(cmd, up, perm, &op);
|
||||||
break;
|
|
||||||
|
|
||||||
case PIO_FONTRESET:
|
case PIO_FONTRESET:
|
||||||
{
|
|
||||||
if (!perm)
|
if (!perm)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
#ifdef BROKEN_GRAPHICS_PROGRAMS
|
#ifdef BROKEN_GRAPHICS_PROGRAMS
|
||||||
/* With BROKEN_GRAPHICS_PROGRAMS defined, the default
|
/* With BROKEN_GRAPHICS_PROGRAMS defined, the default
|
||||||
font is not saved. */
|
font is not saved. */
|
||||||
ret = -ENOSYS;
|
return -ENOSYS;
|
||||||
break;
|
|
||||||
#else
|
#else
|
||||||
{
|
|
||||||
op.op = KD_FONT_OP_SET_DEFAULT;
|
op.op = KD_FONT_OP_SET_DEFAULT;
|
||||||
op.data = NULL;
|
op.data = NULL;
|
||||||
ret = con_font_op(vc_cons[fg_console].d, &op);
|
ret = con_font_op(vc_cons[fg_console].d, &op);
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
return ret;
|
||||||
console_lock();
|
console_lock();
|
||||||
con_set_default_unimap(vc_cons[fg_console].d);
|
con_set_default_unimap(vc_cons[fg_console].d);
|
||||||
console_unlock();
|
console_unlock();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
case KDFONTOP: {
|
case KDFONTOP: {
|
||||||
if (copy_from_user(&op, up, sizeof(op))) {
|
if (copy_from_user(&op, up, sizeof(op)))
|
||||||
ret = -EFAULT;
|
return -EFAULT;
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!perm && op.op != KD_FONT_OP_GET)
|
if (!perm && op.op != KD_FONT_OP_GET)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
ret = con_font_op(vc, &op);
|
ret = con_font_op(vc, &op);
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
return ret;
|
||||||
if (copy_to_user(up, &op, sizeof(op)))
|
if (copy_to_user(up, &op, sizeof(op)))
|
||||||
ret = -EFAULT;
|
return -EFAULT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case PIO_SCRNMAP:
|
case PIO_SCRNMAP:
|
||||||
if (!perm)
|
if (!perm)
|
||||||
ret = -EPERM;
|
return -EPERM;
|
||||||
else
|
return con_set_trans_old(up);
|
||||||
ret = con_set_trans_old(up);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GIO_SCRNMAP:
|
case GIO_SCRNMAP:
|
||||||
ret = con_get_trans_old(up);
|
return con_get_trans_old(up);
|
||||||
break;
|
|
||||||
|
|
||||||
case PIO_UNISCRNMAP:
|
case PIO_UNISCRNMAP:
|
||||||
if (!perm)
|
if (!perm)
|
||||||
ret = -EPERM;
|
return -EPERM;
|
||||||
else
|
return con_set_trans_new(up);
|
||||||
ret = con_set_trans_new(up);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GIO_UNISCRNMAP:
|
case GIO_UNISCRNMAP:
|
||||||
ret = con_get_trans_new(up);
|
return con_get_trans_new(up);
|
||||||
break;
|
|
||||||
|
|
||||||
case PIO_UNIMAPCLR:
|
case PIO_UNIMAPCLR:
|
||||||
if (!perm)
|
if (!perm)
|
||||||
|
@ -1015,8 +966,7 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
|
|
||||||
case PIO_UNIMAP:
|
case PIO_UNIMAP:
|
||||||
case GIO_UNIMAP:
|
case GIO_UNIMAP:
|
||||||
ret = do_unimap_ioctl(cmd, up, perm, vc);
|
return do_unimap_ioctl(cmd, up, perm, vc);
|
||||||
break;
|
|
||||||
|
|
||||||
case VT_LOCKSWITCH:
|
case VT_LOCKSWITCH:
|
||||||
if (!capable(CAP_SYS_TTY_CONFIG))
|
if (!capable(CAP_SYS_TTY_CONFIG))
|
||||||
|
@ -1029,17 +979,15 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
vt_dont_switch = false;
|
vt_dont_switch = false;
|
||||||
break;
|
break;
|
||||||
case VT_GETHIFONTMASK:
|
case VT_GETHIFONTMASK:
|
||||||
ret = put_user(vc->vc_hi_font_mask,
|
return put_user(vc->vc_hi_font_mask,
|
||||||
(unsigned short __user *)arg);
|
(unsigned short __user *)arg);
|
||||||
break;
|
|
||||||
case VT_WAITEVENT:
|
case VT_WAITEVENT:
|
||||||
ret = vt_event_wait_ioctl((struct vt_event __user *)arg);
|
return vt_event_wait_ioctl((struct vt_event __user *)arg);
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
ret = -ENOIOCTLCMD;
|
return -ENOIOCTLCMD;
|
||||||
}
|
}
|
||||||
out:
|
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_vc(struct vc_data *vc)
|
void reset_vc(struct vc_data *vc)
|
||||||
|
|
Loading…
Reference in New Issue