vt: vt_ioctl: remove unnecessary console allocation checks
commit 1aa6e058dd
upstream.
The vc_cons_allocated() checks in vt_ioctl() and vt_compat_ioctl() are
unnecessary because they can only be reached by calling ioctl() on an
open tty, which implies the corresponding virtual console is allocated.
And even if the virtual console *could* be freed concurrently, then
these checks would be broken since they aren't done under console_lock,
and the vc_data is dereferenced before them anyway.
So, remove these unneeded checks to avoid confusion.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Link: https://lore.kernel.org/r/20200224080326.295046-1-ebiggers@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
c897e625f9
commit
d1b6ab26c8
|
@ -350,22 +350,13 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
{
|
{
|
||||||
struct vc_data *vc = tty->driver_data;
|
struct vc_data *vc = tty->driver_data;
|
||||||
struct console_font_op op; /* used in multiple places here */
|
struct console_font_op op; /* used in multiple places here */
|
||||||
unsigned int console;
|
unsigned int console = vc->vc_num;
|
||||||
unsigned char ucval;
|
unsigned char ucval;
|
||||||
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 = 0;
|
||||||
|
|
||||||
console = vc->vc_num;
|
|
||||||
|
|
||||||
|
|
||||||
if (!vc_cons_allocated(console)) { /* impossible? */
|
|
||||||
ret = -ENOIOCTLCMD;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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
|
||||||
* to be the owner of the tty, or have CAP_SYS_TTY_CONFIG.
|
* to be the owner of the tty, or have CAP_SYS_TTY_CONFIG.
|
||||||
|
@ -1195,14 +1186,9 @@ long vt_compat_ioctl(struct tty_struct *tty,
|
||||||
{
|
{
|
||||||
struct vc_data *vc = tty->driver_data;
|
struct vc_data *vc = tty->driver_data;
|
||||||
struct console_font_op op; /* used in multiple places here */
|
struct console_font_op op; /* used in multiple places here */
|
||||||
unsigned int console = vc->vc_num;
|
|
||||||
void __user *up = compat_ptr(arg);
|
void __user *up = compat_ptr(arg);
|
||||||
int perm;
|
int perm;
|
||||||
|
|
||||||
|
|
||||||
if (!vc_cons_allocated(console)) /* impossible? */
|
|
||||||
return -ENOIOCTLCMD;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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
|
||||||
* to be the owner of the tty, or have CAP_SYS_TTY_CONFIG.
|
* to be the owner of the tty, or have CAP_SYS_TTY_CONFIG.
|
||||||
|
|
Loading…
Reference in New Issue