The open path for ptmx slaves is via the ptmx device. Opening them any
other way is not allowed. Vegard Nossum found that previously this was not
the case and mknod foo c 128 42; cat foo would produce nasty diagnostics
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* init_dev - initialise a tty device
* @driver: tty driver we are opening a device on
* @idx: device index
* init_dev - initialise a tty device
* @driver: tty driver we are opening a device on
* @idx: device index
- * @tty: returned tty structure
+ * @ret_tty: returned tty structure
+ * @first_ok: ok to open a new device (used by ptmx)
*
* Prepare a tty device. This may not be a "new" clean device but
* could also be an active device. The pty drivers require special
*
* Prepare a tty device. This may not be a "new" clean device but
* could also be an active device. The pty drivers require special
*/
static int init_dev(struct tty_driver *driver, int idx,
*/
static int init_dev(struct tty_driver *driver, int idx,
- struct tty_struct **ret_tty)
+ struct tty_struct **ret_tty, int first_ok)
{
struct tty_struct *tty, *o_tty;
struct ktermios *tp, **tp_loc, *o_tp, **o_tp_loc;
{
struct tty_struct *tty, *o_tty;
struct ktermios *tp, **tp_loc, *o_tp, **o_tp_loc;
}
if (tty) goto fast_track;
}
if (tty) goto fast_track;
+ if (driver->subtype == PTY_TYPE_MASTER &&
+ (driver->flags & TTY_DRIVER_DEVPTS_MEM) && !first_ok) {
+ retval = -EIO;
+ goto end_init;
+ }
/*
* First time open is complex, especially for PTY devices.
* This code guarantees that either everything succeeds and the
/*
* First time open is complex, especially for PTY devices.
* This code guarantees that either everything succeeds and the
if (retval)
goto release_mem_out;
if (retval)
goto release_mem_out;
/*
* This fast open can be used if the tty is already open.
/*
* This fast open can be used if the tty is already open.
- * tty_open - open a tty device
+ * __tty_open - open a tty device
* @inode: inode of device file
* @filp: file pointer to tty
*
* @inode: inode of device file
* @filp: file pointer to tty
*
return -ENODEV;
}
got_driver:
return -ENODEV;
}
got_driver:
- retval = init_dev(driver, index, &tty);
+ retval = init_dev(driver, index, &tty, 0);
mutex_unlock(&tty_mutex);
if (retval)
return retval;
mutex_unlock(&tty_mutex);
if (retval)
return retval;
return index;
mutex_lock(&tty_mutex);
return index;
mutex_lock(&tty_mutex);
- retval = init_dev(ptm_driver, index, &tty);
+ retval = init_dev(ptm_driver, index, &tty, 1);
mutex_unlock(&tty_mutex);
if (retval)
mutex_unlock(&tty_mutex);
if (retval)