tty ioctls cleanups, compat and not only
Subsystems (17)
Al Viro
maintainerPATCH 1/1 tty ioctls cleanups, compat and not only
See vfs.git#work.tty-ioctl. Completely untested, should seriously
clean the things up wrt compat. Remaining problems (aside of the bugs introduced in it, of course):
* TIOCSERGSTRUCT must die; it's present only in amiserial and it's
_vile_; look at what it copies out and weep.
* synclink_gt has proper compat handling for its private ioctls;
other synclink drivers (with the same ioctls) do not.
* dgnc definitely has buggered ioctls - structs full of longs are
bloody bad idea for passing around. It's in staging, and I'd say that it needs the userland ABI fixed.
* cyclades, rocket, moxa and mxser probably have non-trivial
problems with their private ioctls; I hadn't looked into those.
* n_gsm needs ->compat_ioctl(); easy to do, I just hadn't done it
yet.
* ipwireless might or might not need compat_ioctl (PPP stuff in it);
not sure.
* ldisc private ioctls need more work. Hadn't gone there yet.
Generic ioctls should be fine - they never reach ->compat_ioctl() with this series.
There's some overlap with patches posted earlier - e.g. I'm fairly
sure that keyboard ioctl "remove from fs/compat_ioctl.c" part duplicates one of yours; I'll be glad to drop and replace such duplicates with already posted variants.
Basic idea is to shunt generic ioctls that are reachable only
via tty_ioctl() very early in tty_compat_ioctl(), separately for those that do and do not need compat_ptr(). That already simplifies the hell out of ->compat_ioctl() situation - its instances won't ever see those, so they can e.g. ignore the behaviour of n_tty_ioctl_helper(); whatever they get in cmd won't be accepted by that one.
Next we separate TIOC[SG]SERIAL into a couple of new methods,
leaving the copyin/copyout to callers. That allows to take care of compat for those in tty_compat_ioctl() *and* actually kills some of ->ioctl() instances.
And then there's dead code of all kinds all over the place ;-/
The oldest one has been alive from Aug 1 1992 to Oct 18 1992 and had shambled around ever since (FIONBIO), but there are other examples. 10 years dead is better than 26, but still...
Shortlog and diffstat follow, patches in followups...
Al Viro (50):
presence of RS485 ioctls has been unconditional since 2014
move compat handling of tty ioctls to tty_compat_ioctl()
tty_ioctl(): drop FIONBIO handling
mos7720: bury dead TIOCM... in ->ioctl()
tty_ioctl(): start taking TIOC[SG]SERIAL into separate methods
simserial: switch to ->[sg]et_serial()
fwserial: switch to ->[sg]et_serial()
greybus/uart: switch to ->[sg]et_serial()
amiserial: switch to ->[sg]et_serial()
cyclades: switch to ->[sg]et_serial()
ipwireless: switch to ->[sg]et_serial()
isicom: switch to ->[sg]et_serial()
moxa: switch to ->[sg]et_serial()
mxser: switch to ->[sg]et_serial()
serial_core: switch to ->[sg]et_serial()
rfcomm: get rid of mentioning TIOC[SG]SERIAL
usb-serial: begin switching to ->[sg]et_serial()
cdc-acm: switch to ->[sg]et_serial()
ark3116: switch to ->get_serial()
f81232: switch to ->get_serial()
f81534: switch to ->get_serial()
fdti_sio: switch to ->[sg]et_serial()
io_edgeport: switch to ->get_serial()
io_ti: switch to ->get_serial()
mos7720: switch to ->get_serial()
mos7840: switch to ->get_serial()
opticon: switch to ->get_serial()
pl2303: switch to ->get_serial()
quatech2: switch to ->get_serial()
ssu100: switch to ->get_serial()
ti_usb_3410_5052: switch to ->[sg]et_serial()
whiteheat: switch to ->get_serial()
usb_wwan: switch to ->[sg]et_serial()
complete ->[sg]et_serial() switchover
synclink: reduce pointless checks in ->ioctl()
take compat TIOC[SG]SERIAL treatment into tty_compat_ioctl()
kill capinc_tty_ioctl()
isdn_tty: TCSBRK{,P} won't reach ->ioctl()
dgnc: TIOCM... won't reach ->ioctl()
kill the rest of tty COMPAT_IOCTL() entries
dgnc: break-related ioctls won't reach ->ioctl()
remove fallback to drivers for TIOCGICOUNT
dgnc: leave TIOC[GS]SOFTCAR to ldisc
dgnc: don't bother with (empty) stub for TCXONC
gigaset: don't try to printk userland buffer contents
vt_compat_ioctl(): clean up, use compat_ptr() properly
gigaset: add ->compat_ioctl()
compat_ioctl - kill keyboard ioctl handling
pty: fix compat ioctls
synclink_gt(): fix compat_ioctl()arch/ia64/hp/sim/simserial.c | 17 ++- drivers/char/pcmcia/synclink_cs.c | 3 +- drivers/isdn/capi/capi.c | 7 -- drivers/isdn/gigaset/interface.c | 13 +- drivers/isdn/i4l/isdn_tty.c | 19 --- drivers/staging/dgnc/dgnc_tty.c | 218 -------------------------------- drivers/staging/fwserial/fwserial.c | 66 +++++----- drivers/staging/greybus/uart.c | 47 +++---- drivers/tty/amiserial.c | 83 ++++++------- drivers/tty/cyclades.c | 77 ++++++------ drivers/tty/ipwireless/tty.c | 36 +++--- drivers/tty/isicom.c | 72 ++++------- drivers/tty/moxa.c | 79 ++++++------ drivers/tty/mxser.c | 97 ++++++++------- drivers/tty/pty.c | 6 +- drivers/tty/serial/serial_core.c | 38 ++---- drivers/tty/synclink.c | 3 +- drivers/tty/synclink_gt.c | 19 +-- drivers/tty/synclinkmp.c | 3 +- drivers/tty/tty_io.c | 226 +++++++++++++++++++++++++++------- drivers/tty/tty_ioctl.c | 16 --- drivers/tty/vt/vt_ioctl.c | 31 ++--- drivers/usb/class/cdc-acm.c | 41 +++--- drivers/usb/serial/ark3116.c | 38 ++---- drivers/usb/serial/f81232.c | 36 ++---- drivers/usb/serial/f81534.c | 38 ++---- drivers/usb/serial/ftdi_sio.c | 48 ++++---- drivers/usb/serial/io_edgeport.c | 37 +++--- drivers/usb/serial/io_ti.c | 47 +++---- drivers/usb/serial/mos7720.c | 88 +++---------- drivers/usb/serial/mos7840.c | 40 +++--- drivers/usb/serial/opticon.c | 43 ++----- drivers/usb/serial/option.c | 3 +- drivers/usb/serial/pl2303.c | 29 ++--- drivers/usb/serial/quatech2.c | 42 ++----- drivers/usb/serial/ssu100.c | 42 ++----- drivers/usb/serial/ti_usb_3410_5052.c | 74 ++++------- drivers/usb/serial/usb-serial.c | 18 +++ drivers/usb/serial/usb-wwan.h | 6 +- drivers/usb/serial/usb_wwan.c | 63 +++------- drivers/usb/serial/whiteheat.c | 42 +++---- fs/compat_ioctl.c | 169 ------------------------- include/linux/tty.h | 2 - include/linux/tty_driver.h | 3 + include/linux/usb/serial.h | 2 + net/bluetooth/rfcomm/tty.c | 8 -- 46 files changed, 744 insertions(+), 1391 deletions(-)
Al Viro
maintainerPATCH 1/50 presence of RS485 ioctls has been unconditional since 2014
From: Al Viro <[email protected]>
--- fs/compat_ioctl.c | 4 ---- 1 file changed, 4 deletions(-)
fs/compat_ioctl.c +0 -4
@@ -749,12 +749,8 @@ COMPATIBLE_IOCTL(TIOCOUTQ) COMPATIBLE_IOCTL(TIOCSPGRP) COMPATIBLE_IOCTL(TIOCGPGRP) COMPATIBLE_IOCTL(TIOCSERGETLSR) -#ifdef TIOCSRS485 COMPATIBLE_IOCTL(TIOCSRS485) -#endif -#ifdef TIOCGRS485 COMPATIBLE_IOCTL(TIOCGRS485) -#endif #ifdef TCGETS2 COMPATIBLE_IOCTL(TCGETS2) COMPATIBLE_IOCTL(TCSETS2)
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 12/50 isicom: switch to ->[sg]et_serial()
From: Al Viro <[email protected]>
--- drivers/tty/isicom.c | 72 ++++++++++++++++++---------------------------------- 1 file changed, 25 insertions(+), 47 deletions(-)
drivers/tty/isicom.c +25 -47
@@ -1091,34 +1091,33 @@ static int isicom_tiocmset(struct tty_struct *tty, }static int isicom_set_serial_info (struct tty_struct *tty, -struct serial_struct __user *info) +struct serial_struct *ss) {struct isi_port *port = tty->driver_data; -struct serial_struct newinfo;int reconfig_port; -if (copy_from_user (&newinfo, info,sizeof (newinfo))) -return -EFAULT ; +if (isicom_paranoia_check (port, tty->name,"isicom_ioctl" )) +return -ENODEV ;mutex_lock (&port->port.mutex); reconfig_port = ((port->port.flags &ASYNC_SPD_MASK ) != - (newinfo.flags &ASYNC_SPD_MASK )); + (ss->flags &ASYNC_SPD_MASK ));if (!capable (CAP_SYS_ADMIN )) { -if ((newinfo.close_delay != port->port.close_delay) || - (newinfo.closing_wait != port->port.closing_wait) || - ((newinfo.flags & ~ASYNC_USR_MASK ) != +if ((ss->close_delay != port->port.close_delay) || + (ss->closing_wait != port->port.closing_wait) || + ((ss->flags & ~ASYNC_USR_MASK ) != (port->port.flags & ~ASYNC_USR_MASK ))) {mutex_unlock (&port->port.mutex);return -EPERM ; } port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK ) | - (newinfo.flags &ASYNC_USR_MASK )); + (ss->flags &ASYNC_USR_MASK )); }else { - port->port.close_delay = newinfo.close_delay; - port->port.closing_wait = newinfo.closing_wait; + port->port.close_delay = ss->close_delay; + port->port.closing_wait = ss->closing_wait; port->port.flags = ((port->port.flags & ~ASYNC_FLAGS ) | - (newinfo.flags &ASYNC_FLAGS )); + (ss->flags &ASYNC_FLAGS )); }if (reconfig_port) {unsigned long flags;
@@ -1130,46 +1129,24 @@ static int isicom_set_serial_info(struct tty_struct *tty,return 0 ; } -static int isicom_get_serial_info (struct isi_port *port, -struct serial_struct __user *info) -{ -struct serial_struct out_info; - -mutex_lock (&port->port.mutex); -memset (&out_info,0 ,sizeof (out_info)); -/* out_info.type = ? */ - out_info.line = port - isi_ports; - out_info.port = port->card->base; - out_info.irq = port->card->irq; - out_info.flags = port->port.flags; -/* out_info.baud_base = ? */ - out_info.close_delay = port->port.close_delay; - out_info.closing_wait = port->port.closing_wait; -mutex_unlock (&port->port.mutex); -if (copy_to_user (info, &out_info,sizeof (out_info))) -return -EFAULT ; -return 0 ; -} - -static int isicom_ioctl (struct tty_struct *tty, -unsigned int cmd,unsigned long arg) +static int isicom_get_serial_info (struct tty_struct *tty, +struct serial_struct *ss) {struct isi_port *port = tty->driver_data; -void __user *argp = (void __user *)arg;if (isicom_paranoia_check (port, tty->name,"isicom_ioctl" ))return -ENODEV ; -switch (cmd) { -case TIOCGSERIAL : -return isicom_get_serial_info (port, argp); - -case TIOCSSERIAL : -return isicom_set_serial_info (tty, argp); - -default : -return -ENOIOCTLCMD ; - } +mutex_lock (&port->port.mutex); +/* ss->type = ? */ + ss->line = port - isi_ports; + ss->port = port->card->base; + ss->irq = port->card->irq; + ss->flags = port->port.flags; +/* ss->baud_base = ? */ + ss->close_delay = port->port.close_delay; + ss->closing_wait = port->port.closing_wait; +mutex_unlock (&port->port.mutex);return 0 ; }
@@ -1273,7 +1250,6 @@ static const struct tty_operations isicom_ops = { .flush_chars = isicom_flush_chars, .write_room = isicom_write_room, .chars_in_buffer = isicom_chars_in_buffer, - .ioctl = isicom_ioctl, .set_termios = isicom_set_termios, .throttle = isicom_throttle, .unthrottle = isicom_unthrottle,
@@ -1284,6 +1260,8 @@ static const struct tty_operations isicom_ops = { .tiocmget = isicom_tiocmget, .tiocmset = isicom_tiocmset, .break_ctl = isicom_send_break, + .get_serial = isicom_get_serial_info, + .set_serial = isicom_set_serial_info, };static const struct tty_port_operations isicom_port_ops = {
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 8/50 greybus/uart: switch to ->[sg]et_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/staging/greybus/uart.c | 47 ++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 29 deletions(-)
drivers/staging/greybus/uart.c +18 -29
@@ -616,40 +616,33 @@ static void gb_tty_unthrottle(struct tty_struct *tty) } } -static int get_serial_info (struct gb_tty *gb_tty, -struct serial_struct __user *info) +static int get_serial_info (struct tty_struct *tty, +struct serial_struct *ss) { -struct serial_struct tmp; - -memset (&tmp,0 ,sizeof (tmp)); - tmp.type =PORT_16550A ; - tmp.line = gb_tty->minor; - tmp.xmit_fifo_size =16 ; - tmp.baud_base =9600 ; - tmp.close_delay = gb_tty->port.close_delay /10 ; - tmp.closing_wait = +struct gb_tty *gb_tty = tty->driver_data; + + ss->type =PORT_16550A ; + ss->line = gb_tty->minor; + ss->xmit_fifo_size =16 ; + ss->baud_base =9600 ; + ss->close_delay = gb_tty->port.close_delay /10 ; + ss->closing_wait = gb_tty->port.closing_wait ==ASYNC_CLOSING_WAIT_NONE ?ASYNC_CLOSING_WAIT_NONE : gb_tty->port.closing_wait /10 ; - -if (copy_to_user (info, &tmp,sizeof (tmp))) -return -EFAULT ;return 0 ; } -static int set_serial_info (struct gb_tty *gb_tty, -struct serial_struct __user *newinfo) +static int set_serial_info (struct tty_struct *tty, +struct serial_struct *ss) { -struct serial_struct new_serial; +struct gb_tty *gb_tty = tty->driver_data;unsigned int closing_wait;unsigned int close_delay;int retval =0 ; -if (copy_from_user (&new_serial, newinfo,sizeof (new_serial))) -return -EFAULT ; - - close_delay = new_serial.close_delay *10 ; - closing_wait = new_serial.closing_wait ==ASYNC_CLOSING_WAIT_NONE ? -ASYNC_CLOSING_WAIT_NONE : new_serial.closing_wait *10 ; + close_delay = ss->close_delay *10 ; + closing_wait = ss->closing_wait ==ASYNC_CLOSING_WAIT_NONE ? +ASYNC_CLOSING_WAIT_NONE : ss->closing_wait *10 ;mutex_lock (&gb_tty->port.mutex);if (!capable (CAP_SYS_ADMIN )) {
@@ -728,12 +721,6 @@ static int gb_tty_ioctl(struct tty_struct *tty, unsigned int cmd,struct gb_tty *gb_tty = tty->driver_data;switch (cmd) { -case TIOCGSERIAL : -return get_serial_info (gb_tty, - (struct serial_struct __user *)arg); -case TIOCSSERIAL : -return set_serial_info (gb_tty, - (struct serial_struct __user *)arg);case TIOCMIWAIT :return wait_serial_change (gb_tty, arg); }
@@ -818,6 +805,8 @@ static const struct tty_operations gb_ops = { .tiocmget = gb_tty_tiocmget, .tiocmset = gb_tty_tiocmset, .get_icount = gb_tty_get_icount, + .set_serial = set_serial_info, + .get_serial = get_serial_info, };static const struct tty_port_operations gb_port_ops = {
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 24/50 io_ti: switch to ->get_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/usb/serial/io_ti.c | 47 ++++++++++++++-------------------------------- 1 file changed, 14 insertions(+), 33 deletions(-)
drivers/usb/serial/io_ti.c +14 -33
@@ -2437,47 +2437,28 @@ static int edge_tiocmget(struct tty_struct *tty)return result; } -static int get_serial_info (struct edgeport_port *edge_port, -struct serial_struct __user *retinfo) +static int get_serial_info (struct tty_struct *tty, +struct serial_struct *ss) { -struct serial_struct tmp; +struct usb_serial_port *port = tty->driver_data; +struct edgeport_port *edge_port =usb_get_serial_port_data (port);unsigned cwait; cwait = edge_port->port->port.closing_wait;if (cwait !=ASYNC_CLOSING_WAIT_NONE ) cwait =jiffies_to_msecs (cwait) /10 ; -memset (&tmp,0 ,sizeof (tmp)); - - tmp.type =PORT_16550A ; - tmp.line = edge_port->port->minor; - tmp.port = edge_port->port->port_number; - tmp.irq =0 ; - tmp.xmit_fifo_size = edge_port->port->bulk_out_size; - tmp.baud_base =9600 ; - tmp.close_delay =5 *HZ ; - tmp.closing_wait = cwait; - -if (copy_to_user (retinfo, &tmp,sizeof (*retinfo))) -return -EFAULT ; + ss->type =PORT_16550A ; + ss->line = edge_port->port->minor; + ss->port = edge_port->port->port_number; + ss->irq =0 ; + ss->xmit_fifo_size = edge_port->port->bulk_out_size; + ss->baud_base =9600 ; + ss->close_delay =5 *HZ ; + ss->closing_wait = cwait;return 0 ; } -static int edge_ioctl (struct tty_struct *tty, -unsigned int cmd,unsigned long arg) -{ -struct usb_serial_port *port = tty->driver_data; -struct edgeport_port *edge_port =usb_get_serial_port_data (port); - -switch (cmd) { -case TIOCGSERIAL : -dev_dbg (&port->dev,"%s - TIOCGSERIAL\n" , __func__); -return get_serial_info (edge_port, - (struct serial_struct __user *) arg); - } -return -ENOIOCTLCMD ; -} -static void edge_break (struct tty_struct *tty,int break_state) {struct usb_serial_port *port = tty->driver_data;
@@ -2738,7 +2719,7 @@ static struct usb_serial_driver edgeport_1port_device = { .release = edge_release, .port_probe = edge_port_probe, .port_remove = edge_port_remove, - .ioctl = edge_ioctl, + .get_serial = get_serial_info, .set_termios = edge_set_termios, .tiocmget = edge_tiocmget, .tiocmset = edge_tiocmset,
@@ -2777,7 +2758,7 @@ static struct usb_serial_driver edgeport_2port_device = { .release = edge_release, .port_probe = edge_port_probe, .port_remove = edge_port_remove, - .ioctl = edge_ioctl, + .get_serial = get_serial_info, .set_termios = edge_set_termios, .tiocmget = edge_tiocmget, .tiocmset = edge_tiocmset,
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 14/50 mxser: switch to ->[sg]et_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/tty/mxser.c | 97 ++++++++++++++++++++++++++++------------------------- 1 file changed, 51 insertions(+), 46 deletions(-)
drivers/tty/mxser.c +51 -46
@@ -1207,76 +1207,90 @@ static int mxser_chars_in_buffer(struct tty_struct *tty)* ------------------------------------------------------------ */ static int mxser_get_serial_info (struct tty_struct *tty, -struct serial_struct __user *retinfo) +struct serial_struct *ss) {struct mxser_port *info = tty->driver_data; -struct serial_struct tmp = { - .type = info->type, - .line = tty->index, - .port = info->ioaddr, - .irq = info->board->irq, - .flags = info->port.flags, - .baud_base = info->baud_base, - .close_delay = info->port.close_delay, - .closing_wait = info->port.closing_wait, - .custom_divisor = info->custom_divisor, - }; -if (copy_to_user (retinfo, &tmp,sizeof (*retinfo))) -return -EFAULT ; +struct tty_port *port = &info->port; + +if (tty->index ==MXSER_PORTS ) +return -ENOTTY ; + +mutex_lock (&port->mutex); + ss->type = info->type, + ss->line = tty->index, + ss->port = info->ioaddr, + ss->irq = info->board->irq, + ss->flags = info->port.flags, + ss->baud_base = info->baud_base, + ss->close_delay = info->port.close_delay, + ss->closing_wait = info->port.closing_wait, + ss->custom_divisor = info->custom_divisor, +mutex_unlock (&port->mutex);return 0 ; }static int mxser_set_serial_info (struct tty_struct *tty, -struct serial_struct __user *new_info) +struct serial_struct *ss) {struct mxser_port *info = tty->driver_data;struct tty_port *port = &info->port; -struct serial_struct new_serial;speed_t baud;unsigned long sl_flags;unsigned int flags;int retval =0 ; -if (!new_info || !info->ioaddr) +if (tty->index ==MXSER_PORTS ) +return -ENOTTY ; +if (tty_io_error (tty)) +return -EIO ; + +mutex_lock (&port->mutex); +if (!info->ioaddr) { +mutex_unlock (&port->mutex);return -ENODEV ; -if (copy_from_user (&new_serial, new_info,sizeof (new_serial))) -return -EFAULT ; + } -if (new_serial.irq != info->board->irq || - new_serial.port != info->ioaddr) +if (ss->irq != info->board->irq || + ss->port != info->ioaddr) { +mutex_unlock (&port->mutex);return -EINVAL ; + } flags = port->flags &ASYNC_SPD_MASK ;if (!capable (CAP_SYS_ADMIN )) { -if ((new_serial.baud_base != info->baud_base) || - (new_serial.close_delay != info->port.close_delay) || - ((new_serial.flags & ~ASYNC_USR_MASK ) != (info->port.flags & ~ASYNC_USR_MASK ))) +if ((ss->baud_base != info->baud_base) || + (ss->close_delay != info->port.close_delay) || + ((ss->flags & ~ASYNC_USR_MASK ) != (info->port.flags & ~ASYNC_USR_MASK ))) { +mutex_unlock (&port->mutex);return -EPERM ; + } info->port.flags = ((info->port.flags & ~ASYNC_USR_MASK ) | - (new_serial.flags &ASYNC_USR_MASK )); + (ss->flags &ASYNC_USR_MASK )); }else {/* * OK, past this point, all the error checking has been done. * At this point, we start making changes..... */ port->flags = ((port->flags & ~ASYNC_FLAGS ) | - (new_serial.flags &ASYNC_FLAGS )); - port->close_delay = new_serial.close_delay *HZ /100 ; - port->closing_wait = new_serial.closing_wait *HZ /100 ; + (ss->flags &ASYNC_FLAGS )); + port->close_delay = ss->close_delay *HZ /100 ; + port->closing_wait = ss->closing_wait *HZ /100 ; port->low_latency = (port->flags &ASYNC_LOW_LATENCY ) ?1 :0 ;if ((port->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_CUST && - (new_serial.baud_base != info->baud_base || - new_serial.custom_divisor != + (ss->baud_base != info->baud_base || + ss->custom_divisor != info->custom_divisor)) { -if (new_serial.custom_divisor ==0 ) +if (ss->custom_divisor ==0 ) { +mutex_unlock (&port->mutex);return -EINVAL ; - baud = new_serial.baud_base / new_serial.custom_divisor; + } + baud = ss->baud_base / ss->custom_divisor;tty_encode_baud_rate (tty, baud, baud); } } - info->type = new_serial.type; + info->type = ss->type;process_txrx_fifo (info);
@@ -1291,6 +1305,7 @@ static int mxser_set_serial_info(struct tty_struct *tty,if (retval ==0 )tty_port_set_initialized (port,1 ); } +mutex_unlock (&port->mutex);return retval; }
@@ -1660,11 +1675,9 @@ static int mxser_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) {struct mxser_port *info = tty->driver_data; -struct tty_port *port = &info->port;struct async_icount cnow;unsigned long flags;void __user *argp = (void __user *)arg; -int retval;if (tty->index ==MXSER_PORTS )return mxser_ioctl_special (cmd, argp);
@@ -1708,20 +1721,10 @@ static int mxser_ioctl(struct tty_struct *tty,return 0 ; } -if (cmd !=TIOCGSERIAL && cmd !=TIOCMIWAIT &&tty_io_error (tty)) +if (cmd !=TIOCMIWAIT &&tty_io_error (tty))return -EIO ;switch (cmd) { -case TIOCGSERIAL : -mutex_lock (&port->mutex); - retval =mxser_get_serial_info (tty, argp); -mutex_unlock (&port->mutex); -return retval; -case TIOCSSERIAL : -mutex_lock (&port->mutex); - retval =mxser_set_serial_info (tty, argp); -mutex_unlock (&port->mutex); -return retval;case TIOCSERGETLSR :/* Get line status register */ return mxser_get_lsr_info (info, argp);/*
@@ -2325,6 +2328,8 @@ static const struct tty_operations mxser_ops = { .wait_until_sent = mxser_wait_until_sent, .tiocmget = mxser_tiocmget, .tiocmset = mxser_tiocmset, + .set_serial = mxser_set_serial_info, + .get_serial = mxser_get_serial_info, .get_icount = mxser_get_icount, };
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 19/50 ark3116: switch to ->get_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/usb/serial/ark3116.c | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-)
drivers/usb/serial/ark3116.c +8 -30
@@ -397,38 +397,16 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port)return result; } -static int ark3116_get_serial_info (struct usb_serial_port *port, -struct serial_struct __user *retinfo) -{ -struct serial_struct tmp; - -memset (&tmp,0 ,sizeof (tmp)); - - tmp.type =PORT_16654 ; - tmp.line = port->minor; - tmp.port = port->port_number; - tmp.baud_base =460800 ; - -if (copy_to_user (retinfo, &tmp,sizeof (tmp))) -return -EFAULT ; - -return 0 ; -} - -static int ark3116_ioctl (struct tty_struct *tty, -unsigned int cmd,unsigned long arg) +static int ark3116_get_serial_info (struct tty_struct *tty, +struct serial_struct *ss) {struct usb_serial_port *port = tty->driver_data; -void __user *user_arg = (void __user *)arg; - -switch (cmd) { -case TIOCGSERIAL : -return ark3116_get_serial_info (port, user_arg); -default : -break ; - } -return -ENOIOCTLCMD ; + ss->type =PORT_16654 ; + ss->line = port->minor; + ss->port = port->port_number; + ss->baud_base =460800 ; +return 0 ; }static int ark3116_tiocmget (struct tty_struct *tty)
@@ -668,7 +646,7 @@ static struct usb_serial_driver ark3116_device = { .port_remove = ark3116_port_remove, .set_termios = ark3116_set_termios, .init_termios = ark3116_init_termios, - .ioctl = ark3116_ioctl, + .get_serial = ark3116_get_serial_info, .tiocmget = ark3116_tiocmget, .tiocmset = ark3116_tiocmset, .tiocmiwait = usb_serial_generic_tiocmiwait,
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 16/50 rfcomm: get rid of mentioning TIOC[SG]SERIAL
In reply to Al ViroFrom: Al Viro <[email protected]>
no support there
--- net/bluetooth/rfcomm/tty.c | 8 -------- 1 file changed, 8 deletions(-)
net/bluetooth/rfcomm/tty.c +0 -8
@@ -839,14 +839,6 @@ static int rfcomm_tty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned lBT_DBG ("TIOCMIWAIT" );break ; -case TIOCGSERIAL : -BT_ERR ("TIOCGSERIAL is not supported" ); -return -ENOIOCTLCMD ; - -case TIOCSSERIAL : -BT_ERR ("TIOCSSERIAL is not supported" ); -return -ENOIOCTLCMD ; -case TIOCSERGSTRUCT :BT_ERR ("TIOCSERGSTRUCT is not supported" );return -ENOIOCTLCMD ;
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 23/50 io_edgeport: switch to ->get_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/usb/serial/io_edgeport.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-)
drivers/usb/serial/io_edgeport.c +16 -21
@@ -1637,24 +1637,20 @@ static int edge_tiocmget(struct tty_struct *tty)return result; } -static int get_serial_info (struct edgeport_port *edge_port, -struct serial_struct __user *retinfo) +static int get_serial_info (struct tty_struct *tty, +struct serial_struct *ss) { -struct serial_struct tmp; - -memset (&tmp,0 ,sizeof (tmp)); - - tmp.type =PORT_16550A ; - tmp.line = edge_port->port->minor; - tmp.port = edge_port->port->port_number; - tmp.irq =0 ; - tmp.xmit_fifo_size = edge_port->maxTxCredits; - tmp.baud_base =9600 ; - tmp.close_delay =5 *HZ ; - tmp.closing_wait =30 *HZ ; +struct usb_serial_port *port = tty->driver_data; +struct edgeport_port *edge_port =usb_get_serial_port_data (port); -if (copy_to_user (retinfo, &tmp,sizeof (*retinfo))) -return -EFAULT ; + ss->type =PORT_16550A ; + ss->line = edge_port->port->minor; + ss->port = edge_port->port->port_number; + ss->irq =0 ; + ss->xmit_fifo_size = edge_port->maxTxCredits; + ss->baud_base =9600 ; + ss->close_delay =5 *HZ ; + ss->closing_wait =30 *HZ ;return 0 ; }
@@ -1667,17 +1663,12 @@ static int edge_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) {struct usb_serial_port *port = tty->driver_data; -DEFINE_WAIT (wait);struct edgeport_port *edge_port =usb_get_serial_port_data (port);switch (cmd) {case TIOCSERGETLSR :dev_dbg (&port->dev,"%s TIOCSERGETLSR\n" , __func__);return get_lsr_info (edge_port, (unsigned int __user *) arg); - -case TIOCGSERIAL : -dev_dbg (&port->dev,"%s TIOCGSERIAL\n" , __func__); -return get_serial_info (edge_port, (struct serial_struct __user *) arg); }return -ENOIOCTLCMD ; }
@@ -3126,6 +3117,7 @@ static struct usb_serial_driver edgeport_2port_device = { .set_termios = edge_set_termios, .tiocmget = edge_tiocmget, .tiocmset = edge_tiocmset, + .get_serial = get_serial_info, .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, .write = edge_write,
@@ -3161,6 +3153,7 @@ static struct usb_serial_driver edgeport_4port_device = { .set_termios = edge_set_termios, .tiocmget = edge_tiocmget, .tiocmset = edge_tiocmset, + .get_serial = get_serial_info, .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, .write = edge_write,
@@ -3196,6 +3189,7 @@ static struct usb_serial_driver edgeport_8port_device = { .set_termios = edge_set_termios, .tiocmget = edge_tiocmget, .tiocmset = edge_tiocmset, + .get_serial = get_serial_info, .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, .write = edge_write,
@@ -3231,6 +3225,7 @@ static struct usb_serial_driver epic_device = { .set_termios = edge_set_termios, .tiocmget = edge_tiocmget, .tiocmset = edge_tiocmset, + .get_serial = get_serial_info, .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, .write = edge_write,
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 50/50 synclink_gt(): fix compat_ioctl()
In reply to Al ViroFrom: Al Viro <[email protected]>
compat_ptr() for pointer-taking ones...
--- drivers/tty/synclink_gt.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/tty/synclink_gt.c +4 -12
@@ -1185,14 +1185,13 @@ static long slgt_compat_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) {struct slgt_info *info = tty->driver_data; -int rc = -ENOIOCTLCMD ; +int rc;if (sanity_check (info, tty->name,"compat_ioctl" ))return -ENODEV ;DBGINFO (("%s compat_ioctl() cmd=%08X\n" , info->device_name, cmd));switch (cmd) { -case MGSL_IOCSPARAMS32 : rc =set_params32 (info,compat_ptr (arg));break ;
@@ -1212,18 +1211,11 @@ static long slgt_compat_ioctl(struct tty_struct *tty,case MGSL_IOCWAITGPIO :case MGSL_IOCGXSYNC :case MGSL_IOCGXCTRL : -case MGSL_IOCSTXIDLE : -case MGSL_IOCTXENABLE : -case MGSL_IOCRXENABLE : -case MGSL_IOCTXABORT : -case TIOCMIWAIT : -case MGSL_IOCSIF : -case MGSL_IOCSXSYNC : -case MGSL_IOCSXCTRL : - rc =ioctl (tty, cmd, arg); + rc =ioctl (tty, cmd, (unsigned long )compat_ptr (arg));break ; +default : + rc =ioctl (tty, cmd, arg); } -DBGINFO (("%s compat_ioctl() cmd=%08X rc=%d\n" , info->device_name, cmd, rc));return rc; }
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 46/50 vt_compat_ioctl(): clean up, use compat_ptr() properly
In reply to Al ViroFrom: Al Viro <[email protected]>
we need it for "convert the structure" cases too
--- drivers/tty/vt/vt_ioctl.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-)
drivers/tty/vt/vt_ioctl.c +9 -22
@@ -1171,17 +1171,13 @@ long vt_compat_ioctl(struct tty_struct *tty, {struct vc_data *vc = tty->driver_data;struct console_font_op op;/* used in multiple places here */ -unsigned int console; -void __user *up = (void __user *)arg; +unsigned int console = vc->vc_num; +void __user *up =compat_ptr (arg);int perm; -int ret =0 ; - console = vc->vc_num; -if (!vc_cons_allocated (console)) {/* impossible? */ - ret = -ENOIOCTLCMD ; - goto out; - } +if (!vc_cons_allocated (console))/* impossible? */ +return -ENOIOCTLCMD ;/* * To have permissions to do most of the vt ioctls, we either have
@@ -1197,17 +1193,14 @@ long vt_compat_ioctl(struct tty_struct *tty,*/ case PIO_FONTX :case GIO_FONTX : - ret =compat_fontx_ioctl (cmd, up, perm, &op); -break ; +return compat_fontx_ioctl (cmd, up, perm, &op);case KDFONTOP : - ret =compat_kdfontop_ioctl (up, perm, &op, vc); -break ; +return compat_kdfontop_ioctl (up, perm, &op, vc);case PIO_UNIMAP :case GIO_UNIMAP : - ret =compat_unimap_ioctl (cmd, up, perm, vc); -break ; +return compat_unimap_ioctl (cmd, up, perm, vc);/* * all these treat 'arg' as an integer
@@ -1232,21 +1225,15 @@ long vt_compat_ioctl(struct tty_struct *tty,case VT_DISALLOCATE :case VT_RESIZE :case VT_RESIZEX : - goto fallback; +return vt_ioctl (tty, cmd, arg);/* * the rest has a compatible data structure behind arg, * but we have to convert it to a proper 64 bit pointer. */ default : - arg = (unsigned long )compat_ptr (arg); - goto fallback; +return vt_ioctl (tty, cmd, (unsigned long )up); } -out: -return ret; - -fallback: -return vt_ioctl (tty, cmd, arg); }
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 28/50 pl2303: switch to ->get_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/usb/serial/pl2303.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-)
drivers/usb/serial/pl2303.c +8 -21
@@ -808,29 +808,16 @@ static int pl2303_carrier_raised(struct usb_serial_port *port)return 0 ; } -static int pl2303_ioctl (struct tty_struct *tty, -unsigned int cmd,unsigned long arg) +static int pl2303_get_serial (struct tty_struct *tty, +struct serial_struct *ss) { -struct serial_struct ser;struct usb_serial_port *port = tty->driver_data; -switch (cmd) { -case TIOCGSERIAL : -memset (&ser,0 ,sizeof ser); - ser.type =PORT_16654 ; - ser.line = port->minor; - ser.port = port->port_number; - ser.baud_base =460800 ; - -if (copy_to_user ((void __user *)arg, &ser,sizeof ser)) -return -EFAULT ; - -return 0 ; -default : -break ; - } - -return -ENOIOCTLCMD ; + ss->type =PORT_16654 ; + ss->line = port->minor; + ss->port = port->port_number; + ss->baud_base =460800 ; +return 0 ; }static void pl2303_set_break (struct usb_serial_port *port,bool enable)
@@ -1016,7 +1003,7 @@ static struct usb_serial_driver pl2303_device = { .close = pl2303_close, .dtr_rts = pl2303_dtr_rts, .carrier_raised = pl2303_carrier_raised, - .ioctl = pl2303_ioctl, + .get_serial = pl2303_get_serial, .break_ctl = pl2303_break_ctl, .set_termios = pl2303_set_termios, .tiocmget = pl2303_tiocmget,
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 22/50 fdti_sio: switch to ->[sg]et_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/usb/serial/ftdi_sio.c | 48 +++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 27 deletions(-)
drivers/usb/serial/ftdi_sio.c +21 -27
@@ -1055,6 +1055,10 @@ static int ftdi_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear);static int ftdi_ioctl (struct tty_struct *tty,unsigned int cmd,unsigned long arg); +static int get_serial_info (struct tty_struct *tty, +struct serial_struct *ss); +static int set_serial_info (struct tty_struct *tty, +struct serial_struct *ss);static void ftdi_break_ctl (struct tty_struct *tty,int break_state);static bool ftdi_tx_empty (struct usb_serial_port *port); static int ftdi_get_modem_status(struct usb_serial_port *port,
@@ -1091,6 +1095,8 @@ static struct usb_serial_driver ftdi_sio_device = { .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, .ioctl = ftdi_ioctl, + .get_serial = get_serial_info, + .set_serial = set_serial_info, .set_termios = ftdi_set_termios, .break_ctl = ftdi_break_ctl, .tx_empty = ftdi_tx_empty,
@@ -1443,48 +1449,42 @@ static int read_latency_timer(struct usb_serial_port *port)return 0 ; } -static int get_serial_info (struct usb_serial_port *port, -struct serial_struct __user *retinfo) +static int get_serial_info (struct tty_struct *tty, +struct serial_struct *ss) { +struct usb_serial_port *port = tty->driver_data;struct ftdi_private *priv =usb_get_serial_port_data (port); -struct serial_struct tmp; -memset (&tmp,0 ,sizeof (tmp)); - tmp.flags = priv->flags; - tmp.baud_base = priv->baud_base; - tmp.custom_divisor = priv->custom_divisor; -if (copy_to_user (retinfo, &tmp,sizeof (*retinfo))) -return -EFAULT ; + ss->flags = priv->flags; + ss->baud_base = priv->baud_base; + ss->custom_divisor = priv->custom_divisor;return 0 ; }static int set_serial_info (struct tty_struct *tty, -struct usb_serial_port *port,struct serial_struct __user *newinfo) +struct serial_struct *ss) { +struct usb_serial_port *port = tty->driver_data;struct ftdi_private *priv =usb_get_serial_port_data (port); -struct serial_struct new_serial;struct ftdi_private old_priv; -if (copy_from_user (&new_serial, newinfo,sizeof (new_serial))) -return -EFAULT ; -mutex_lock (&priv->cfg_lock); old_priv = *priv;/* Do error checking and permission checking */ if (!capable (CAP_SYS_ADMIN )) { -if ((new_serial.flags ^ priv->flags) & ~ASYNC_USR_MASK ) { +if ((ss->flags ^ priv->flags) & ~ASYNC_USR_MASK ) {mutex_unlock (&priv->cfg_lock);return -EPERM ; } priv->flags = ((priv->flags & ~ASYNC_USR_MASK ) | - (new_serial.flags &ASYNC_USR_MASK )); - priv->custom_divisor = new_serial.custom_divisor; + (ss->flags &ASYNC_USR_MASK )); + priv->custom_divisor = ss->custom_divisor; goto check_and_exit; } -if (new_serial.baud_base != priv->baud_base) { +if (ss->baud_base != priv->baud_base) {mutex_unlock (&priv->cfg_lock);return -EINVAL ; }
@@ -1492,8 +1492,8 @@ static int set_serial_info(struct tty_struct *tty,/* Make the changes - these are privileged changes! */ priv->flags = ((priv->flags & ~ASYNC_FLAGS ) | - (new_serial.flags &ASYNC_FLAGS )); - priv->custom_divisor = new_serial.custom_divisor; + (ss->flags &ASYNC_FLAGS )); + priv->custom_divisor = ss->custom_divisor; check_and_exit:write_latency_timer (port);
@@ -1507,10 +1507,8 @@ static int set_serial_info(struct tty_struct *tty,dev_warn_ratelimited (&port->dev,"use of SPD flags is deprecated\n" );change_speed (tty, port); -mutex_unlock (&priv->cfg_lock); } -else -mutex_unlock (&priv->cfg_lock); +mutex_unlock (&priv->cfg_lock);return 0 ; }
@@ -2452,10 +2450,6 @@ static int ftdi_ioctl(struct tty_struct *tty,void __user *argp = (void __user *)arg;switch (cmd) { -case TIOCGSERIAL : -return get_serial_info (port, argp); -case TIOCSSERIAL : -return set_serial_info (tty, port, argp);case TIOCSERGETLSR :return get_lsr_info (port, argp);default :
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 47/50 gigaset: add ->compat_ioctl()
In reply to Al ViroFrom: Al Viro <[email protected]>
... and get rid of COMPAT_IOCTL() for its private ioctls
--- drivers/isdn/gigaset/interface.c | 11 +++++++++++ fs/compat_ioctl.c | 5 ----- 2 files changed, 11 insertions(+), 5 deletions(-)
drivers/isdn/gigaset/interface.c +11 -0
@@ -233,6 +233,14 @@ static int if_ioctl(struct tty_struct *tty,return retval; } +#ifdef CONFIG_COMPAT +static long if_compat_ioctl (struct tty_struct *tty, +unsigned int cmd,unsigned long arg) +{ +return if_ioctl (tty, cmd, (unsigned long )compat_ptr (arg)); +} +#endif +static int if_tiocmget (struct tty_struct *tty) {struct cardstate *cs = tty->driver_data;
@@ -472,6 +480,9 @@ static const struct tty_operations if_ops = { .open = if_open, .close = if_close, .ioctl = if_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = if_compat_ioctl, +#endif .write = if_write, .write_room = if_write_room, .chars_in_buffer = if_chars_in_buffer,
fs/compat_ioctl.c +0 -5
@@ -1021,11 +1021,6 @@ COMPATIBLE_IOCTL(CAPI_SET_FLAGS) COMPATIBLE_IOCTL(CAPI_CLR_FLAGS) COMPATIBLE_IOCTL(CAPI_NCCI_OPENCOUNT) COMPATIBLE_IOCTL(CAPI_NCCI_GETUNIT) -/* Siemens Gigaset */ -COMPATIBLE_IOCTL(GIGASET_REDIR) -COMPATIBLE_IOCTL(GIGASET_CONFIG) -COMPATIBLE_IOCTL(GIGASET_BRKCHARS) -COMPATIBLE_IOCTL(GIGASET_VERSION) /* Misc. */ COMPATIBLE_IOCTL(0x41545900) /* ATYIO_CLKR */ COMPATIBLE_IOCTL(0x41545901) /* ATYIO_CLKW */
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 18/50 cdc-acm: switch to ->[sg]et_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/usb/class/cdc-acm.c | 41 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 27 deletions(-)
drivers/usb/class/cdc-acm.c +14 -27
@@ -956,37 +956,28 @@ static int acm_tty_tiocmset(struct tty_struct *tty,return acm_set_control (acm, acm->ctrlout = newctrl); } -static int get_serial_info (struct acm *acm,struct serial_struct __user *info) +static int get_serial_info (struct tty_struct *tty,struct serial_struct *ss) { -struct serial_struct tmp; +struct acm *acm = tty->driver_data; -memset (&tmp,0 ,sizeof (tmp)); - tmp.xmit_fifo_size = acm->writesize; - tmp.baud_base =le32_to_cpu (acm->line.dwDTERate); - tmp.close_delay = acm->port.close_delay /10 ; - tmp.closing_wait = acm->port.closing_wait ==ASYNC_CLOSING_WAIT_NONE ? + ss->xmit_fifo_size = acm->writesize; + ss->baud_base =le32_to_cpu (acm->line.dwDTERate); + ss->close_delay = acm->port.close_delay /10 ; + ss->closing_wait = acm->port.closing_wait ==ASYNC_CLOSING_WAIT_NONE ?ASYNC_CLOSING_WAIT_NONE : acm->port.closing_wait /10 ; - -if (copy_to_user (info, &tmp,sizeof (tmp))) -return -EFAULT ; -else -return 0 ; +return 0 ; } -static int set_serial_info (struct acm *acm, -struct serial_struct __user *newinfo) +static int set_serial_info (struct tty_struct *tty,struct serial_struct *ss) { -struct serial_struct new_serial; +struct acm *acm = tty->driver_data;unsigned int closing_wait, close_delay;int retval =0 ; -if (copy_from_user (&new_serial, newinfo,sizeof (new_serial))) -return -EFAULT ; - - close_delay = new_serial.close_delay *10 ; - closing_wait = new_serial.closing_wait ==ASYNC_CLOSING_WAIT_NONE ? -ASYNC_CLOSING_WAIT_NONE : new_serial.closing_wait *10 ; + close_delay = ss->close_delay *10 ; + closing_wait = ss->closing_wait ==ASYNC_CLOSING_WAIT_NONE ? +ASYNC_CLOSING_WAIT_NONE : ss->closing_wait *10 ;mutex_lock (&acm->port.mutex);
@@ -1071,12 +1062,6 @@ static int acm_tty_ioctl(struct tty_struct *tty,int rv = -ENOIOCTLCMD ;switch (cmd) { -case TIOCGSERIAL :/* gets serial port data */ - rv =get_serial_info (acm, (struct serial_struct __user *) arg); -break ; -case TIOCSSERIAL : - rv =set_serial_info (acm, (struct serial_struct __user *) arg); -break ;case TIOCMIWAIT : rv =usb_autopm_get_interface (acm->control);if (rv <0 ) {
@@ -1998,6 +1983,8 @@ static const struct tty_operations acm_ops = { .set_termios = acm_tty_set_termios, .tiocmget = acm_tty_tiocmget, .tiocmset = acm_tty_tiocmset, + .get_serial = get_serial_info, + .set_serial = set_serial_info, .get_icount = acm_tty_get_icount, };
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 44/50 dgnc: don't bother with (empty) stub for TCXONC
In reply to Al ViroFrom: Al Viro <[email protected]>
for pity sake, that case is identical to their default: _and_ bears an explicit comment re leaving to ldisc. Which is what default is doing, obviously...
--- drivers/staging/dgnc/dgnc_tty.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/staging/dgnc/dgnc_tty.c +0 -5
@@ -2157,11 +2157,6 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,/* pretend we didn't recognize this */ return -ENOIOCTLCMD ; -case TCXONC : -spin_unlock_irqrestore (&ch->ch_lock, flags); -/* Make the ld do it */ -return -ENOIOCTLCMD ; -case DIGI_GETA :/* get information for ditty */ spin_unlock_irqrestore (&ch->ch_lock, flags);
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 49/50 pty: fix compat ioctls
In reply to Al ViroFrom: Al Viro <[email protected]>
pointer-taking ones need compat_ptr(); int-taking one doesn't.
--- drivers/tty/pty.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/tty/pty.c +12 -2
@@ -28,6 +28,7 @@#include <linux/mount.h> #include <linux/file.h> #include <linux/ioctl.h> +#include <linux/compat.h> #undef TTY_DEBUG_HANGUP#ifdef TTY_DEBUG_HANGUP
@@ -488,6 +489,7 @@ static int pty_bsd_ioctl(struct tty_struct *tty,return -ENOIOCTLCMD ; } +#ifdef CONFIG_COMPAT static long pty_bsd_compat_ioctl (struct tty_struct *tty,unsigned int cmd,unsigned long arg) {
@@ -495,8 +497,11 @@ static long pty_bsd_compat_ioctl(struct tty_struct *tty,* PTY ioctls don't require any special translation between 32-bit and * 64-bit userspace, they are already compatible. */ -return pty_bsd_ioctl (tty, cmd, arg); + return pty_bsd_ioctl(tty, cmd, (unsigned long)compat_ptr(arg)); } +#else +#define pty_bsd_compat_ioctl NULL +#endif static int legacy_count =CONFIG_LEGACY_PTY_COUNT ;/*
@@ -676,6 +681,7 @@ static int pty_unix98_ioctl(struct tty_struct *tty,return -ENOIOCTLCMD ; } +#ifdef CONFIG_COMPAT static long pty_unix98_compat_ioctl (struct tty_struct *tty,unsigned int cmd,unsigned long arg) {
@@ -683,8 +689,12 @@ static long pty_unix98_compat_ioctl(struct tty_struct *tty,* PTY ioctls don't require any special translation between 32-bit and * 64-bit userspace, they are already compatible. */ -return pty_unix98_ioctl (tty, cmd, arg); +return pty_unix98_ioctl (tty, cmd, + cmd == TIOCSIG ? arg : (unsigned long)compat_ptr(arg)); } +#else +#define pty_unix98_compat_ioctl NULL +#endif /** * ptm_unix98_lookup - find a pty master
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 45/50 gigaset: don't try to printk userland buffer contents
In reply to Al ViroFrom: Al Viro <[email protected]>
especially when you've just copied it in...
--- drivers/isdn/gigaset/interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/isdn/gigaset/interface.c +1 -1
@@ -206,7 +206,7 @@ static int if_ioctl(struct tty_struct *tty, ? -EFAULT :0 ;if (retval >=0 ) {gigaset_dbg_buffer (DEBUG_IF ,"GIGASET_BRKCHARS" , -6 , (const unsigned char *) arg); +6 , buf); retval = cs->ops->brkchars (cs, buf); }break ;
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 41/50 dgnc: break-related ioctls won't reach ->ioctl()
In reply to Al ViroFrom: Al Viro <[email protected]>
kill the dead code, especially since ->break_ctl() will do the right thing anyway.
--- drivers/staging/dgnc/dgnc_tty.c | 75 ----------------------------------------- 1 file changed, 75 deletions(-)
drivers/staging/dgnc/dgnc_tty.c +0 -75
@@ -2081,81 +2081,6 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,switch (cmd) {/* Here are all the standard ioctl's that we MUST implement */ - -case TCSBRK : -/* -* TCSBRK is SVID version: non-zero arg --> no break -* this behaviour is exploited by tcdrain(). -* -* According to POSIX.1 spec (7.2.2.1.2) breaks should be -* between 0.25 and 0.5 seconds so we'll ask for something -* in the middle: 0.375 seconds. -*/ - rc =tty_check_change (tty); -spin_unlock_irqrestore (&ch->ch_lock, flags); -if (rc) -return rc; - - rc = ch_bd_ops->drain (tty,0 ); -if (rc) -return -EINTR ; - -spin_lock_irqsave (&ch->ch_lock, flags); - -if (((cmd ==TCSBRK ) && (!arg)) || (cmd ==TCSBRKP )) - ch_bd_ops->send_break (ch,250 ); - -spin_unlock_irqrestore (&ch->ch_lock, flags); - -return 0 ; - -case TCSBRKP : -/* -* support for POSIX tcsendbreak() -* According to POSIX.1 spec (7.2.2.1.2) breaks should be -* between 0.25 and 0.5 seconds so we'll ask for something -* in the middle: 0.375 seconds. -*/ - rc =tty_check_change (tty); -spin_unlock_irqrestore (&ch->ch_lock, flags); -if (rc) -return rc; - - rc = ch_bd_ops->drain (tty,0 ); -if (rc) -return -EINTR ; - -spin_lock_irqsave (&ch->ch_lock, flags); - - ch_bd_ops->send_break (ch,250 ); - -spin_unlock_irqrestore (&ch->ch_lock, flags); - -return 0 ; - -case TIOCSBRK : - rc =tty_check_change (tty); -spin_unlock_irqrestore (&ch->ch_lock, flags); -if (rc) -return rc; - - rc = ch_bd_ops->drain (tty,0 ); -if (rc) -return -EINTR ; - -spin_lock_irqsave (&ch->ch_lock, flags); - - ch_bd_ops->send_break (ch,250 ); - -spin_unlock_irqrestore (&ch->ch_lock, flags); - -return 0 ; - -case TIOCCBRK : -/* Do Nothing */ -spin_unlock_irqrestore (&ch->ch_lock, flags); -return 0 ; -case TIOCGSOFTCAR :spin_unlock_irqrestore (&ch->ch_lock, flags);
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 48/50 compat_ioctl - kill keyboard ioctl handling
In reply to Al ViroFrom: Al Viro <[email protected]>
all of those are provided only by vt and s390 tty3270; both have proper ->compat_ioctl()
--- fs/compat_ioctl.c | 29 ----------------------------- 1 file changed, 29 deletions(-)
fs/compat_ioctl.c +0 -29
@@ -644,9 +644,6 @@ static int compat_ioctl_preallocate(struct file *file,static unsigned int ioctl_pointer[] = {/* compatible ioctls first */ -COMPATIBLE_IOCTL(0x4B50) /* KDGHWCLK - not in the kernel, but don't complain */ -COMPATIBLE_IOCTL(0x4B51) /* KDSHWCLK - not in the kernel, but don't complain */ -/* Little t */ COMPATIBLE_IOCTL (TIOCOUTQ )/* Little f */
@@ -663,23 +660,6 @@ COMPATIBLE_IOCTL(FIGETBSZ) COMPATIBLE_IOCTL(FIFREEZE) COMPATIBLE_IOCTL(FITHAW) COMPATIBLE_IOCTL(FITRIM) -COMPATIBLE_IOCTL(KDGETKEYCODE) -COMPATIBLE_IOCTL(KDSETKEYCODE) -COMPATIBLE_IOCTL(KDGKBTYPE) -COMPATIBLE_IOCTL(KDGETMODE) -COMPATIBLE_IOCTL(KDGKBMODE) -COMPATIBLE_IOCTL(KDGKBMETA) -COMPATIBLE_IOCTL(KDGKBENT) -COMPATIBLE_IOCTL(KDSKBENT) -COMPATIBLE_IOCTL(KDGKBSENT) -COMPATIBLE_IOCTL(KDSKBSENT) -COMPATIBLE_IOCTL(KDGKBDIACR) -COMPATIBLE_IOCTL(KDSKBDIACR) -COMPATIBLE_IOCTL(KDGKBDIACRUC) -COMPATIBLE_IOCTL(KDSKBDIACRUC) -COMPATIBLE_IOCTL(KDKBDREP) -COMPATIBLE_IOCTL(KDGKBLED) -COMPATIBLE_IOCTL(KDGETLED)#ifdef CONFIG_BLOCK /* Big S */ COMPATIBLE_IOCTL (SCSI_IOCTL_GET_IDLUN )
@@ -1185,15 +1165,6 @@ static long do_ioctl_trans(unsigned int cmd,case HOT_ADD_DISK :case SET_DISK_FAULTY :case SET_BITMAP_FILE : -/* Big K */ -case KDSIGACCEPT : -case KIOCSOUND : -case KDMKTONE : -case KDSETMODE : -case KDSKBMODE : -case KDSKBMETA : -case KDSKBLED : -case KDSETLED :return vfs_ioctl (file, cmd, arg); }
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 39/50 dgnc: TIOCM... won't reach ->ioctl()
In reply to Al ViroFrom: Al Viro <[email protected]>
bury the dead code (and ->tiocmget()/->tiocmset() are there, so I really wonder why have they kept the stuff that became unreachable with the introduction of those...)
--- drivers/staging/dgnc/dgnc_tty.c | 114 ---------------------------------------- 1 file changed, 114 deletions(-)
drivers/staging/dgnc/dgnc_tty.c +0 -114
@@ -60,10 +60,6 @@ static void dgnc_tty_unthrottle(struct tty_struct *tty);static void dgnc_tty_flush_chars (struct tty_struct *tty);static void dgnc_tty_flush_buffer (struct tty_struct *tty);static void dgnc_tty_hangup (struct tty_struct *tty); -static int dgnc_set_modem_info (struct channel_t *ch,unsigned int command, -unsigned int __user *value); -static int dgnc_get_modem_info (struct channel_t *ch, -unsigned int __user *value);static int dgnc_tty_tiocmget (struct tty_struct *tty);static int dgnc_tty_tiocmset (struct tty_struct *tty,unsigned int set,unsigned int clear);
@@ -1701,106 +1697,6 @@ static void dgnc_tty_send_xchar(struct tty_struct *tty, char c)spin_unlock_irqrestore (&ch->ch_lock, flags); } -/* Return modem signals to ld. */ -static inline int dgnc_get_mstat (struct channel_t *ch) -{ -unsigned char mstat; -unsigned long flags; -int rc; - -if (!ch) -return -ENXIO ; - -spin_lock_irqsave (&ch->ch_lock, flags); - - mstat = ch->ch_mostat | ch->ch_mistat; - -spin_unlock_irqrestore (&ch->ch_lock, flags); - - rc =0 ; - -if (mstat &UART_MCR_DTR ) - rc |=TIOCM_DTR ; -if (mstat &UART_MCR_RTS ) - rc |=TIOCM_RTS ; -if (mstat &UART_MSR_CTS ) - rc |=TIOCM_CTS ; -if (mstat &UART_MSR_DSR ) - rc |=TIOCM_DSR ; -if (mstat &UART_MSR_RI ) - rc |=TIOCM_RI ; -if (mstat &UART_MSR_DCD ) - rc |=TIOCM_CD ; - -return rc; -} - -/* Return modem signals to ld. */ -static int dgnc_get_modem_info (struct channel_t *ch, -unsigned int __user *value) -{ -return put_user (dgnc_get_mstat (ch), value); -} - -/* Set modem signals, called by ld. */ -static int dgnc_set_modem_info (struct channel_t *ch, -unsigned int command, -unsigned int __user *value) -{ -int rc; -unsigned int arg =0 ; -unsigned long flags; - - rc =get_user (arg, value); -if (rc) -return rc; - -switch (command) { -case TIOCMBIS : -if (arg &TIOCM_RTS ) - ch->ch_mostat |=UART_MCR_RTS ; - -if (arg &TIOCM_DTR ) - ch->ch_mostat |=UART_MCR_DTR ; - -break ; - -case TIOCMBIC : -if (arg &TIOCM_RTS ) - ch->ch_mostat &= ~(UART_MCR_RTS ); - -if (arg &TIOCM_DTR ) - ch->ch_mostat &= ~(UART_MCR_DTR ); - -break ; - -case TIOCMSET : - -if (arg &TIOCM_RTS ) - ch->ch_mostat |=UART_MCR_RTS ; -else - ch->ch_mostat &= ~(UART_MCR_RTS ); - -if (arg &TIOCM_DTR ) - ch->ch_mostat |=UART_MCR_DTR ; -else - ch->ch_mostat &= ~(UART_MCR_DTR ); - -break ; - -default : -return -EINVAL ; - } - -spin_lock_irqsave (&ch->ch_lock, flags); - - ch->ch_bd->bd_ops->assert_modem_signals (ch); - -spin_unlock_irqrestore (&ch->ch_lock, flags); - -return 0 ; -} -/* Ioctl to get the information for ditty. */ static int dgnc_tty_digigeta (struct tty_struct *tty,struct digi_t __user *retinfo)
@@ -2282,16 +2178,6 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,return 0 ; -case TIOCMGET : -spin_unlock_irqrestore (&ch->ch_lock, flags); -return dgnc_get_modem_info (ch, uarg); - -case TIOCMBIS : -case TIOCMBIC : -case TIOCMSET : -spin_unlock_irqrestore (&ch->ch_lock, flags); -return dgnc_set_modem_info (ch, cmd, uarg); -/* Here are any additional ioctl's that we want to implement */ case TCFLSH :
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 43/50 dgnc: leave TIOC[GS]SOFTCAR to ldisc
In reply to Al ViroFrom: Al Viro <[email protected]>
no point duplicating that in tty_operations ->ioctl()
--- drivers/staging/dgnc/dgnc_tty.c | 24 ------------------------ 1 file changed, 24 deletions(-)
drivers/staging/dgnc/dgnc_tty.c +0 -24
@@ -2080,31 +2080,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, }switch (cmd) { -/* Here are all the standard ioctl's that we MUST implement */ -case TIOCGSOFTCAR : - -spin_unlock_irqrestore (&ch->ch_lock, flags); - -return put_user (C_CLOCAL (tty) ?1 :0 , - (unsigned long __user *)arg); - -case TIOCSSOFTCAR : - -spin_unlock_irqrestore (&ch->ch_lock, flags); - rc =get_user (arg, (unsigned long __user *)arg); -if (rc) -return rc; - -spin_lock_irqsave (&ch->ch_lock, flags); - tty->termios.c_cflag = ((tty->termios.c_cflag & ~CLOCAL ) | - (arg ?CLOCAL :0 )); - ch_bd_ops->param (tty); -spin_unlock_irqrestore (&ch->ch_lock, flags); - -return 0 ; -/* Here are any additional ioctl's that we want to implement */ -case TCFLSH :/* * The linux tty driver doesn't have a flush
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 21/50 f81534: switch to ->get_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/usb/serial/f81534.c | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-)
drivers/usb/serial/f81534.c +8 -30
@@ -1139,43 +1139,21 @@ static void f81534_close(struct usb_serial_port *port)mutex_unlock (&serial_priv->urb_mutex); } -static int f81534_get_serial_info (struct usb_serial_port *port, -struct serial_struct __user *retinfo) +static int f81534_get_serial_info (struct tty_struct *tty, +struct serial_struct *ss) { +struct usb_serial_port *port = tty->driver_data;struct f81534_port_private *port_priv; -struct serial_struct tmp; port_priv =usb_get_serial_port_data (port); -memset (&tmp,0 ,sizeof (tmp)); - - tmp.type =PORT_16550A ; - tmp.port = port->port_number; - tmp.line = port->minor; - tmp.baud_base = port_priv->baud_base; - -if (copy_to_user (retinfo, &tmp,sizeof (*retinfo))) -return -EFAULT ; - + ss->type =PORT_16550A ; + ss->port = port->port_number; + ss->line = port->minor; + ss->baud_base = port_priv->baud_base;return 0 ; } -static int f81534_ioctl (struct tty_struct *tty,unsigned int cmd, -unsigned long arg) -{ -struct usb_serial_port *port = tty->driver_data; -struct serial_struct __user *buf = (struct serial_struct __user *)arg; - -switch (cmd) { -case TIOCGSERIAL : -return f81534_get_serial_info (port, buf); -default : -break ; - } - -return -ENOIOCTLCMD ; -} -static void f81534_process_per_serial_block (struct usb_serial_port *port,u8 *data) {
@@ -1581,7 +1559,7 @@ static struct usb_serial_driver f81534_device = { .break_ctl = f81534_break_ctl, .dtr_rts = f81534_dtr_rts, .process_read_urb = f81534_process_read_urb, - .ioctl = f81534_ioctl, + .get_serial = f81534_get_serial_info, .tiocmget = f81534_tiocmget, .tiocmset = f81534_tiocmset, .write_bulk_callback = f81534_write_usb_callback,
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 42/50 remove fallback to drivers for TIOCGICOUNT
In reply to Al ViroFrom: Al Viro <[email protected]>
none of them handles it anyway.
--- drivers/tty/tty_io.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/tty/tty_io.c +1 -5
@@ -2606,11 +2606,7 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case TIOCMBIS :return tty_tiocmset (tty, cmd, p);case TIOCGICOUNT : - retval =tty_tiocgicount (tty, p); -/* For the moment allow fall through to the old method */ -if (retval != -EINVAL ) -return retval; -break ; +return tty_tiocgicount (tty, p);case TCFLSH :switch (arg) {case TCIFLUSH :
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 15/50 serial_core: switch to ->[sg]et_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/tty/serial/serial_core.c | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-)
drivers/tty/serial/serial_core.c +12 -26
@@ -778,17 +778,13 @@ static int uart_get_info(struct tty_port *port, struct serial_struct *retinfo)return ret; } -static int uart_get_info_user (struct tty_port *port, -struct serial_struct __user *retinfo) +static int uart_get_info_user (struct tty_struct *tty, +struct serial_struct *ss) { -struct serial_struct tmp; - -if (uart_get_info (port, &tmp) <0 ) -return -EIO ; +struct uart_state *state = tty->driver_data; +struct tty_port *port = &state->port; -if (copy_to_user (retinfo, &tmp,sizeof (*retinfo))) -return -EFAULT ; -return 0 ; +return uart_get_info (port, ss) <0 ? -EIO :0 ; } static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
@@ -990,16 +986,13 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,return retval; } -static int uart_set_info_user (struct tty_struct *tty,struct uart_state *state, -struct serial_struct __user *newinfo) +static int uart_set_info_user (struct tty_struct *tty,struct serial_struct *ss) { -struct serial_struct new_serial; +struct uart_state *state = tty->driver_data;struct tty_port *port = &state->port;int retval; -if (copy_from_user (&new_serial, newinfo,sizeof (new_serial))) -return -EFAULT ; - +down_write (&tty->termios_rwsem);/* * This semaphore protects port->count. It is also * very useful to prevent opens. Also, take the
@@ -1008,8 +1001,9 @@ static int uart_set_info_user(struct tty_struct *tty, struct uart_state *state,* under us. */ mutex_lock (&port->mutex); - retval =uart_set_info (tty, port, state, &new_serial); + retval =uart_set_info (tty, port, state, ss);mutex_unlock (&port->mutex); +up_write (&tty->termios_rwsem);return retval; }
@@ -1325,16 +1319,6 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)* These ioctls don't rely on the hardware to be present. */ switch (cmd) { -case TIOCGSERIAL : - ret =uart_get_info_user (port, uarg); -break ; - -case TIOCSSERIAL : -down_write (&tty->termios_rwsem); - ret =uart_set_info_user (tty, state, uarg); -up_write (&tty->termios_rwsem); -break ; -case TIOCSERCONFIG :down_write (&tty->termios_rwsem); ret =uart_do_autoconfig (tty, state);
@@ -2413,6 +2397,8 @@ static const struct tty_operations uart_ops = {#endif .tiocmget = uart_tiocmget, .tiocmset = uart_tiocmset, + .set_serial = uart_set_info_user, + .get_serial = uart_get_info_user, .get_icount = uart_get_icount, #ifdef CONFIG_CONSOLE_POLL .poll_init = uart_poll_init,
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 37/50 kill capinc_tty_ioctl()
In reply to Al ViroFrom: Al Viro <[email protected]>
NULL ->ioctl() in tty_operations is treated as "returns -ENOIOCTLCMD"...
--- drivers/isdn/capi/capi.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/isdn/capi/capi.c +0 -7
@@ -1155,12 +1155,6 @@ static int capinc_tty_chars_in_buffer(struct tty_struct *tty)return mp->outbytes; } -static int capinc_tty_ioctl (struct tty_struct *tty, -unsigned int cmd,unsigned long arg) -{ -return -ENOIOCTLCMD ; -} -static void capinc_tty_set_termios (struct tty_struct *tty,struct ktermios *old) {pr_debug ("capinc_tty_set_termios\n" );
@@ -1236,7 +1230,6 @@ static const struct tty_operations capinc_ops = { .flush_chars = capinc_tty_flush_chars, .write_room = capinc_tty_write_room, .chars_in_buffer = capinc_tty_chars_in_buffer, - .ioctl = capinc_tty_ioctl, .set_termios = capinc_tty_set_termios, .throttle = capinc_tty_throttle, .unthrottle = capinc_tty_unthrottle,
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 36/50 take compat TIOC[SG]SERIAL treatment into tty_compat_ioctl()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/tty/tty_io.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/compat_ioctl.c | 67 ------------------------------------------- 2 files changed, 81 insertions(+), 67 deletions(-)
drivers/tty/tty_io.c +81 -0
@@ -2651,6 +2651,81 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) }#ifdef CONFIG_COMPAT + +struct serial_struct32 { +compat_int_t type; +compat_int_t line; +compat_uint_t port; +compat_int_t irq; +compat_int_t flags; +compat_int_t xmit_fifo_size; +compat_int_t custom_divisor; +compat_int_t baud_base; +unsigned short close_delay; +char io_type; +char reserved_char[1 ]; +compat_int_t hub6; +unsigned short closing_wait;/* time to wait before closing */ +unsigned short closing_wait2;/* no longer used... */ +compat_uint_t iomem_base; +unsigned short iomem_reg_shift; +unsigned int port_high; +/* compat_ulong_t iomap_base FIXME */ +compat_int_t reserved[1 ]; +}; + +static int compat_tty_tiocsserial (struct tty_struct *tty, +struct serial_struct32 __user *ss) +{ + static DEFINE_RATELIMIT_STATE(depr_flags, + DEFAULT_RATELIMIT_INTERVAL, + DEFAULT_RATELIMIT_BURST); +char comm[TASK_COMM_LEN ]; +struct serial_struct32 v32; +struct serial_struct v; +int flags; + +if (copy_from_user (&v32, ss,sizeof (struct serial_struct32 ))) +return -EFAULT ; + +memcpy (&v, &v32, offsetof(struct serial_struct32 , iomem_base)); + v.iomem_base =compat_ptr (v32.iomem_base); + v.iomem_reg_shift = v32.iomem_reg_shift; + v.port_high = v32.port_high; + v.iomap_base =0 ; + + flags = v.flags &ASYNC_DEPRECATED ; + +if (flags &&__ratelimit (&depr_flags)) +pr_warn ("%s: '%s' is using deprecated serial flags (with no effect): %.8x\n" , + __func__,get_task_comm (comm, current), flags); +if (!tty->ops->set_serial) +return -ENOTTY ; +return tty->ops->set_serial (tty, &v); +} + +static int compat_tty_tiocgserial (struct tty_struct *tty, +struct serial_struct32 __user *ss) +{ +struct serial_struct32 v32; +struct serial_struct v; +int err; +memset (&v,0 ,sizeof (struct serial_struct )); + +if (!tty->ops->set_serial) +return -ENOTTY ; + err = tty->ops->get_serial (tty, &v); +if (!err) { +memcpy (&v32, &v, offsetof(struct serial_struct32 , iomem_base)); + v32.iomem_base = (unsigned long )v.iomem_base >>32 ? +0xfffffff :ptr_to_compat (v.iomem_base); + v32.iomem_reg_shift = v.iomem_reg_shift; + v32.port_high = v.port_high; +if (copy_to_user (ss, &v32,sizeof (struct serial_struct32 ))) + err = -EFAULT ; + } +return err; +}static long tty_compat_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {
@@ -2736,6 +2811,12 @@ static long tty_compat_ioctl(struct file *file, unsigned int cmd,if (tty_paranoia_check (tty,file_inode (file),"tty_ioctl" ))return -EINVAL ; +switch (cmd) { +case TIOCSSERIAL : +return compat_tty_tiocsserial (tty,compat_ptr (arg)); +case TIOCGSERIAL : +return compat_tty_tiocgserial (tty,compat_ptr (arg)); + }if (tty->ops->compat_ioctl) { retval = tty->ops->compat_ioctl (tty, cmd, arg);if (retval != -ENOIOCTLCMD )
fs/compat_ioctl.c +0 -67
79 lines not on this page · raw message
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 33/50 usb_wwan: switch to ->[sg]et_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/usb/serial/option.c | 3 ++- drivers/usb/serial/usb-wwan.h | 6 +++-- drivers/usb/serial/usb_wwan.c | 63 ++++++++++++------------------------------- 3 files changed, 23 insertions(+), 49 deletions(-)
drivers/usb/serial/option.c +2 -1
@@ -1962,7 +1962,8 @@ static struct usb_serial_driver option_1port_device = { .chars_in_buffer = usb_wwan_chars_in_buffer, .tiocmget = usb_wwan_tiocmget, .tiocmset = usb_wwan_tiocmset, - .ioctl = usb_wwan_ioctl, + .get_serial = usb_wwan_get_serial_info, + .set_serial = usb_wwan_set_serial_info, .attach = option_attach, .release = option_release, .port_probe = usb_wwan_port_probe,
drivers/usb/serial/usb-wwan.h +4 -2
@@ -15,8 +15,10 @@ extern int usb_wwan_write_room(struct tty_struct *tty);extern int usb_wwan_tiocmget (struct tty_struct *tty);extern int usb_wwan_tiocmset (struct tty_struct *tty,unsigned int set,unsigned int clear); -extern int usb_wwan_ioctl (struct tty_struct *tty, -unsigned int cmd,unsigned long arg); +extern int usb_wwan_get_serial_info (struct tty_struct *tty, +struct serial_struct *ss); +extern int usb_wwan_set_serial_info (struct tty_struct *tty, +struct serial_struct *ss);extern int usb_wwan_write (struct tty_struct *tty,struct usb_serial_port *port,const unsigned char *buf,int count);extern int usb_wwan_chars_in_buffer (struct tty_struct *tty);
drivers/usb/serial/usb_wwan.c +17 -46
85 lines not on this page · raw message
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 35/50 synclink: reduce pointless checks in ->ioctl()
In reply to Al ViroFrom: Al Viro <[email protected]>
it's never getting called with TIOC[SG]SERIAL anymore (nor has it ever supported those, while we are at it)
--- drivers/char/pcmcia/synclink_cs.c | 3 +-- drivers/tty/synclink.c | 3 +-- drivers/tty/synclink_gt.c | 3 +-- drivers/tty/synclinkmp.c | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-)
drivers/char/pcmcia/synclink_cs.c +1 -2
@@ -2237,8 +2237,7 @@ static int mgslpc_ioctl(struct tty_struct *tty,if (mgslpc_paranoia_check (info, tty->name,"mgslpc_ioctl" ))return -ENODEV ; -if ((cmd !=TIOCGSERIAL ) && (cmd !=TIOCSSERIAL ) && - (cmd !=TIOCMIWAIT )) { +if (cmd !=TIOCMIWAIT ) {if (tty_io_error (tty))return -EIO ; }
drivers/tty/synclink.c +1 -2
@@ -2959,8 +2959,7 @@ static int mgsl_ioctl(struct tty_struct *tty,if (mgsl_paranoia_check (info, tty->name,"mgsl_ioctl" ))return -ENODEV ; -if ((cmd !=TIOCGSERIAL ) && (cmd !=TIOCSSERIAL ) && - (cmd !=TIOCMIWAIT )) { +if (cmd !=TIOCMIWAIT ) {if (tty_io_error (tty))return -EIO ; }
drivers/tty/synclink_gt.c +1 -2
@@ -1029,8 +1029,7 @@ static int ioctl(struct tty_struct *tty,return -ENODEV ;DBGINFO (("%s ioctl() cmd=%08X\n" , info->device_name, cmd)); -if ((cmd !=TIOCGSERIAL ) && (cmd !=TIOCSSERIAL ) && - (cmd !=TIOCMIWAIT )) { +if (cmd !=TIOCMIWAIT ) {if (tty_io_error (tty))return -EIO ; }
drivers/tty/synclinkmp.c +1 -2
@@ -1259,8 +1259,7 @@ static int ioctl(struct tty_struct *tty,if (sanity_check (info, tty->name,"ioctl" ))return -ENODEV ; -if ((cmd !=TIOCGSERIAL ) && (cmd !=TIOCSSERIAL ) && - (cmd !=TIOCMIWAIT )) { +if (cmd !=TIOCMIWAIT ) {if (tty_io_error (tty))return -EIO ; }
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 40/50 kill the rest of tty COMPAT_IOCTL() entries
In reply to Al ViroFrom: Al Viro <[email protected]>
TIOCLINUX is handled by ->compat_ioctl() in the only place that has native ->ioctl() recognizing it, TIOC{START,STOP} are simply useless these days - unrecognized compat ioctl won't spew into syslog anymore.
--- fs/compat_ioctl.c | 13 ------------- 1 file changed, 13 deletions(-)
fs/compat_ioctl.c +0 -13
@@ -647,8 +647,6 @@ static unsigned int ioctl_pointer[] = { COMPATIBLE_IOCTL(0x4B50) /* KDGHWCLK - not in the kernel, but don't complain */COMPATIBLE_IOCTL (0x4B51 )/* KDSHWCLK - not in the kernel, but don't complain */ -/* Big T */ -COMPATIBLE_IOCTL (TIOCLINUX) /* Little t */COMPATIBLE_IOCTL (TIOCOUTQ )/* Little f */
@@ -1113,17 +1111,6 @@ COMPATIBLE_IOCTL(JSIOCGAXES)COMPATIBLE_IOCTL (JSIOCGBUTTONS) COMPATIBLE_IOCTL(JSIOCGNAME(0)) -#ifdef TIOCSTART -/* - * For these two we have definitions in ioctls.h and/or termios.h on - * some architectures but no actual implemention. Some applications - * like bash call them if they are defined in the headers, so we provide - * entries here to avoid syslog message spew. - */ -COMPATIBLE_IOCTL(TIOCSTART) -COMPATIBLE_IOCTL(TIOCSTOP) -#endif -/* fat 'r' ioctls. These are handled by fat with ->compat_ioctl, but we don't want warnings on other file systems. So declare them as compatible here. */
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 38/50 isdn_tty: TCSBRK{,P} won't reach ->ioctl()
In reply to Al ViroFrom: Al Viro <[email protected]>
kill the long-dead code - it's been unreachable since 2008. Redundant, as well - generic will do exact same thing, since ->break_ctl is NULL here...
--- drivers/isdn/i4l/isdn_tty.c | 19 ------------------- 1 file changed, 19 deletions(-)
drivers/isdn/i4l/isdn_tty.c +0 -19
@@ -1412,31 +1412,12 @@ static int isdn_tty_ioctl(struct tty_struct *tty, uint cmd, ulong arg) { modem_info *info = (modem_info *) tty->driver_data; -int retval;if (isdn_tty_paranoia_check (info, tty->name,"isdn_tty_ioctl" ))return -ENODEV ;if (tty_io_error (tty))return -EIO ;switch (cmd) { -case TCSBRK :/* SVID version: non-zero arg --> no break */ -#ifdef ISDN_DEBUG_MODEM_IOCTL -printk (KERN_DEBUG "ttyI%d ioctl TCSBRK\n" , info->line); -#endif - retval =tty_check_change (tty); -if (retval) -return retval; -tty_wait_until_sent (tty,0 ); -return 0 ; -case TCSBRKP :/* support for POSIX tcsendbreak() */ -#ifdef ISDN_DEBUG_MODEM_IOCTL -printk (KERN_DEBUG "ttyI%d ioctl TCSBRKP\n" , info->line); -#endif - retval =tty_check_change (tty); -if (retval) -return retval; -tty_wait_until_sent (tty,0 ); -return 0 ;case TIOCSERGETLSR :/* Get line status register */ #ifdef ISDN_DEBUG_MODEM_IOCTL printk (KERN_DEBUG "ttyI%d ioctl TIOCSERGETLSR\n" , info->line);
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 13/50 moxa: switch to ->[sg]et_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
Pointless dead assignments in moxa_set_serial_info() killed off; they would've been a bug, if not for the fact that user-settable flags had never been used in that driver. Bogus from day 1, though...
--- drivers/tty/moxa.c | 79 +++++++++++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 39 deletions(-)
drivers/tty/moxa.c +40 -39
@@ -221,8 +221,8 @@ static int MoxaPortRxQueue(struct moxa_port *);static int MoxaPortTxFree (struct moxa_port *);static void MoxaPortTxDisable (struct moxa_port *);static void MoxaPortTxEnable (struct moxa_port *); -static int moxa_get_serial_info (struct moxa_port *,struct serial_struct __user *); -static int moxa_set_serial_info (struct moxa_port *,struct serial_struct __user *); +static int moxa_get_serial_info (struct tty_struct *,struct serial_struct *); +static int moxa_set_serial_info (struct tty_struct *,struct serial_struct *);static void MoxaSetFifo (struct moxa_port *port,int enable);/*
@@ -375,16 +375,6 @@ static int moxa_ioctl(struct tty_struct *tty, }break ; } -case TIOCGSERIAL : -mutex_lock (&ch->port.mutex); - ret =moxa_get_serial_info (ch, argp); -mutex_unlock (&ch->port.mutex); -break ; -case TIOCSSERIAL : -mutex_lock (&ch->port.mutex); - ret =moxa_set_serial_info (ch, argp); -mutex_unlock (&ch->port.mutex); -break ;default : ret = -ENOIOCTLCMD ; }
@@ -415,6 +405,8 @@ static const struct tty_operations moxa_ops = { .break_ctl = moxa_break_ctl, .tiocmget = moxa_tiocmget, .tiocmset = moxa_tiocmset, + .set_serial = moxa_set_serial_info, + .get_serial = moxa_get_serial_info, };static const struct tty_port_operations moxa_port_ops = {
@@ -2034,46 +2026,55 @@ static void MoxaPortTxEnable(struct moxa_port *port)moxafunc (port->tableAddr, FC_SetXonState, Magic_code); } -static int moxa_get_serial_info (struct moxa_port *info, -struct serial_struct __user *retinfo) +static int moxa_get_serial_info (struct tty_struct *tty, +struct serial_struct *ss) { -struct serial_struct tmp = { - .type = info->type, - .line = info->port.tty->index, - .flags = info->port.flags, - .baud_base =921600 , - .close_delay = info->port.close_delay - }; -return copy_to_user (retinfo, &tmp,sizeof (*retinfo)) ? -EFAULT :0 ; +struct moxa_port *info = tty->driver_data; + +if (tty->index ==MAX_PORTS ) +return -EINVAL ; +if (!info) +return -ENODEV ; +mutex_lock (&info->port.mutex); + ss->type = info->type, + ss->line = info->port.tty->index, + ss->flags = info->port.flags, + ss->baud_base =921600 , + ss->close_delay = info->port.close_delay; +mutex_unlock (&info->port.mutex); +return 0 ; } -static int moxa_set_serial_info (struct moxa_port *info, -struct serial_struct __user *new_info) +static int moxa_set_serial_info (struct tty_struct *tty, +struct serial_struct *ss) { -struct serial_struct new_serial; +struct moxa_port *info = tty->driver_data; -if (copy_from_user (&new_serial, new_info,sizeof (new_serial))) -return -EFAULT ; +if (tty->index ==MAX_PORTS ) +return -EINVAL ; +if (!info) +return -ENODEV ; -if (new_serial.irq !=0 || new_serial.port !=0 || - new_serial.custom_divisor !=0 || - new_serial.baud_base !=921600 ) +if (ss->irq !=0 || ss->port !=0 || + ss->custom_divisor !=0 || + ss->baud_base !=921600 )return -EPERM ; +mutex_lock (&info->port.mutex);if (!capable (CAP_SYS_ADMIN )) { -if (((new_serial.flags & ~ASYNC_USR_MASK ) != - (info->port.flags & ~ASYNC_USR_MASK ))) +if (((ss->flags & ~ASYNC_USR_MASK ) != + (info->port.flags & ~ASYNC_USR_MASK ))) { +mutex_unlock (&info->port.mutex);return -EPERM ; - }else - info->port.close_delay = new_serial.close_delay *HZ /100 ; - - new_serial.flags = (new_serial.flags & ~ASYNC_FLAGS ); - new_serial.flags |= (info->port.flags &ASYNC_FLAGS ); + } + } + info->port.close_delay = ss->close_delay *HZ /100 ; -MoxaSetFifo (info, new_serial.type ==PORT_16550A ); +MoxaSetFifo (info, ss->type ==PORT_16550A ); - info->type = new_serial.type; + info->type = ss->type; +mutex_unlock (&info->port.mutex);return 0 ; }
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 17/50 usb-serial: begin switching to ->[sg]et_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
add such methods for usb_serial_driver, provide tty_operations ->[sg]et_serial() calling those. For now the lack of methods in driver means ENOIOCTLCMD from usb-serial ->[sg]et_serial(), making tty_ioctl() fall back to calling ->ioctl(). Once all drivers are converted, we'll be returning -ENOTTY instead, completing the switchover.
--- drivers/usb/serial/usb-serial.c | 18 ++++++++++++++++++ include/linux/usb/serial.h | 2 ++ 2 files changed, 20 insertions(+)
drivers/usb/serial/usb-serial.c +18 -0
@@ -396,6 +396,22 @@ static void serial_unthrottle(struct tty_struct *tty) port->serial->type->unthrottle (tty); } +static int serial_get_serial (struct tty_struct *tty,struct serial_struct *ss) +{ +struct usb_serial_port *port = tty->driver_data; +if (port->serial->type->get_serial) +return port->serial->type->get_serial (tty, ss); +return -ENOIOCTLCMD ; +} + +static int serial_set_serial (struct tty_struct *tty,struct serial_struct *ss) +{ +struct usb_serial_port *port = tty->driver_data; +if (port->serial->type->set_serial) +return port->serial->type->get_serial (tty, ss); +return -ENOIOCTLCMD ; +} +static int serial_ioctl (struct tty_struct *tty,unsigned int cmd,unsigned long arg) {
@@ -1177,6 +1193,8 @@ static const struct tty_operations serial_ops = { .tiocmget = serial_tiocmget, .tiocmset = serial_tiocmset, .get_icount = serial_get_icount, + .set_serial = serial_set_serial, + .get_serial = serial_get_serial, .cleanup = serial_cleanup, .install = serial_install, .proc_show = serial_proc_show,
include/linux/usb/serial.h +2 -0
@@ -285,6 +285,8 @@ struct usb_serial_driver {int (*write_room)(struct tty_struct *tty);int (*ioctl)(struct tty_struct *tty,unsigned int cmd,unsigned long arg); +int (*get_serial)(struct tty_struct *tty,struct serial_struct *ss); +int (*set_serial)(struct tty_struct *tty,struct serial_struct *ss);void (*set_termios)(struct tty_struct *tty,struct usb_serial_port *port,struct ktermios *old);void (*break_ctl)(struct tty_struct *tty,int break_state);
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 20/50 f81232: switch to ->get_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/usb/serial/f81232.c | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-)
drivers/usb/serial/f81232.c +8 -28
@@ -583,36 +583,16 @@ static int f81232_carrier_raised(struct usb_serial_port *port)return 0 ; } -static int f81232_get_serial_info (struct usb_serial_port *port, -unsigned long arg) -{ -struct serial_struct ser; - -memset (&ser,0 ,sizeof (ser)); - - ser.type =PORT_16550A ; - ser.line = port->minor; - ser.port = port->port_number; - ser.baud_base =F81232_MAX_BAUDRATE ; - -if (copy_to_user ((void __user *)arg, &ser,sizeof (ser))) -return -EFAULT ; - -return 0 ; -} - -static int f81232_ioctl (struct tty_struct *tty, -unsigned int cmd,unsigned long arg) +static int f81232_get_serial_info (struct tty_struct *tty, +struct serial_struct *ss) {struct usb_serial_port *port = tty->driver_data; -switch (cmd) { -case TIOCGSERIAL : -return f81232_get_serial_info (port, arg); -default : -break ; - } -return -ENOIOCTLCMD ; + ss->type =PORT_16550A ; + ss->line = port->minor; + ss->port = port->port_number; + ss->baud_base =F81232_MAX_BAUDRATE ; +return 0 ; }static void f81232_interrupt_work (struct work_struct *work)
@@ -665,7 +645,7 @@ static struct usb_serial_driver f81232_device = { .close = f81232_close, .dtr_rts = f81232_dtr_rts, .carrier_raised = f81232_carrier_raised, - .ioctl = f81232_ioctl, + .get_serial = f81232_get_serial_info, .break_ctl = f81232_break_ctl, .set_termios = f81232_set_termios, .tiocmget = f81232_tiocmget,
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 31/50 ti_usb_3410_5052: switch to ->[sg]et_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/usb/serial/ti_usb_3410_5052.c | 74 ++++++++++++----------------------- 1 file changed, 24 insertions(+), 50 deletions(-)
drivers/usb/serial/ti_usb_3410_5052.c +24 -50
@@ -313,8 +313,6 @@ static int ti_chars_in_buffer(struct tty_struct *tty);static bool ti_tx_empty (struct usb_serial_port *port);static void ti_throttle (struct tty_struct *tty);static void ti_unthrottle (struct tty_struct *tty); -static int ti_ioctl (struct tty_struct *tty, -unsigned int cmd,unsigned long arg);static void ti_set_termios (struct tty_struct *tty,struct usb_serial_port *port,struct ktermios *old_termios);static int ti_tiocmget (struct tty_struct *tty);
@@ -330,10 +328,10 @@ static void ti_recv(struct usb_serial_port *port, unsigned char *data,static void ti_send (struct ti_port *tport);static int ti_set_mcr (struct ti_port *tport,unsigned int mcr);static int ti_get_lsr (struct ti_port *tport,u8 *lsr); -static int ti_get_serial_info (struct ti_port *tport, -struct serial_struct __user *ret_arg); -static int ti_set_serial_info (struct tty_struct *tty,struct ti_port *tport, -struct serial_struct __user *new_arg); +static int ti_get_serial_info (struct tty_struct *tty, +struct serial_struct *ss); +static int ti_set_serial_info (struct tty_struct *tty, +struct serial_struct *ss);static void ti_handle_new_msr (struct ti_port *tport,u8 msr);static void ti_stop_read (struct ti_port *tport,struct tty_struct *tty);
@@ -436,7 +434,8 @@ static struct usb_serial_driver ti_1port_device = { .tx_empty = ti_tx_empty, .throttle = ti_throttle, .unthrottle = ti_unthrottle, - .ioctl = ti_ioctl, + .get_serial = ti_get_serial_info, + .set_serial = ti_set_serial_info, .set_termios = ti_set_termios, .tiocmget = ti_tiocmget, .tiocmset = ti_tiocmset,
@@ -469,7 +468,8 @@ static struct usb_serial_driver ti_2port_device = { .tx_empty = ti_tx_empty, .throttle = ti_throttle, .unthrottle = ti_unthrottle, - .ioctl = ti_ioctl, + .get_serial = ti_get_serial_info, + .set_serial = ti_set_serial_info, .set_termios = ti_set_termios, .tiocmget = ti_tiocmget, .tiocmset = ti_tiocmset,
@@ -902,24 +902,6 @@ static void ti_unthrottle(struct tty_struct *tty) } } -static int ti_ioctl (struct tty_struct *tty, -unsigned int cmd,unsigned long arg) -{ -struct usb_serial_port *port = tty->driver_data; -struct ti_port *tport =usb_get_serial_port_data (port); - -switch (cmd) { -case TIOCGSERIAL : -return ti_get_serial_info (tport, - (struct serial_struct __user *)arg); -case TIOCSSERIAL : -return ti_set_serial_info (tty, tport, - (struct serial_struct __user *)arg); - } -return -ENOIOCTLCMD ; -} - -static void ti_set_termios (struct tty_struct *tty,struct usb_serial_port *port,struct ktermios *old_termios) {
@@ -1417,45 +1399,37 @@ static int ti_get_lsr(struct ti_port *tport, u8 *lsr) } -static int ti_get_serial_info (struct ti_port *tport, -struct serial_struct __user *ret_arg) +static int ti_get_serial_info (struct tty_struct *tty, +struct serial_struct *ss) { -struct usb_serial_port *port = tport->tp_port; -struct serial_struct ret_serial; +struct usb_serial_port *port = tty->driver_data; +struct ti_port *tport =usb_get_serial_port_data (port);unsigned cwait; cwait = port->port.closing_wait;if (cwait !=ASYNC_CLOSING_WAIT_NONE ) cwait =jiffies_to_msecs (cwait) /10 ; -memset (&ret_serial,0 ,sizeof (ret_serial)); - - ret_serial.type =PORT_16550A ; - ret_serial.line = port->minor; - ret_serial.port = port->port_number; - ret_serial.xmit_fifo_size =kfifo_size (&port->write_fifo); - ret_serial.baud_base = tport->tp_tdev->td_is_3410 ?921600 :460800 ; - ret_serial.closing_wait = cwait; - -if (copy_to_user (ret_arg, &ret_serial,sizeof (*ret_arg))) -return -EFAULT ; - + ss->type =PORT_16550A ; + ss->line = port->minor; + ss->port = port->port_number; + ss->xmit_fifo_size =kfifo_size (&port->write_fifo); + ss->baud_base = tport->tp_tdev->td_is_3410 ?921600 :460800 ; + ss->closing_wait = cwait;return 0 ; } -static int ti_set_serial_info (struct tty_struct *tty,struct ti_port *tport, -struct serial_struct __user *new_arg) +static int ti_set_serial_info (struct tty_struct *tty, +struct serial_struct *ss) { -struct serial_struct new_serial; +struct usb_serial_port *port = tty->driver_data; +struct ti_port *tport =usb_get_serial_port_data (port);unsigned cwait; -if (copy_from_user (&new_serial, new_arg,sizeof (new_serial))) -return -EFAULT ; - - cwait = new_serial.closing_wait; + cwait = ss->closing_wait;if (cwait !=ASYNC_CLOSING_WAIT_NONE ) - cwait =msecs_to_jiffies (10 * new_serial.closing_wait); + cwait =msecs_to_jiffies (10 * ss->closing_wait); tport->tp_port->port.closing_wait = cwait;
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 30/50 ssu100: switch to ->get_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/usb/serial/ssu100.c | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-)
drivers/usb/serial/ssu100.c +11 -31
@@ -331,39 +331,19 @@ static int ssu100_open(struct tty_struct *tty, struct usb_serial_port *port)return usb_serial_generic_open (tty, port); } -static int get_serial_info (struct usb_serial_port *port, -struct serial_struct __user *retinfo) -{ -struct serial_struct tmp; - -memset (&tmp,0 ,sizeof (tmp)); - tmp.line = port->minor; - tmp.port =0 ; - tmp.irq =0 ; - tmp.xmit_fifo_size = port->bulk_out_size; - tmp.baud_base =9600 ; - tmp.close_delay =5 *HZ ; - tmp.closing_wait =30 *HZ ; - -if (copy_to_user (retinfo, &tmp,sizeof (*retinfo))) -return -EFAULT ; -return 0 ; -} - -static int ssu100_ioctl (struct tty_struct *tty, -unsigned int cmd,unsigned long arg) +static int get_serial_info (struct tty_struct *tty, +struct serial_struct *ss) {struct usb_serial_port *port = tty->driver_data; -switch (cmd) { -case TIOCGSERIAL : -return get_serial_info (port, - (struct serial_struct __user *) arg); -default : -break ; - } - -return -ENOIOCTLCMD ; + ss->line = port->minor; + ss->port =0 ; + ss->irq =0 ; + ss->xmit_fifo_size = port->bulk_out_size; + ss->baud_base =9600 ; + ss->close_delay =5 *HZ ; + ss->closing_wait =30 *HZ ; +return 0 ; }static int ssu100_attach (struct usb_serial *serial)
@@ -566,7 +546,7 @@ static struct usb_serial_driver ssu100_device = { .tiocmset = ssu100_tiocmset, .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, - .ioctl = ssu100_ioctl, + .get_serial = get_serial_info, .set_termios = ssu100_set_termios, };
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 29/50 quatech2: switch to ->get_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/usb/serial/quatech2.c | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-)
drivers/usb/serial/quatech2.c +11 -31
@@ -453,39 +453,19 @@ static void qt2_disconnect(struct usb_serial *serial)usb_kill_urb (serial_priv->read_urb); } -static int get_serial_info (struct usb_serial_port *port, -struct serial_struct __user *retinfo) -{ -struct serial_struct tmp; - -memset (&tmp,0 ,sizeof (tmp)); - tmp.line = port->minor; - tmp.port =0 ; - tmp.irq =0 ; - tmp.xmit_fifo_size = port->bulk_out_size; - tmp.baud_base =9600 ; - tmp.close_delay =5 *HZ ; - tmp.closing_wait =30 *HZ ; - -if (copy_to_user (retinfo, &tmp,sizeof (*retinfo))) -return -EFAULT ; -return 0 ; -} - -static int qt2_ioctl (struct tty_struct *tty, -unsigned int cmd,unsigned long arg) +static int get_serial_info (struct tty_struct *tty, +struct serial_struct *ss) {struct usb_serial_port *port = tty->driver_data; -switch (cmd) { -case TIOCGSERIAL : -return get_serial_info (port, - (struct serial_struct __user *)arg); -default : -break ; - } - -return -ENOIOCTLCMD ; + ss->line = port->minor; + ss->port =0 ; + ss->irq =0 ; + ss->xmit_fifo_size = port->bulk_out_size; + ss->baud_base =9600 ; + ss->close_delay =5 *HZ ; + ss->closing_wait =30 *HZ ; +return 0 ; }static void qt2_process_status (struct usb_serial_port *port,unsigned char *ch)
@@ -1013,7 +993,7 @@ static struct usb_serial_driver qt2_device = { .tiocmset = qt2_tiocmset, .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, - .ioctl = qt2_ioctl, + .get_serial = get_serial_info, .set_termios = qt2_set_termios, };
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 27/50 opticon: switch to ->get_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/usb/serial/opticon.c | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-)
drivers/usb/serial/opticon.c +12 -31
@@ -328,42 +328,23 @@ static int opticon_tiocmset(struct tty_struct *tty,return 0 ; } -static int get_serial_info (struct usb_serial_port *port, -struct serial_struct __user *serial) +static int get_serial_info (struct tty_struct *tty, +struct serial_struct *ss) { -struct serial_struct tmp; - -memset (&tmp,0x00 ,sizeof (tmp)); +struct usb_serial_port *port = tty->driver_data;/* fake emulate a 16550 uart to make userspace code happy */ - tmp.type =PORT_16550A ; - tmp.line = port->minor; - tmp.port =0 ; - tmp.irq =0 ; - tmp.xmit_fifo_size =1024 ; - tmp.baud_base =9600 ; - tmp.close_delay =5 *HZ ; - tmp.closing_wait =30 *HZ ; - -if (copy_to_user (serial, &tmp,sizeof (*serial))) -return -EFAULT ; + ss->type =PORT_16550A ; + ss->line = port->minor; + ss->port =0 ; + ss->irq =0 ; + ss->xmit_fifo_size =1024 ; + ss->baud_base =9600 ; + ss->close_delay =5 *HZ ; + ss->closing_wait =30 *HZ ;return 0 ; } -static int opticon_ioctl (struct tty_struct *tty, -unsigned int cmd,unsigned long arg) -{ -struct usb_serial_port *port = tty->driver_data; - -switch (cmd) { -case TIOCGSERIAL : -return get_serial_info (port, - (struct serial_struct __user *)arg); - } - -return -ENOIOCTLCMD ; -} -static int opticon_port_probe (struct usb_serial_port *port) {struct opticon_private *priv;
@@ -404,7 +385,7 @@ static struct usb_serial_driver opticon_device = { .write_room = opticon_write_room, .throttle = usb_serial_generic_throttle, .unthrottle = usb_serial_generic_unthrottle, - .ioctl = opticon_ioctl, + .get_serial = get_serial_info, .tiocmget = opticon_tiocmget, .tiocmset = opticon_tiocmset, .process_read_urb = opticon_process_read_urb,
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 26/50 mos7840: switch to ->get_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/usb/serial/mos7840.c | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-)
drivers/usb/serial/mos7840.c +17 -23
@@ -1931,27 +1931,27 @@ static int mos7840_get_lsr_info(struct tty_struct *tty,* function to get information about serial port *****************************************************************************/ -static int mos7840_get_serial_info (struct moschip_port *mos7840_port, -struct serial_struct __user *retinfo) +static int mos7840_get_serial_info (struct tty_struct *tty, +struct serial_struct *ss) { -struct serial_struct tmp; +struct usb_serial_port *port = tty->driver_data; +struct moschip_port *mos7840_port; -if (mos7840_port ==NULL ) +if (mos7840_port_paranoia_check (port, __func__))return -1 ; -memset (&tmp,0 ,sizeof (tmp)); - - tmp.type =PORT_16550A ; - tmp.line = mos7840_port->port->minor; - tmp.port = mos7840_port->port->port_number; - tmp.irq =0 ; - tmp.xmit_fifo_size =NUM_URBS *URB_TRANSFER_BUFFER_SIZE ; - tmp.baud_base =9600 ; - tmp.close_delay =5 *HZ ; - tmp.closing_wait =30 *HZ ; + mos7840_port =mos7840_get_port_private (port); +if (mos7840_port ==NULL ) +return -1 ; -if (copy_to_user (retinfo, &tmp,sizeof (*retinfo))) -return -EFAULT ; + ss->type =PORT_16550A ; + ss->line = mos7840_port->port->minor; + ss->port = mos7840_port->port->port_number; + ss->irq =0 ; + ss->xmit_fifo_size =NUM_URBS *URB_TRANSFER_BUFFER_SIZE ; + ss->baud_base =9600 ; + ss->close_delay =5 *HZ ; + ss->closing_wait =30 *HZ ;return 0 ; }
@@ -1982,13 +1982,6 @@ static int mos7840_ioctl(struct tty_struct *tty,dev_dbg (&port->dev,"%s TIOCSERGETLSR\n" , __func__);return mos7840_get_lsr_info (tty, argp); -case TIOCGSERIAL : -dev_dbg (&port->dev,"%s TIOCGSERIAL\n" , __func__); -return mos7840_get_serial_info (mos7840_port, argp); - -case TIOCSSERIAL : -dev_dbg (&port->dev,"%s TIOCSSERIAL\n" , __func__); -break ;default :break ; }
@@ -2376,6 +2369,7 @@ static struct usb_serial_driver moschip7840_4port_device = { .calc_num_ports = mos7840_calc_num_ports, .probe = mos7840_probe, .ioctl = mos7840_ioctl, + .get_serial = mos7840_get_serial_info, .set_termios = mos7840_set_termios, .break_ctl = mos7840_break, .tiocmget = mos7840_tiocmget,
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 34/50 complete ->[sg]et_serial() switchover
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/tty/tty_io.c | 12 ++++-------- drivers/usb/serial/usb-serial.c | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-)
drivers/tty/tty_io.c +4 -8
@@ -2474,7 +2474,7 @@ static int tty_tiocsserial(struct tty_struct *tty, struct serial_struct __user *pr_warn ("%s: '%s' is using deprecated serial flags (with no effect): %.8x\n" , __func__,get_task_comm (comm, current), flags);if (!tty->ops->set_serial) -return -ENOIOCTLCMD ; +return -ENOTTY ;return tty->ops->set_serial (tty, &v); }
@@ -2485,7 +2485,7 @@ static int tty_tiocgserial(struct tty_struct *tty, struct serial_struct __user *memset (&v,0 ,sizeof (struct serial_struct ));if (!tty->ops->set_serial) -return -ENOIOCTLCMD ; +return -ENOTTY ; err = tty->ops->get_serial (tty, &v);if (!err &©_to_user (ss, &v,sizeof (struct serial_struct ))) err = -EFAULT ;
@@ -2621,13 +2621,9 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) }break ;case TIOCSSERIAL : - retval =tty_tiocsserial (tty, p); -if (retval != -ENOIOCTLCMD ) -return retval; +return tty_tiocsserial (tty, p);case TIOCGSERIAL : - retval =tty_tiocgserial (tty, p); -if (retval != -ENOIOCTLCMD ) -return retval; +return tty_tiocgserial (tty, p);case TIOCGPTPEER :/* Special because the struct file is needed */ return ptm_open_peer (file, tty, (int )arg);
drivers/usb/serial/usb-serial.c +2 -2
@@ -401,7 +401,7 @@ static int serial_get_serial(struct tty_struct *tty, struct serial_struct *ss)struct usb_serial_port *port = tty->driver_data;if (port->serial->type->get_serial)return port->serial->type->get_serial (tty, ss); -return -ENOIOCTLCMD ; +return -ENOTTY ; }static int serial_set_serial (struct tty_struct *tty,struct serial_struct *ss)
@@ -409,7 +409,7 @@ static int serial_set_serial(struct tty_struct *tty, struct serial_struct *ss)struct usb_serial_port *port = tty->driver_data;if (port->serial->type->set_serial)return port->serial->type->get_serial (tty, ss); -return -ENOIOCTLCMD ; +return -ENOTTY ; } static int serial_ioctl(struct tty_struct *tty,
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 32/50 whiteheat: switch to ->get_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
... and fix the return value - on success it used to have ioctl(2) fill the user-supplied struct serial_struct and return -ENOTTY.
--- drivers/usb/serial/whiteheat.c | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-)
drivers/usb/serial/whiteheat.c +15 -27
@@ -83,8 +83,8 @@ static int whiteheat_port_remove(struct usb_serial_port *port);static int whiteheat_open (struct tty_struct *tty,struct usb_serial_port *port);static void whiteheat_close (struct usb_serial_port *port); -static int whiteheat_ioctl (struct tty_struct *tty, -unsigned int cmd,unsigned long arg); +static int whiteheat_get_serial (struct tty_struct *tty, +struct serial_struct *ss);static void whiteheat_set_termios (struct tty_struct *tty,struct usb_serial_port *port,struct ktermios *old);static int whiteheat_tiocmget (struct tty_struct *tty);
@@ -120,7 +120,7 @@ static struct usb_serial_driver whiteheat_device = { .port_remove = whiteheat_port_remove, .open = whiteheat_open, .close = whiteheat_close, - .ioctl = whiteheat_ioctl, + .get_serial = whiteheat_get_serial, .set_termios = whiteheat_set_termios, .break_ctl = whiteheat_break_ctl, .tiocmget = whiteheat_tiocmget,
@@ -442,33 +442,21 @@ static int whiteheat_tiocmset(struct tty_struct *tty, } -static int whiteheat_ioctl (struct tty_struct *tty, -unsigned int cmd,unsigned long arg) +static int whiteheat_get_serial (struct tty_struct *tty, +struct serial_struct *ss) {struct usb_serial_port *port = tty->driver_data; -struct serial_struct serstruct; -void __user *user_arg = (void __user *)arg; - -switch (cmd) { -case TIOCGSERIAL : -memset (&serstruct,0 ,sizeof (serstruct)); - serstruct.type =PORT_16654 ; - serstruct.line = port->minor; - serstruct.port = port->port_number; - serstruct.xmit_fifo_size =kfifo_size (&port->write_fifo); - serstruct.custom_divisor =0 ; - serstruct.baud_base =460800 ; - serstruct.close_delay =CLOSING_DELAY ; - serstruct.closing_wait =CLOSING_DELAY ; - -if (copy_to_user (user_arg, &serstruct,sizeof (serstruct))) -return -EFAULT ; -break ; -default : -break ; - } -return -ENOIOCTLCMD ; + ss->type =PORT_16654 ; + ss->line = port->minor; + ss->port = port->port_number; + ss->xmit_fifo_size =kfifo_size (&port->write_fifo); + ss->custom_divisor =0 ; + ss->baud_base =460800 ; + ss->close_delay =CLOSING_DELAY ; + ss->closing_wait =CLOSING_DELAY ; + +return 0 ; }
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 25/50 mos7720: switch to ->get_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/usb/serial/mos7720.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-)
drivers/usb/serial/mos7720.c +16 -22
@@ -1786,24 +1786,22 @@ static int mos7720_tiocmset(struct tty_struct *tty,return 0 ; } -static int get_serial_info (struct moschip_port *mos7720_port, -struct serial_struct __user *retinfo) +static int get_serial_info (struct tty_struct *tty, +struct serial_struct *ss) { -struct serial_struct tmp; - -memset (&tmp,0 ,sizeof (tmp)); - - tmp.type =PORT_16550A ; - tmp.line = mos7720_port->port->minor; - tmp.port = mos7720_port->port->port_number; - tmp.irq =0 ; - tmp.xmit_fifo_size =NUM_URBS *URB_TRANSFER_BUFFER_SIZE ; - tmp.baud_base =9600 ; - tmp.close_delay =5 *HZ ; - tmp.closing_wait =30 *HZ ; - -if (copy_to_user (retinfo, &tmp,sizeof (*retinfo))) -return -EFAULT ; +struct usb_serial_port *port = tty->driver_data; +struct moschip_port *mos7720_port; + mos7720_port =usb_get_serial_port_data (port); +if (mos7720_port ==NULL ) +return -ENODEV ; + ss->type =PORT_16550A ; + ss->line = mos7720_port->port->minor; + ss->port = mos7720_port->port->port_number; + ss->irq =0 ; + ss->xmit_fifo_size =NUM_URBS *URB_TRANSFER_BUFFER_SIZE ; + ss->baud_base =9600 ; + ss->close_delay =5 *HZ ; + ss->closing_wait =30 *HZ ;return 0 ; }
@@ -1822,11 +1820,6 @@ static int mos7720_ioctl(struct tty_struct *tty,dev_dbg (&port->dev,"%s TIOCSERGETLSR\n" , __func__);return get_lsr_info (tty, mos7720_port, (unsigned int __user *)arg); - -case TIOCGSERIAL : -dev_dbg (&port->dev,"%s TIOCGSERIAL\n" , __func__); -return get_serial_info (mos7720_port, - (struct serial_struct __user *)arg); }return -ENOIOCTLCMD ;
@@ -1963,6 +1956,7 @@ static struct usb_serial_driver moschip7720_2port_driver = { .ioctl = mos7720_ioctl, .tiocmget = mos7720_tiocmget, .tiocmset = mos7720_tiocmset, + .get_serial = get_serial_info, .set_termios = mos7720_set_termios, .write = mos7720_write, .write_room = mos7720_write_room,
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 5/50 tty_ioctl(): start taking TIOC[SG]SERIAL into separate methods
In reply to Al ViroFrom: Al Viro <[email protected]>
->set_serial() and ->get_serial() resp., both taking tty and a kernel pointer to serial_struct.
--- drivers/tty/tty_io.c | 36 ++++++++++++++++++++++++++++++------ include/linux/tty_driver.h | 3 +++ 2 files changed, 33 insertions(+), 6 deletions(-)
drivers/tty/tty_io.c +30 -6
@@ -97,6 +97,7 @@#include <linux/seq_file.h> #include <linux/serial.h> #include <linux/ratelimit.h> +#include <linux/compat.h> #include <linux/uaccess.h>
@@ -2455,22 +2456,40 @@ static int tty_tiocgicount(struct tty_struct *tty, void __user *arg)return 0 ; } -static void tty_warn_deprecated_flags (struct serial_struct __user *ss) +static int tty_tiocsserial (struct tty_struct *tty,struct serial_struct __user *ss) { static DEFINE_RATELIMIT_STATE(depr_flags, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST);char comm[TASK_COMM_LEN ]; +struct serial_struct v;int flags; -if (get_user (flags, &ss->flags)) -return ; +if (copy_from_user (&v, ss,sizeof (struct serial_struct ))) +return -EFAULT ; - flags &=ASYNC_DEPRECATED ; + flags = v.flags &ASYNC_DEPRECATED ;if (flags &&__ratelimit (&depr_flags))pr_warn ("%s: '%s' is using deprecated serial flags (with no effect): %.8x\n" , __func__,get_task_comm (comm, current), flags); +if (!tty->ops->set_serial) +return -ENOIOCTLCMD ; +return tty->ops->set_serial (tty, &v); +} + +static int tty_tiocgserial (struct tty_struct *tty,struct serial_struct __user *ss) +{ +struct serial_struct v; +int err; +memset (&v,0 ,sizeof (struct serial_struct )); + +if (!tty->ops->set_serial) +return -ENOIOCTLCMD ; + err = tty->ops->get_serial (tty, &v); +if (!err &©_to_user (ss, &v,sizeof (struct serial_struct ))) + err = -EFAULT ; +return err; }/*
@@ -2602,8 +2621,13 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) }break ;case TIOCSSERIAL : -tty_warn_deprecated_flags (p); -break ; + retval =tty_tiocsserial (tty, p); +if (retval != -ENOIOCTLCMD ) +return retval; +case TIOCGSERIAL : + retval =tty_tiocgserial (tty, p); +if (retval != -ENOIOCTLCMD ) +return retval;case TIOCGPTPEER :/* Special because the struct file is needed */ return ptm_open_peer (file, tty, (int )arg);
include/linux/tty_driver.h +3 -0
@@ -249,6 +249,7 @@struct tty_struct ;struct tty_driver ;struct serial_icounter_struct ; +struct serial_struct ;struct tty_operations { struct tty_struct * (*lookup)(struct tty_driver *driver,
@@ -287,6 +288,8 @@ struct tty_operations {int (*set_termiox)(struct tty_struct *tty,struct termiox *tnew);int (*get_icount)(struct tty_struct *tty,struct serial_icounter_struct *icount); +int (*get_serial)(struct tty_struct *tty,struct serial_struct *p); +int (*set_serial)(struct tty_struct *tty,struct serial_struct *p);void (*show_fdinfo)(struct tty_struct *tty,struct seq_file *m);#ifdef CONFIG_CONSOLE_POLL int (*poll_init)(struct tty_driver *driver,int line,char *options);
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 3/50 tty_ioctl(): drop FIONBIO handling
In reply to Al ViroFrom: Al Viro <[email protected]>
That code had been live for 11 weeks back in 1992, but it had been 26 years since sys_ioctl() began handling FIONBIO on its own. Time to to bury the body, already...
--- drivers/tty/tty_io.c | 30 ------------------------------ 1 file changed, 30 deletions(-)
drivers/tty/tty_io.c +0 -30
@@ -2288,34 +2288,6 @@ static int tioccons(struct file *file) }/** -* fionbio - non blocking ioctl -* @file: file to set blocking value -* @p: user parameter -* -* Historical tty interfaces had a blocking control ioctl before -* the generic functionality existed. This piece of history is preserved -* in the expected tty API of posix OS's. -* -* Locking: none, the open file handle ensures it won't go away. -*/ - -static int fionbio (struct file *file,int __user *p) -{ -int nonblock; - -if (get_user (nonblock, p)) -return -EFAULT ; - -spin_lock (&file->f_lock); -if (nonblock) - file->f_flags |=O_NONBLOCK ; -else - file->f_flags &= ~O_NONBLOCK ; -spin_unlock (&file->f_lock); -return 0 ; -} - -/** * tiocsetd - set line discipline * @tty: tty device * @p: pointer to user data
@@ -2561,8 +2533,6 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)return tiocswinsz (real_tty, p);case TIOCCONS :return real_tty != tty ? -EINVAL :tioccons (file); -case FIONBIO : -return fionbio (file, p);case TIOCEXCL :set_bit (TTY_EXCLUSIVE , &tty->flags);return 0 ;
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 2/50 move compat handling of tty ioctls to tty_compat_ioctl()
In reply to Al ViroFrom: Al Viro <[email protected]>
ioctls that are
* callable only via tty_ioctl()
* not driver-specific
* not demand data structure conversions
* either always need passing arg as is or always demand compat_ptr()
get intercepted in tty_compat_ioctl() from the very beginning and redirecter to tty_ioctl(). As the result, their entries in fs/compat_ioctl.c (some of those had been missing, BTW) got removed, as well as n_tty_compat_ioctl_helper() (now it's never called with any cmd it would accept).
--- drivers/tty/tty_io.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++-- drivers/tty/tty_ioctl.c | 16 ---------- fs/compat_ioctl.c | 51 -------------------------------- include/linux/tty.h | 2 -- 4 files changed, 75 insertions(+), 71 deletions(-)
drivers/tty/tty_io.c +75 -2
@@ -2668,6 +2668,81 @@ static long tty_compat_ioctl(struct file *file, unsigned int cmd,struct tty_ldisc *ld;int retval = -ENOIOCTLCMD ; +switch (cmd) { +case TIOCSTI : +case TIOCGWINSZ : +case TIOCSWINSZ : +case TIOCGEXCL : +case TIOCGETD : +case TIOCSETD : +case TIOCGDEV : +case TIOCMGET : +case TIOCMSET : +case TIOCMBIC : +case TIOCMBIS : +case TIOCGICOUNT : +case TIOCGPGRP : +case TIOCSPGRP : +case TIOCGSID : +case TIOCSERGETLSR : +case TIOCGRS485 : +case TIOCSRS485 : +#ifdef TIOCGETP +case TIOCGETP : +case TIOCSETP : +case TIOCSETN : +#endif +#ifdef TIOCGETC +case TIOCGETC : +case TIOCSETC : +#endif +#ifdef TIOCGLTC +case TIOCGLTC : +case TIOCSLTC : +#endif +case TCSETSF : +case TCSETSW : +case TCSETS : +case TCGETS : +#ifdef TCGETS2 +case TCGETS2 : +case TCSETSF2 : +case TCSETSW2 : +case TCSETS2 : +#endif +case TCGETA : +case TCSETAF : +case TCSETAW : +case TCSETA : +case TIOCGLCKTRMIOS : +case TIOCSLCKTRMIOS : +#ifdef TCGETX +case TCGETX : +case TCSETX : +case TCSETXW : +case TCSETXF : +#endif +case TIOCGSOFTCAR : +case TIOCSSOFTCAR : +return tty_ioctl (file, cmd, (unsigned long )compat_ptr (arg)); +case TIOCCONS : +case TIOCEXCL : +case TIOCNXCL : +case TIOCVHANGUP : +case TIOCSBRK : +case TIOCCBRK : +case TCSBRK : +case TCSBRKP : +case TCFLSH : +case TIOCGPTPEER : +case TIOCNOTTY : +case TIOCSCTTY : +case TCXONC : +case TIOCMIWAIT : +case TIOCSERCONFIG : +return tty_ioctl (file, cmd, arg); + } +if (tty_paranoia_check (tty,file_inode (file),"tty_ioctl" ))return -EINVAL ;
@@ -2682,8 +2757,6 @@ static long tty_compat_ioctl(struct file *file, unsigned int cmd,return hung_up_tty_compat_ioctl (file, cmd, arg);if (ld->ops->compat_ioctl) retval = ld->ops->compat_ioctl (tty, file, cmd, arg); -else - retval =n_tty_compat_ioctl_helper (tty, file, cmd, arg);tty_ldisc_deref (ld);return retval;
drivers/tty/tty_ioctl.c +0 -16
@@ -941,19 +941,3 @@ int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, } }EXPORT_SYMBOL (n_tty_ioctl_helper); - -#ifdef CONFIG_COMPAT -long n_tty_compat_ioctl_helper (struct tty_struct *tty,struct file *file, -unsigned int cmd,unsigned long arg) -{ -switch (cmd) { -case TIOCGLCKTRMIOS : -case TIOCSLCKTRMIOS : -return tty_mode_ioctl (tty, file, cmd, (unsigned long )compat_ptr (arg)); -default : -return -ENOIOCTLCMD ; - } -} -EXPORT_SYMBOL (n_tty_compat_ioctl_helper); -#endif -
fs/compat_ioctl.c +0 -51
72 lines not on this page · raw message
include/linux/tty.h +0 -2
@@ -746,8 +746,6 @@ static inline int tty_audit_push(void)/* tty_ioctl.c */ extern int n_tty_ioctl_helper (struct tty_struct *tty,struct file *file,unsigned int cmd,unsigned long arg); -extern long n_tty_compat_ioctl_helper (struct tty_struct *tty,struct file *file, -unsigned int cmd,unsigned long arg);/* vt.c */
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 9/50 amiserial: switch to ->[sg]et_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/tty/amiserial.c | 83 ++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 45 deletions(-)
drivers/tty/amiserial.c +38 -45
@@ -996,63 +996,60 @@ static void rs_unthrottle(struct tty_struct * tty)* ------------------------------------------------------------ */ -static int get_serial_info (struct tty_struct *tty,struct serial_state *state, -struct serial_struct __user * retinfo) +static int get_serial_info (struct tty_struct *tty,struct serial_struct *ss) { -struct serial_struct tmp; - -memset (&tmp,0 ,sizeof (tmp)); +struct serial_state *state = tty->driver_data; + +if (serial_paranoia_check (state, tty->name,"rs_ioctl" )) +return -ENODEV ; +tty_lock (tty); - tmp.line = tty->index; - tmp.port = state->port; - tmp.flags = state->tport.flags; - tmp.xmit_fifo_size = state->xmit_fifo_size; - tmp.baud_base = state->baud_base; - tmp.close_delay = state->tport.close_delay; - tmp.closing_wait = state->tport.closing_wait; - tmp.custom_divisor = state->custom_divisor; + ss->line = tty->index; + ss->port = state->port; + ss->flags = state->tport.flags; + ss->xmit_fifo_size = state->xmit_fifo_size; + ss->baud_base = state->baud_base; + ss->close_delay = state->tport.close_delay; + ss->closing_wait = state->tport.closing_wait; + ss->custom_divisor = state->custom_divisor;tty_unlock (tty); -if (copy_to_user (retinfo,&tmp,sizeof (*retinfo))) -return -EFAULT ;return 0 ; } -static int set_serial_info (struct tty_struct *tty,struct serial_state *state, -struct serial_struct __user * new_info) +static int set_serial_info (struct tty_struct *tty,struct serial_struct *ss) { +struct serial_state *state = tty->driver_data;struct tty_port *port = &state->tport; -struct serial_struct new_serial;bool change_spd; -int retval =0 ; -if (copy_from_user (&new_serial,new_info,sizeof (new_serial))) -return -EFAULT ; +if (serial_paranoia_check (state, tty->name,"rs_ioctl" )) +return -ENODEV ;tty_lock (tty); - change_spd = ((new_serial.flags ^ port->flags) &ASYNC_SPD_MASK ) || - new_serial.custom_divisor != state->custom_divisor; -if (new_serial.irq || new_serial.port != state->port || - new_serial.xmit_fifo_size != state->xmit_fifo_size) { + change_spd = ((ss->flags ^ port->flags) &ASYNC_SPD_MASK ) || + ss->custom_divisor != state->custom_divisor; +if (ss->irq || ss->port != state->port || + ss->xmit_fifo_size != state->xmit_fifo_size) {tty_unlock (tty);return -EINVAL ; }if (!serial_isroot ()) { -if ((new_serial.baud_base != state->baud_base) || - (new_serial.close_delay != port->close_delay) || - (new_serial.xmit_fifo_size != state->xmit_fifo_size) || - ((new_serial.flags & ~ASYNC_USR_MASK ) != +if ((ss->baud_base != state->baud_base) || + (ss->close_delay != port->close_delay) || + (ss->xmit_fifo_size != state->xmit_fifo_size) || + ((ss->flags & ~ASYNC_USR_MASK ) != (port->flags & ~ASYNC_USR_MASK ))) {tty_unlock (tty);return -EPERM ; } port->flags = ((port->flags & ~ASYNC_USR_MASK ) | - (new_serial.flags &ASYNC_USR_MASK )); - state->custom_divisor = new_serial.custom_divisor; + (ss->flags &ASYNC_USR_MASK )); + state->custom_divisor = ss->custom_divisor; goto check_and_exit; } -if (new_serial.baud_base <9600 ) { +if (ss->baud_base <9600 ) {tty_unlock (tty);return -EINVAL ; }
@@ -1062,19 +1059,19 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,* At this point, we start making changes..... */ - state->baud_base = new_serial.baud_base; + state->baud_base = ss->baud_base; port->flags = ((port->flags & ~ASYNC_FLAGS ) | - (new_serial.flags &ASYNC_FLAGS )); - state->custom_divisor = new_serial.custom_divisor; - port->close_delay = new_serial.close_delay *HZ /100 ; - port->closing_wait = new_serial.closing_wait *HZ /100 ; + (ss->flags &ASYNC_FLAGS )); + state->custom_divisor = ss->custom_divisor; + port->close_delay = ss->close_delay *HZ /100 ; + port->closing_wait = ss->closing_wait *HZ /100 ; port->low_latency = (port->flags &ASYNC_LOW_LATENCY ) ?1 :0 ; check_and_exit:if (tty_port_initialized (port)) {if (change_spd) {/* warn about deprecation unless clearing */ -if (new_serial.flags &ASYNC_SPD_MASK ) +if (ss->flags &ASYNC_SPD_MASK )dev_warn_ratelimited (tty->dev,"use of SPD flags is deprecated\n" );change_speed (tty, state,NULL ); }
@@ -1084,7 +1081,6 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,return retval; } -/* * get_lsr_info - get line status register info *
@@ -1224,18 +1220,13 @@ static int rs_ioctl(struct tty_struct *tty,if (serial_paranoia_check (info, tty->name,"rs_ioctl" ))return -ENODEV ; -if ((cmd !=TIOCGSERIAL ) && (cmd !=TIOCSSERIAL ) && - (cmd !=TIOCSERCONFIG ) && (cmd !=TIOCSERGSTRUCT ) && +if ((cmd !=TIOCSERCONFIG ) && (cmd !=TIOCSERGSTRUCT ) && (cmd !=TIOCMIWAIT ) && (cmd !=TIOCGICOUNT )) {if (tty_io_error (tty))return -EIO ; }switch (cmd) { -case TIOCGSERIAL : -return get_serial_info (tty, info, argp); -case TIOCSSERIAL : -return set_serial_info (tty, info, argp);case TIOCSERCONFIG :return 0 ;
@@ -1607,6 +1598,8 @@ static const struct tty_operations serial_ops = { .tiocmget = rs_tiocmget, .tiocmset = rs_tiocmset, .get_icount = rs_get_icount, + .set_serial = set_serial_info, + .get_serial = get_serial_info, .proc_show = rs_proc_show, };
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 10/50 cyclades: switch to ->[sg]et_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/tty/cyclades.c | 77 ++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 40 deletions(-)
drivers/tty/cyclades.c +37 -40
@@ -2257,44 +2257,45 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty) } }/* set_line_char */ -static int cy_get_serial_info (struct cyclades_port *info, -struct serial_struct __user *retinfo) +static int cy_get_serial_info (struct tty_struct *tty, +struct serial_struct *ss) { +struct cyclades_port *info = tty->driver_data;struct cyclades_card *cinfo = info->card; -struct serial_struct tmp = { - .type = info->type, - .line = info->line, - .port = (info->card - cy_card) *0x100 + info->line - - cinfo->first_line, - .irq = cinfo->irq, - .flags = info->port.flags, - .close_delay = info->port.close_delay, - .closing_wait = info->port.closing_wait, - .baud_base = info->baud, - .custom_divisor = info->custom_divisor, - }; -return copy_to_user (retinfo, &tmp,sizeof (*retinfo)) ? -EFAULT :0 ; + +if (serial_paranoia_check (info, tty->name,"cy_ioctl" )) +return -ENODEV ; + ss->type = info->type; + ss->line = info->line; + ss->port = (info->card - cy_card) *0x100 + info->line - + cinfo->first_line; + ss->irq = cinfo->irq; + ss->flags = info->port.flags; + ss->close_delay = info->port.close_delay; + ss->closing_wait = info->port.closing_wait; + ss->baud_base = info->baud; + ss->custom_divisor = info->custom_divisor; +return 0 ; } -static int -cy_set_serial_info (struct cyclades_port *info,struct tty_struct *tty, -struct serial_struct __user *new_info) +static int cy_set_serial_info (struct tty_struct *tty, +struct serial_struct *ss) { -struct serial_struct new_serial; +struct cyclades_port *info = tty->driver_data;int old_flags;int ret; -if (copy_from_user (&new_serial, new_info,sizeof (new_serial))) -return -EFAULT ; +if (serial_paranoia_check (info, tty->name,"cy_ioctl" )) +return -ENODEV ;mutex_lock (&info->port.mutex); old_flags = info->port.flags;if (!capable (CAP_SYS_ADMIN )) { -if (new_serial.close_delay != info->port.close_delay || - new_serial.baud_base != info->baud || - (new_serial.flags &ASYNC_FLAGS & +if (ss->close_delay != info->port.close_delay || + ss->baud_base != info->baud || + (ss->flags &ASYNC_FLAGS & ~ASYNC_USR_MASK ) != (info->port.flags &ASYNC_FLAGS & ~ASYNC_USR_MASK )) {
@@ -2302,9 +2303,9 @@ cy_set_serial_info(struct cyclades_port *info, struct tty_struct *tty,return -EPERM ; } info->port.flags = (info->port.flags & ~ASYNC_USR_MASK ) | - (new_serial.flags &ASYNC_USR_MASK ); - info->baud = new_serial.baud_base; - info->custom_divisor = new_serial.custom_divisor; + (ss->flags &ASYNC_USR_MASK ); + info->baud = ss->baud_base; + info->custom_divisor = ss->custom_divisor; goto check_and_exit; }
@@ -2313,18 +2314,18 @@ cy_set_serial_info(struct cyclades_port *info, struct tty_struct *tty,* At this point, we start making changes..... */ - info->baud = new_serial.baud_base; - info->custom_divisor = new_serial.custom_divisor; + info->baud = ss->baud_base; + info->custom_divisor = ss->custom_divisor; info->port.flags = (info->port.flags & ~ASYNC_FLAGS ) | - (new_serial.flags &ASYNC_FLAGS ); - info->port.close_delay = new_serial.close_delay *HZ /100 ; - info->port.closing_wait = new_serial.closing_wait *HZ /100 ; + (ss->flags &ASYNC_FLAGS ); + info->port.close_delay = ss->close_delay *HZ /100 ; + info->port.closing_wait = ss->closing_wait *HZ /100 ; check_and_exit:if (tty_port_initialized (&info->port)) { -if ((new_serial.flags ^ old_flags) &ASYNC_SPD_MASK ) { +if ((ss->flags ^ old_flags) &ASYNC_SPD_MASK ) {/* warn about deprecation unless clearing */ -if (new_serial.flags &ASYNC_SPD_MASK ) +if (ss->flags &ASYNC_SPD_MASK )dev_warn_ratelimited (tty->dev,"use of SPD flags is deprecated\n" ); }cy_set_line_char (info, tty);
@@ -2698,12 +2699,6 @@ cy_ioctl(struct tty_struct *tty,case CYGETWAIT : ret_val = info->port.closing_wait / (HZ /100 );break ; -case TIOCGSERIAL : - ret_val =cy_get_serial_info (info, argp); -break ; -case TIOCSSERIAL : - ret_val =cy_set_serial_info (info, tty, argp); -break ;case TIOCSERGETLSR :/* Get line status register */ ret_val =get_lsr_info (info, argp);break ;
@@ -4011,6 +4006,8 @@ static const struct tty_operations cy_ops = { .tiocmget = cy_tiocmget, .tiocmset = cy_tiocmset, .get_icount = cy_get_icount, + .set_serial = cy_set_serial_info, + .get_serial = cy_get_serial_info, .proc_show = cyclades_proc_show, };
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 7/50 fwserial: switch to ->[sg]et_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/staging/fwserial/fwserial.c | 66 ++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 38 deletions(-)
drivers/staging/fwserial/fwserial.c +28 -38
@@ -1209,42 +1209,40 @@ static int wait_msr_change(struct fwtty_port *port, unsigned long mask) check_msr_delta(port, mask, &prev)); } -static int get_serial_info (struct fwtty_port *port, -struct serial_struct __user *info) +static int get_serial_info (struct tty_struct *tty, +struct serial_struct *ss) { -struct serial_struct tmp; - -memset (&tmp,0 ,sizeof (tmp)); - - tmp.type =PORT_UNKNOWN ; - tmp.line = port->port.tty->index; - tmp.flags = port->port.flags; - tmp.xmit_fifo_size =FWTTY_PORT_TXFIFO_LEN ; - tmp.baud_base =400000000 ; - tmp.close_delay = port->port.close_delay; - -return (copy_to_user (info, &tmp,sizeof (*info))) ? -EFAULT :0 ; +struct fwtty_port *port = tty->driver_data; +mutex_lock (&port->port.mutex); + ss->type =PORT_UNKNOWN ; + ss->line = port->port.tty->index; + ss->flags = port->port.flags; + ss->xmit_fifo_size =FWTTY_PORT_TXFIFO_LEN ; + ss->baud_base =400000000 ; + ss->close_delay = port->port.close_delay; +mutex_unlock (&port->port.mutex); +return 0 ; } -static int set_serial_info (struct fwtty_port *port, -struct serial_struct __user *info) +static int set_serial_info (struct tty_struct *tty, +struct serial_struct *ss) { -struct serial_struct tmp; - -if (copy_from_user (&tmp, info,sizeof (tmp))) -return -EFAULT ; +struct fwtty_port *port = tty->driver_data; -if (tmp.irq !=0 || tmp.port !=0 || tmp.custom_divisor !=0 || - tmp.baud_base !=400000000 ) +if (ss->irq !=0 || ss->port !=0 || ss->custom_divisor !=0 || + ss->baud_base !=400000000 )return -EPERM ; +mutex_lock (&port->port.mutex);if (!capable (CAP_SYS_ADMIN )) { -if (((tmp.flags & ~ASYNC_USR_MASK ) != - (port->port.flags & ~ASYNC_USR_MASK ))) +if (((ss->flags & ~ASYNC_USR_MASK ) != + (port->port.flags & ~ASYNC_USR_MASK ))) { +mutex_unlock (&port->port.mutex);return -EPERM ; - }else { - port->port.close_delay = tmp.close_delay *HZ /100 ; + } } + port->port.close_delay = ss->close_delay *HZ /100 ; +mutex_unlock (&port->port.mutex);return 0 ; }
@@ -1256,18 +1254,6 @@ static int fwtty_ioctl(struct tty_struct *tty, unsigned int cmd,int err;switch (cmd) { -case TIOCGSERIAL : -mutex_lock (&port->port.mutex); - err =get_serial_info (port, (void __user *)arg); -mutex_unlock (&port->port.mutex); -break ; - -case TIOCSSERIAL : -mutex_lock (&port->port.mutex); - err =set_serial_info (port, (void __user *)arg); -mutex_unlock (&port->port.mutex); -break ; -case TIOCMIWAIT : err =wait_msr_change (port, arg);break ;
@@ -1557,6 +1543,8 @@ static const struct tty_operations fwtty_ops = { .tiocmget = fwtty_tiocmget, .tiocmset = fwtty_tiocmset, .get_icount = fwtty_get_icount, + .set_serial = set_serial_info, + .get_serial = get_serial_info, .proc_show = fwtty_proc_show, };
@@ -1578,6 +1566,8 @@ static const struct tty_operations fwloop_ops = { .tiocmget = fwtty_tiocmget, .tiocmset = fwtty_tiocmset, .get_icount = fwtty_get_icount, + .set_serial = set_serial_info, + .get_serial = get_serial_info, };static inline int mgmt_pkt_expected_len (__be16 code)
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 6/50 simserial: switch to ->[sg]et_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- arch/ia64/hp/sim/simserial.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
arch/ia64/hp/sim/simserial.c +13 -4
@@ -297,18 +297,25 @@ static void rs_unthrottle(struct tty_struct * tty)printk (KERN_INFO "simrs_unthrottle called\n" ); } +static int rs_setserial (struct tty_struct *tty,struct serial_struct *ss) +{ +return 0 ; +} + +static int rs_getserial (struct tty_struct *tty,struct serial_struct *ss) +{ +return 0 ; +} +static int rs_ioctl (struct tty_struct *tty,unsigned int cmd,unsigned long arg) { -if ((cmd !=TIOCGSERIAL ) && (cmd !=TIOCSSERIAL ) && - (cmd !=TIOCSERCONFIG ) && (cmd !=TIOCSERGSTRUCT ) && +if ((cmd !=TIOCSERCONFIG ) && (cmd !=TIOCSERGSTRUCT ) && (cmd !=TIOCMIWAIT )) {if (tty_io_error (tty))return -EIO ; }switch (cmd) { -case TIOCGSERIAL : -case TIOCSSERIAL :case TIOCSERGSTRUCT :case TIOCMIWAIT :return 0 ;
@@ -448,6 +455,8 @@ static const struct tty_operations hp_ops = { .throttle = rs_throttle, .unthrottle = rs_unthrottle, .send_xchar = rs_send_xchar, + .set_serial = rs_setserial, + .get_serial = rs_getserial, .hangup = rs_hangup, .proc_show = rs_proc_show, };
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 4/50 mos7720: bury dead TIOCM... in ->ioctl()
In reply to Al ViroFrom: Al Viro <[email protected]>
These ioctls never reach driver's ->ioctl() - tty_ioctl() handles them on its own. ->tiocm[gs]et() is what actually gets called, and mos7720 provides those, with results equivalent to what the unreachable code would be doing when called.
--- drivers/usb/serial/mos7720.c | 52 -------------------------------------------- 1 file changed, 52 deletions(-)
drivers/usb/serial/mos7720.c +0 -52
@@ -1786,51 +1786,6 @@ static int mos7720_tiocmset(struct tty_struct *tty,return 0 ; } -static int set_modem_info (struct moschip_port *mos7720_port,unsigned int cmd, -unsigned int __user *value) -{ -unsigned int mcr; -unsigned int arg; - -struct usb_serial_port *port; - -if (mos7720_port ==NULL ) -return -1 ; - - port = (struct usb_serial_port *)mos7720_port->port; - mcr = mos7720_port->shadowMCR; - -if (copy_from_user (&arg, value,sizeof (int ))) -return -EFAULT ; - -switch (cmd) { -case TIOCMBIS : -if (arg &TIOCM_RTS ) - mcr |=UART_MCR_RTS ; -if (arg &TIOCM_DTR ) - mcr |=UART_MCR_RTS ; -if (arg &TIOCM_LOOP ) - mcr |=UART_MCR_LOOP ; -break ; - -case TIOCMBIC : -if (arg &TIOCM_RTS ) - mcr &= ~UART_MCR_RTS ; -if (arg &TIOCM_DTR ) - mcr &= ~UART_MCR_RTS ; -if (arg &TIOCM_LOOP ) - mcr &= ~UART_MCR_LOOP ; -break ; - - } - - mos7720_port->shadowMCR = mcr; -write_mos_reg (port->serial, port->port_number,MOS7720_MCR , - mos7720_port->shadowMCR); - -return 0 ; -} -static int get_serial_info (struct moschip_port *mos7720_port,struct serial_struct __user *retinfo) {
@@ -1868,13 +1823,6 @@ static int mos7720_ioctl(struct tty_struct *tty,return get_lsr_info (tty, mos7720_port, (unsigned int __user *)arg); -/* FIXME: These should be using the mode methods */ -case TIOCMBIS : -case TIOCMBIC : -dev_dbg (&port->dev,"%s TIOCMSET/TIOCMBIC/TIOCMSET\n" , __func__); -return set_modem_info (mos7720_port, cmd, - (unsigned int __user *)arg); -case TIOCGSERIAL :dev_dbg (&port->dev,"%s TIOCGSERIAL\n" , __func__); return get_serial_info(mos7720_port,
Signature · 1 line
2.11.0
Al Viro
maintainerPATCH 11/50 ipwireless: switch to ->[sg]et_serial()
In reply to Al ViroFrom: Al Viro <[email protected]>
--- drivers/tty/ipwireless/tty.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/tty/ipwireless/tty.c +18 -18
@@ -248,22 +248,29 @@ static int ipw_write_room(struct tty_struct *linux_tty)return room; } -static int ipwireless_get_serial_info (struct ipw_tty *tty, -struct serial_struct __user *retinfo) +static int ipwireless_get_serial_info (struct tty_struct *linux_tty, +struct serial_struct *ss) { -struct serial_struct tmp; +struct ipw_tty *tty = linux_tty->driver_data; -memset (&tmp,0 ,sizeof (tmp)); - tmp.type =PORT_UNKNOWN ; - tmp.line = tty->index; - tmp.baud_base =115200 ; +if (!tty) +return -ENODEV ; -if (copy_to_user (retinfo, &tmp,sizeof (*retinfo))) -return -EFAULT ; +if (!tty->port.count) +return -EINVAL ; + ss->type =PORT_UNKNOWN ; + ss->line = tty->index; + ss->baud_base =115200 ;return 0 ; } +static int ipwireless_set_serial_info (struct tty_struct *linux_tty, +struct serial_struct *ss) +{ +return 0 ;/* Keeps the PCMCIA scripts happy. */ +} +static int ipw_chars_in_buffer (struct tty_struct *linux_tty) {struct ipw_tty *tty = linux_tty->driver_data;
@@ -386,15 +393,6 @@ static int ipw_ioctl(struct tty_struct *linux_tty,return -EINVAL ;/* FIXME: Exactly how is the tty object locked here .. */ - -switch (cmd) { -case TIOCGSERIAL : -return ipwireless_get_serial_info (tty, (void __user *) arg); - -case TIOCSSERIAL : -return 0 ;/* Keeps the PCMCIA scripts happy. */ - } -if (tty->tty_type ==TTYTYPE_MODEM ) {switch (cmd) {case PPPIOCGCHAN :
@@ -561,6 +559,8 @@ static const struct tty_operations tty_ops = { .chars_in_buffer = ipw_chars_in_buffer, .tiocmget = ipw_tiocmget, .tiocmset = ipw_tiocmset, + .set_serial = ipwireless_set_serial_info, + .get_serial = ipwireless_get_serial_info, };int ipwireless_tty_init (void )
Signature · 1 line
2.11.0
Arnd Bergmann
maintainerRe: [PATCH 46/50] vt_compat_ioctl(): clean up, use compat_ptr() properly
In reply to Al ViroQuoted 6 lines · Al Viro
From: Al Viro <[email protected]>
we need it for "convert the structure" cases too
Signed-off-by Al Viro <[email protected]>
Nice catch. I introduced the mistake in commit e92166517e3c ("tty: handle VT specific compat ioctls in vt driver"), the original code was fine. drivers/s390/char/tty3270.c implements some of the VT ioctls, but none that are affected by this.
At least the VT code is not usable on s390, so it did not make a practical difference.
Arnd
Arnd Bergmann
maintainerRe: [PATCH 40/50] kill the rest of tty COMPAT_IOCTL() entries
In reply to Al ViroQuoted 5 lines · Al Viro
fs/compat_ioctl.c +0
-1@@ -1113,17 +1111,6 @@ COMPATIBLE_IOCTL(JSIOCGAXES)COMPATIBLE_IOCTL (JSIOCGBUTTONS) COMPATIBLE_IOCTL(JSIOCGNAME(0)) -#ifdef TIOCSTART
fs/compat_ioctl.c COMPATIBLE_IOCTL(JSIOCGAXES) · line 1126
Quoted 10 lines
fs/compat_ioctl.c +0
-10-/* -* For these two we have definitions in ioctls.h and/or termios.h on -* some architectures but no actual implemention. Some applications -* like bash call them if they are defined in the headers, so we provide -* entries here to avoid syslog message spew. -*/ -COMPATIBLE_IOCTL(TIOCSTART) -COMPATIBLE_IOCTL(TIOCSTOP) -#endif -
These are also included in my "compat_ioctl: remove IGNORE_IOCTL()" patch, but it's trivial to rebased one on top of the other of course.
Arnd
Arnd Bergmann
maintainerQuoted 12 lines · Al Viro
See vfs.git#work.tty-ioctl. Completely untested, should seriously
clean the things up wrt compat. Remaining problems (aside of the bugs introduced in it, of course):
* TIOCSERGSTRUCT must die; it's present only in amiserial and it's
_vile_; look at what it copies out and weep.
*synclink_gthas proper compat handling for its private ioctls;
other synclink drivers (with the same ioctls) do not.
* dgnc definitely has buggered ioctls - structs full of longs are
bloody bad idea for passing around. It's in staging, and I'd say that it needs the userland ABI fixed.
* cyclades, rocket, moxa and mxser probably have non-trivial
Quoted 8 lines
problems with their private ioctls; I hadn't looked into those.
*n_gsmneeds ->compat_ioctl(); easy to do, I just hadn't done it
yet.
* ipwireless might or might not needcompat_ioctl(PPP stuff in it);
not sure.
* ldisc private ioctls need more work. Hadn't gone there yet.
Generic ioctls should be fine - they never reach ->compat_ioctl() with this series.
I looked at all the new patches, looks all good to me. When I did my (incomplete) analysis, I found a couple more things that could be included in the series if we want to:
* TIOCSERGWILD/TIOCSERSWILD are obsolete and never do anything useful, but the return code is inconsistent: ENOTTY in compat mode vs 0 in uart_ioctl, plus a printk for amiserial. If we want to keep it around rather than deleting it completely, it should be marked as compatible.
* PPPIOCGCHAN/PPPIOCGUNIT are implemented by multiple ldisc variants, marking them as compatible would save us from implementing a comp_ioctl method for each one separately. These are also used on some things that are not ttys though, so we can't remove them from fs/compat_ioctl.c yet.
* FIONREAD/TIOCINQ and TIOCOUTQ also appear multiple times and could be added to that list but not removed from fs/compat_ioctl.c (I think the other users are all in sockets, so adding them in both might be sufficient)
* SIOCGIFNAME, SIOCGIFENCAP, SIOCSIFENCAP, SIOCSIFHWADDR, SIOCSKEEPALIVE, SIOCGKEEPALIVE, SIOCSOUTFILL, and SIOCGOUTFILL are in the tty_ioctl functions for multiple protocol handlers, comparable to the PPP ones.
Quoted 4 lines
There's some overlap with patches posted earlier - e.g. I'm fairly
sure that keyboard ioctl "remove fromfs/compat_ioctl.c" part duplicates one of yours; I'll be glad to drop and replace such duplicates with already posted variants.
Ok, don't worry about the order if you decide to apply yours first, you can just drop mine.
Arnd
Greg Kroah-Hartman
maintainerRe: [PATCH 09/50] amiserial: switch to ->[sg]et_serial()
In reply to Al ViroQuoted 16 lines · Al Viro
From: Al Viro <[email protected]>
Signed-off-by Al Viro <[email protected]>--- drivers/tty/amiserial.c | 83 ++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 45 deletions(-)drivers/tty/amiserial.c +0
-1@@ -996,63 +996,60 @@ static void rs_unthrottle(struct tty_struct * tty)* ------------------------------------------------------------ */ -static int get_serial_info(struct tty_struct *tty, struct serial_state *state,
drivers/tty/amiserial.c static void rs_unthrottle(struct tty_struct * tty) · line 1004
Quoted 10 lines
drivers/tty/amiserial.c +5
-4- struct serial_struct __user * retinfo) +static int get_serial_info (struct tty_struct *tty,struct serial_struct *ss) { -struct serial_struct tmp; - -memset (&tmp,0 ,sizeof (tmp)); +struct serial_state *state = tty->driver_data; + +if (serial_paranoia_check (state, tty->name,"rs_ioctl" )) +return -ENODEV ;
These crazy paranoia check functions just need to be deleted, no need to add new ones here. Or we can just delete them later on...
thanks,
greg k-h
Greg Kroah-Hartman
maintainerRe: [PATCH 41/50] dgnc: break-related ioctls won't reach ->ioctl()
In reply to Al ViroQuoted 9 lines · Al Viro
From: Al Viro <[email protected]>
kill the dead code, especially since ->break_ctl() will do the right thing anyway.
Signed-off-by Al Viro <[email protected]>--- drivers/staging/dgnc/dgnc_tty.c | 75 ----------------------------------------- 1 file changed, 75 deletions(-)
Like I mentioned on IRC, this driver really just needs to be deleted soon. But your patch here is fine, thanks for it, no objections from me.
greg k-h
Quoted 37 lines · Al Viro
See vfs.git#work.tty-ioctl. Completely untested, should seriously
clean the things up wrt compat. Remaining problems (aside of the bugs introduced in it, of course):
* TIOCSERGSTRUCT must die; it's present only in amiserial and it's
_vile_; look at what it copies out and weep.
*synclink_gthas proper compat handling for its private ioctls;
other synclink drivers (with the same ioctls) do not.
* dgnc definitely has buggered ioctls - structs full of longs are
bloody bad idea for passing around. It's in staging, and I'd say that it needs the userland ABI fixed.
* cyclades, rocket, moxa and mxser probably have non-trivial
problems with their private ioctls; I hadn't looked into those.
*n_gsmneeds ->compat_ioctl(); easy to do, I just hadn't done it
yet.
* ipwireless might or might not needcompat_ioctl(PPP stuff in it);
not sure.
* ldisc private ioctls need more work. Hadn't gone there yet.
Generic ioctls should be fine - they never reach ->compat_ioctl() with this series.There's some overlap with patches posted earlier - e.g. I'm fairly
sure that keyboard ioctl "remove fromfs/compat_ioctl.c" part duplicates one of yours; I'll be glad to drop and replace such duplicates with already posted variants.Basic idea is to shunt generic ioctls that are reachable only
viatty_ioctl()very early intty_compat_ioctl(), separately for those that do and do not needcompat_ptr(). That already simplifies the hell out of ->compat_ioctl() situation - its instances won't ever see those, so they can e.g. ignore the behaviour ofn_tty_ioctl_helper(); whatever they get in cmd won't be accepted by that one.Next we separate TIOC[SG]SERIAL into a couple of new methods,
leaving the copyin/copyout to callers. That allows to take care of compat for those intty_compat_ioctl()*and* actually kills some of ->ioctl() instances.
Quoted 6 lines
And then there's dead code of all kinds all over the place ;-/
The oldest one has been alive from Aug 1 1992 to Oct 18 1992 and had shambled around ever since (FIONBIO), but there are other examples. 10 years dead is better than 26, but still...Shortlog and diffstat follow, patches in followups...
Thanks a lot for this work. If you and Arnd want to figure out whose tree to take it through, I have no objection.
All of these can be marked as:
if you want to.
greg k-h
Al Viro
maintainerQuoted 26 lines · Arnd Bergmann
Quoted 12 lines · Al Viro
See vfs.git#work.tty-ioctl. Completely untested, should seriously
clean the things up wrt compat. Remaining problems (aside of the bugs introduced in it, of course):
* TIOCSERGSTRUCT must die; it's present only in amiserial and it's
_vile_; look at what it copies out and weep.
*synclink_gthas proper compat handling for its private ioctls;
other synclink drivers (with the same ioctls) do not.
* dgnc definitely has buggered ioctls - structs full of longs are
bloody bad idea for passing around. It's in staging, and I'd say that it needs the userland ABI fixed.
* cyclades, rocket, moxa and mxser probably have non-trivialQuoted 8 lines
problems with their private ioctls; I hadn't looked into those.
*n_gsmneeds ->compat_ioctl(); easy to do, I just hadn't done it
yet.
* ipwireless might or might not needcompat_ioctl(PPP stuff in it);
not sure.
* ldisc private ioctls need more work. Hadn't gone there yet.
Generic ioctls should be fine - they never reach ->compat_ioctl() with this series.I looked at all the new patches, looks all good to me. When I did my (incomplete) analysis, I found a couple more things that could be included in the series if we want to:
Quoted 5 lines
* TIOCSERGWILD/TIOCSERSWILD are obsolete and never do anything useful, but the return code is inconsistent: ENOTTY in compat mode vs 0 in
uart_ioctl, plus a printk for amiserial. If we want to keep it around rather than deleting it completely, it should be marked as compatible.
Yes. Not sure if we want to - the only user is setserial(8), with
-W Do wild interrupt initialization and exit. This option is no
longer relevant in Linux kernels after version 2.1.
What's more, rc.serial does *not* use it since 2.15 and even in 2.14 it wouldn't have failed the boot - just whine (truthfully) "Cannot scan for wild interrupts" on stderr and continue with the rest of the script. The same goes at least as far back as setserial-2.02. That's what MCC had; if you want to check something earlier, you'll probably have to ask tytso, but I very much doubt that anything of that vintage will work with the current kernels *or* that anyone cared to abort the script in question on setserial -W /dev/cua0 failing to start with.
So I'd seriously suggest removing those altogether. I mean, sure, we can carry explicit "obsolete, quietly return 0 on those" indefinitely, but that really feels over the top. Time to bury the body, unless somebody objects...
Quoted 5 lines
* PPPIOCGCHAN/PPPIOCGUNIT are implemented by multiple ldisc variants, marking them as compatible would save us from implementing a
comp_ioctlmethod for each one separately. These are also used on some things that are not ttys though, so we can't remove them fromfs/compat_ioctl.cyet.
Worse - there's ipwireless, which implements it in tty_operations ->ioctl().
Quoted 4 lines
* FIONREAD/TIOCINQ and TIOCOUTQ also appear multiple times and could be added to that list but not removed from
fs/compat_ioctl.c(I think the other users are all in sockets, so adding them in both might be sufficient)
Pipes as well.
Quoted 5 lines
* SIOCGIFNAME, SIOCGIFENCAP, SIOCSIFENCAP, SIOCSIFHWADDR, SIOCSKEEPALIVE, SIOCGKEEPALIVE, SIOCSOUTFILL, and SIOCGOUTFILL are in the
tty_ioctlfunctions for multiple protocol handlers, comparable to the PPP ones.
Very definitely shared with sockets, and I prefer to handle the tty-side cases in ldisc ->compat_ioctl().
Arnd Bergmann
maintainerQuoted 21 lines · Al Viro
Quoted 6 lines · Arnd Bergmann
On Thu, Sep 13, 2018 at 4:31 AM Al Viro <[email protected]> wrote:
* TIOCSERGWILD/TIOCSERSWILD are obsolete and never do anything useful, but the return code is inconsistent: ENOTTY in compat mode vs 0 inuart_ioctl, plus a printk for amiserial. If we want to keep it around rather than deleting it completely, it should be marked as compatible.Yes. Not sure if we want to - the only user is setserial(8), with
-W Do wild interrupt initialization and exit. This option is no
longer relevant in Linux kernels after version 2.1.What's more, rc.serial does *not* use it since 2.15 and even in 2.14 it wouldn't have failed the boot - just whine (truthfully) "Cannot scan for wild interrupts" on stderr and continue with the rest of the script. The same goes at least as far back as setserial-2.02. That's what MCC had; if you want to check something earlier, you'll probably have to ask tytso, but I very much doubt that anything of that vintage will work with the current kernels *or* that anyone cared to abort the script in question on setserial -W
/dev/cua0failing to start with.
Quoted 3 lines
So I'd seriously suggest removing those altogether. I mean, sure, we can carry explicit "obsolete, quietly return 0 on those" indefinitely, but that really feels over the top. Time to bury the body, unless somebody objects...
Sounds good to me.
Quoted 7 lines
Quoted 5 lines
* PPPIOCGCHAN/PPPIOCGUNIT are implemented by multiple ldisc variants, marking them as compatible would save us from implementing a
comp_ioctlmethod for each one separately. These are also used on some things that are not ttys though, so we can't remove them fromfs/compat_ioctl.cyet.Worse - there's ipwireless, which implements it in
tty_operations->ioctl().
Yes, I saw that too, but couldn't figure out exactly what ipwireless does. I suppose it is some serial port driver that comes with a hardcoded ppp implementation instead of a switchable ldisc?
Quoted 8 lines
Quoted 5 lines
* SIOCGIFNAME, SIOCGIFENCAP, SIOCSIFENCAP, SIOCSIFHWADDR, SIOCSKEEPALIVE, SIOCGKEEPALIVE, SIOCSOUTFILL, and SIOCGOUTFILL are in the
tty_ioctlfunctions for multiple protocol handlers, comparable to the PPP ones.Very definitely shared with sockets, and I prefer to handle the tty-side cases in ldisc ->compat_ioctl().
Fair enough.
Arnd
Al Viro
maintainerQuoted 3 lines · Arnd Bergmann
Yes, I saw that too, but couldn't figure out exactly what ipwireless does. I suppose it is some serial port driver that comes with a hardcoded ppp implementation instead of a switchable ldisc?
NFI...
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines
* SIOCGIFNAME, SIOCGIFENCAP, SIOCSIFENCAP, SIOCSIFHWADDR, SIOCSKEEPALIVE, SIOCGKEEPALIVE, SIOCSOUTFILL, and SIOCGOUTFILL are in the
tty_ioctlfunctions for multiple protocol handlers, comparable to the PPP ones.Very definitely shared with sockets, and I prefer to handle the tty-side cases in ldisc ->compat_ioctl().
Fair enough.
FWIW, a solution of sorts pushed into the same branch. It does *not* cover tty_operations ->compat_ioctl() - only ldisc ones. Comments?
commit de36af5ca465156863b5fb7548e3660ea7d3bbcf
Author: Al Viro <[email protected]> Date: Thu Sep 13 22:12:15 2018 -0400
change semantics of ldisc ->compat_ioctl()
First of all, make it return int. Returning long when native method had never allowed that is ridiculous and inconvenient.
More importantly, change the caller; if ldisc ->compat_ioctl() is NULL or returns -ENOIOCTLCMD, tty_compat_ioctl() will try to feed cmd and compat_ptr(arg) to ldisc's native ->ioctl().
That simplifies ->compat_ioctl() instances quite a bit - they only need to deal with ioctls that are neither generic tty ones (those would get shunted off to tty_ioctl()) nor simple compat pointer ones.
For quite a few ldiscs it means that NULL ->compat_ioctl() does the right thing. Those where it won't serve (see e.g. n_r3964.c) are also easily dealt with - we need to handle the numeric-argument ioctls (calling the native instance) and, if such would exist, the ioctls that need layout conversion, etc.
All in-tree ldiscs dealt with.
drivers/bluetooth/hci_ldisc.c +1 -0
@@ -821,6 +821,7 @@ static int __init hci_uart_init(void) hci_uart_ldisc.read = hci_uart_tty_read; hci_uart_ldisc.write = hci_uart_tty_write; hci_uart_ldisc.ioctl = hci_uart_tty_ioctl; + hci_uart_ldisc.compat_ioctl = hci_uart_tty_ioctl; hci_uart_ldisc.poll = hci_uart_tty_poll; hci_uart_ldisc.receive_buf = hci_uart_tty_receive; hci_uart_ldisc.write_wakeup = hci_uart_tty_wakeup;
drivers/input/serio/serport.c +1 -1
@@ -226,7 +226,7 @@ static int serport_ldisc_ioctl(struct tty_struct *tty, struct file *file,#ifdef CONFIG_COMPAT #define COMPAT_SPIOCSTYPE _IOW('q', 0x01, compat_ulong_t) -static long serport_ldisc_compat_ioctl (struct tty_struct *tty, +static int serport_ldisc_compat_ioctl (struct tty_struct *tty,struct file *file,unsigned int cmd,unsigned long arg) {
drivers/net/hamradio/6pack.c +0 -21
@@ -34,7 +34,6 @@#include <linux/ip.h> #include <linux/tcp.h> #include <linux/semaphore.h> -#include <linux/compat.h> #include <linux/refcount.h> #define SIXPACK_VERSION "Revision: 0.3.0"
@@ -752,23 +751,6 @@ static int sixpack_ioctl(struct tty_struct *tty, struct file *file,return err; } -#ifdef CONFIG_COMPAT -static long sixpack_compat_ioctl (struct tty_struct * tty,struct file * file, -unsigned int cmd,unsigned long arg) -{ -switch (cmd) { -case SIOCGIFNAME : -case SIOCGIFENCAP : -case SIOCSIFENCAP : -case SIOCSIFHWADDR : -return sixpack_ioctl (tty, file, cmd, - (unsigned long )compat_ptr (arg)); - } - -return -ENOIOCTLCMD ; -} -#endif -static struct tty_ldisc_ops sp_ldisc = { .owner =THIS_MODULE , .magic =TTY_LDISC_MAGIC ,
@@ -776,9 +758,6 @@ static struct tty_ldisc_ops sp_ldisc = { .open = sixpack_open, .close = sixpack_close, .ioctl = sixpack_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = sixpack_compat_ioctl, -#endif .receive_buf = sixpack_receive_buf, .write_wakeup = sixpack_write_wakeup, };
drivers/net/hamradio/mkiss.c +0 -21
@@ -35,7 +35,6 @@#include <linux/skbuff.h> #include <linux/if_arp.h> #include <linux/jiffies.h> -#include <linux/compat.h> #include <net/ax25.h>
@@ -875,23 +874,6 @@ static int mkiss_ioctl(struct tty_struct *tty, struct file *file,return err; } -#ifdef CONFIG_COMPAT -static long mkiss_compat_ioctl (struct tty_struct *tty,struct file *file, -unsigned int cmd,unsigned long arg) -{ -switch (cmd) { -case SIOCGIFNAME : -case SIOCGIFENCAP : -case SIOCSIFENCAP : -case SIOCSIFHWADDR : -return mkiss_ioctl (tty, file, cmd, - (unsigned long )compat_ptr (arg)); - } - -return -ENOIOCTLCMD ; -} -#endif -/* * Handle the 'receiver data ready' interrupt. * This function is called by the 'tty_io' module in the kernel when
@@ -966,9 +948,6 @@ static struct tty_ldisc_ops ax_ldisc = { .open = mkiss_open, .close = mkiss_close, .ioctl = mkiss_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = mkiss_compat_ioctl, -#endif .receive_buf = mkiss_receive_buf, .write_wakeup = mkiss_write_wakeup };
drivers/net/slip/slip.c +0 -25
@@ -79,7 +79,6 @@#include <linux/rtnetlink.h> #include <linux/if_arp.h> #include <linux/if_slip.h> -#include <linux/compat.h> #include <linux/delay.h> #include <linux/init.h> #include <linux/slab.h>
@@ -1167,27 +1166,6 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file, } } -#ifdef CONFIG_COMPAT -static long slip_compat_ioctl (struct tty_struct *tty,struct file *file, -unsigned int cmd,unsigned long arg) -{ -switch (cmd) { -case SIOCGIFNAME : -case SIOCGIFENCAP : -case SIOCSIFENCAP : -case SIOCSIFHWADDR : -case SIOCSKEEPALIVE : -case SIOCGKEEPALIVE : -case SIOCSOUTFILL : -case SIOCGOUTFILL : -return slip_ioctl (tty, file, cmd, - (unsigned long )compat_ptr (arg)); - } - -return -ENOIOCTLCMD ; -} -#endif -/* VSV changes start here */ #ifdef CONFIG_SLIP_SMART /* function do_ioctl called from net/core/dev.c
@@ -1280,9 +1258,6 @@ static struct tty_ldisc_ops sl_ldisc = { .close = slip_close, .hangup = slip_hangup, .ioctl = slip_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = slip_compat_ioctl, -#endif .receive_buf = slip_receive_buf, .write_wakeup = slip_write_wakeup, };
drivers/net/wan/x25_asy.c +0 -19
@@ -33,7 +33,6 @@#include <linux/lapb.h> #include <linux/init.h> #include <linux/rtnetlink.h> -#include <linux/compat.h> #include <linux/slab.h> #include <net/x25device.h> #include "x25_asy.h"
@@ -703,21 +702,6 @@ static int x25_asy_ioctl(struct tty_struct *tty, struct file *file, } } -#ifdef CONFIG_COMPAT -static long x25_asy_compat_ioctl (struct tty_struct *tty,struct file *file, -unsigned int cmd,unsigned long arg) -{ -switch (cmd) { -case SIOCGIFNAME : -case SIOCSIFHWADDR : -return x25_asy_ioctl (tty, file, cmd, - (unsigned long )compat_ptr (arg)); - } - -return -ENOIOCTLCMD ; -} -#endif -static int x25_asy_open_dev (struct net_device *dev) {struct x25_asy *sl =netdev_priv (dev);
@@ -769,9 +753,6 @@ static struct tty_ldisc_ops x25_ldisc = { .open = x25_asy_open_tty, .close = x25_asy_close_tty, .ioctl = x25_asy_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = x25_asy_compat_ioctl, -#endif .receive_buf = x25_asy_receive_buf, .write_wakeup = x25_asy_write_wakeup, };
drivers/tty/n_gsm.c +0 -11
@@ -2614,14 +2614,6 @@ static int gsmld_ioctl(struct tty_struct *tty, struct file *file, } } -#ifdef CONFIG_COMPAT -static long gsmld_compat_ioctl (struct tty_struct *tty,struct file *file, -unsigned int cmd,unsigned long arg) -{ -return gsmld_ioctl (tty, file, cmd, arg); -} -#endif -/* * Network interface *
@@ -2833,9 +2825,6 @@ static struct tty_ldisc_ops tty_ldisc_packet = { .flush_buffer = gsmld_flush_buffer, .read = gsmld_read, .write = gsmld_write, -#ifdef CONFIG_COMPAT - .compat_ioctl = gsmld_compat_ioctl, -#endif .ioctl = gsmld_ioctl, .poll = gsmld_poll, .receive_buf = gsmld_receive_buf,
drivers/tty/n_r3964.c +22 -0
@@ -134,6 +134,10 @@ static ssize_t r3964_write(struct tty_struct *tty, struct file *file, const unsigned char *buf, size_t nr);static int r3964_ioctl (struct tty_struct *tty,struct file *file,unsigned int cmd,unsigned long arg); +#ifdef CONFIG_COMPAT +static int r3964_compat_ioctl (struct tty_struct *tty,struct file *file, +unsigned int cmd,unsigned long arg); +#endif static void r3964_set_termios (struct tty_struct *tty,struct ktermios *old);static __poll_t r3964_poll (struct tty_struct *tty,struct file *file,struct poll_table_struct *wait);
@@ -149,6 +153,9 @@ static struct tty_ldisc_ops tty_ldisc_N_R3964 = { .read = r3964_read, .write = r3964_write, .ioctl = r3964_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = r3964_compat_ioctl, +#endif .set_termios = r3964_set_termios, .poll = r3964_poll, .receive_buf = r3964_receive_buf,
@@ -1210,6 +1217,21 @@ static int r3964_ioctl(struct tty_struct *tty, struct file *file, } } +#ifdef CONFIG_COMPAT +static int r3964_compat_ioctl (struct tty_struct *tty,struct file *file, +unsigned int cmd,unsigned long arg) +{ +switch (cmd) { +case R3964_ENABLE_SIGNALS : +case R3964_SETPRIORITY : +case R3964_USE_BCC : +return r3964_ioctl (tty, file, cmd, arg); +default : +return -ENOIOCTLCMD ; + } +} +#endif +static void r3964_set_termios (struct tty_struct *tty,struct ktermios *old) {TRACE_L ("set_termios" );
drivers/tty/tty_io.c +3 -0
@@ -2824,6 +2824,9 @@ static long tty_compat_ioctl(struct file *file, unsigned int cmd,return hung_up_tty_compat_ioctl (file, cmd, arg);if (ld->ops->compat_ioctl) retval = ld->ops->compat_ioctl (tty, file, cmd, arg); +if (retval == -ENOIOCTLCMD && ld->ops->ioctl) + retval = ld->ops->ioctl (tty, file, + (unsigned long )compat_ptr (cmd), arg);tty_ldisc_deref (ld);return retval;
include/linux/tty_ldisc.h +1 -1
@@ -184,7 +184,7 @@ struct tty_ldisc_ops { const unsigned char *buf, size_t nr);int (*ioctl)(struct tty_struct *tty,struct file *file,unsigned int cmd,unsigned long arg); -long (*compat_ioctl)(struct tty_struct *tty,struct file *file, +int (*compat_ioctl)(struct tty_struct *tty,struct file *file,unsigned int cmd,unsigned long arg);void (*set_termios)(struct tty_struct *tty,struct ktermios *old); __poll_t (*poll)(struct tty_struct *, struct file *,
net/nfc/nci/uart.c +1 -0
@@ -465,6 +465,7 @@ static struct tty_ldisc_ops nci_uart_ldisc = { .receive_buf = nci_uart_tty_receive, .write_wakeup = nci_uart_tty_wakeup, .ioctl = nci_uart_tty_ioctl, + .compat_ioctl = nci_uart_tty_ioctl, };static int __init nci_uart_init (void )
Arnd Bergmann
maintainerQuoted 10 lines · Al Viro
On Thu, Sep 13, 2018 at 10:56:48PM +0200, Arnd Bergmann wrote:
commit
de36af5ca465156863b5fb7548e3660ea7d3bbcfAuthor: Al Viro <[email protected]> Date: Thu Sep 13 22:12:15 2018 -0400change semantics of ldisc ->compat_ioctl()
First of all, make it return int. Returning long when native method had never allowed that is ridiculous and inconvenient.
Ack.
Quoted 7 lines
More importantly, change the caller; if ldisc ->compat_ioctl() is NULL or returns
-ENOIOCTLCMD,tty_compat_ioctl()will try to feed cmd andcompat_ptr(arg)to ldisc's native ->ioctl().That simplifies ->compat_ioctl() instances quite a bit - they only need to deal with ioctls that are neither generic tty ones (those would get shunted off to
tty_ioctl()) nor simple compat pointer ones.
This does sound very appealing, but there is a small downside:
The difference between ".compat_ioctl = NULL" and ".compat_ioctl=native_ioctl" is now very subtle, and I wouldn't necessarily expect casual readers to understand that.
If we go with my file_operations patch for generic_compat_ioctl_ptrarg and add generic_compat_ioctl_intarg, we can do the same thing here with ldisc_compat_ioctl_ptrarg/ldisc_compat_ioctl_intarg to make it a little more consistent with fops and self-documenting.
drivers/bluetooth/hci_ldisc.c static int __init hci_uart_init(void) · line 827
Quoted 12 lines
drivers/bluetooth/hci_ldisc.c +1
-0@@ -821,6 +821,7 @@ static int __init hci_uart_init(void) hci_uart_ldisc.read = hci_uart_tty_read; hci_uart_ldisc.write = hci_uart_tty_write; hci_uart_ldisc.ioctl = hci_uart_tty_ioctl; + hci_uart_ldisc.compat_ioctl = hci_uart_tty_ioctl; hci_uart_ldisc.poll = hci_uart_tty_poll; hci_uart_ldisc.receive_buf = hci_uart_tty_receive; hci_uart_ldisc.write_wakeup = hci_uart_tty_wakeup;
so this would become
hci_uart_ldisc.compat_ioctl = ldisc_compat_ioctl_intarg;
drivers/bluetooth/hci_ldisc.c static struct tty_ldisc_ops sp_ldisc = { · line 763
Quoted 13 lines
static struct
tty_ldisc_opssp_ldisc= {
.owner =THIS_MODULE,
.magic =TTY_LDISC_MAGIC,drivers/bluetooth/hci_ldisc.c +0
-3@@ -776,9 +758,6 @@ static struct tty_ldisc_ops sp_ldisc = { .open = sixpack_open, .close = sixpack_close, .ioctl = sixpack_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = sixpack_compat_ioctl, -#endif .receive_buf = sixpack_receive_buf, .write_wakeup = sixpack_write_wakeup, };
And this would be
.compat_ioctl = ldisc_compat_ioctl_ptrarg,
respectively
drivers/tty/tty_io.c static long tty_compat_ioctl(struct file *file, unsigned int cmd, · line 2830
Quoted 12 lines
drivers/tty/tty_io.c +3
-0@@ -2824,6 +2824,9 @@ static long tty_compat_ioctl(struct file *file, unsigned int cmd,return hung_up_tty_compat_ioctl (file, cmd, arg);if (ld->ops->compat_ioctl) retval = ld->ops->compat_ioctl (tty, file, cmd, arg); +if (retval == -ENOIOCTLCMD && ld->ops->ioctl) + retval = ld->ops->ioctl (tty, file, + (unsigned long )compat_ptr (cmd), arg);tty_ldisc_deref (ld);
The added fallback would still be useful in case someone forgets to add the .compat_ioctl assignment to a newly added ldisc.
Another idea I had for a final fallback would be
tty_ldisc_deref(ld);
+ if (retval == -ENOIOCTLCMD && _IOC_TYPE(cmd) == 'T') {
+ retval = tty_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
+ WARN_ON_ONCE(retval != -ENOIOCTLCMD && retval != -ENOTTY);
+ }
Seeing that you list every single 'T' command in tty_compat_ioctl() that we handle in the native case, that WARN_ON_ONCE should not trigger for any input, but it would catch (and warn about) any of those that might get added in the future to the native code path without the compat entry.
That might be too much -- if it gets easy enough to keep the code correct in the first place, there is no need.
Arnd
Re: [PATCH 11/50] ipwireless: switch to ->[sg]et_serial()
In reply to Al ViroQuoted 3 lines · Al Viro
From: Al Viro <[email protected]>
Signed-off-by Al Viro <[email protected]>
Johan Hovold
maintainerRe: [PATCH 05/50] tty_ioctl(): start taking TIOC[SG]SERIAL into separate methods
In reply to Al ViroQuoted 16 lines · Al Viro
From: Al Viro <[email protected]>
->set_serial() and ->get_serial() resp., both taking tty and a kernel pointer to
serial_struct.Signed-off-by Al Viro <[email protected]>--- drivers/tty/tty_io.c | 36 ++++++++++++++++++++++++++++++------ include/linux/tty_driver.h | 3 +++ 2 files changed, 33 insertions(+), 6 deletions(-)drivers/tty/tty_io.c +0
-0
drivers/tty/tty_io.c line 100
Quoted 4 lines
drivers/tty/tty_io.c +1
-0@@ -97,6 +97,7 @@#include <linux/seq_file.h> #include <linux/serial.h> #include <linux/ratelimit.h> +#include <linux/compat.h>
Looks like you don't need this (just yet anyway).
Quoted 5 lines
drivers/tty/tty_io.c +0
-0#include <linux/uaccess.h> @@ -2455,22 +2456,40 @@ static int tty_tiocgicount(struct tty_struct *tty, void __user *arg)return 0 ; }
[...]
drivers/tty/tty_io.c static int tty_tiocgicount(struct tty_struct *tty, void __user *arg) · line 2484
Quoted 4 lines
drivers/tty/tty_io.c +4
-0+static int tty_tiocgserial (struct tty_struct *tty,struct serial_struct __user *ss) +{ +struct serial_struct v; +int err;
Missing newline.
drivers/tty/tty_io.c static int tty_tiocgicount(struct tty_struct *tty, void __user *arg) · line 2487
Quoted 3 lines
drivers/tty/tty_io.c +3
-0+memset (&v,0 ,sizeof (struct serial_struct )); + +if (!tty->ops->set_serial)
You want get_serial here.
Quoted 9 lines
drivers/tty/tty_io.c +5
-0+return -ENOIOCTLCMD ; + err = tty->ops->get_serial (tty, &v); +if (!err &©_to_user (ss, &v,sizeof (struct serial_struct ))) + err = -EFAULT ; +return err; }/*
drivers/tty/tty_io.c long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · line 2626
Quoted 8 lines
drivers/tty/tty_io.c +3
-2@@ -2602,8 +2621,13 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) }break ;case TIOCSSERIAL : -tty_warn_deprecated_flags (p); -break ; + retval =tty_tiocsserial (tty, p); +if (retval != -ENOIOCTLCMD ) +return retval;
Missing break.
drivers/tty/tty_io.c long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · line 2630
Quoted 4 lines
drivers/tty/tty_io.c +4
-0+case TIOCGSERIAL : + retval =tty_tiocgserial (tty, p); +if (retval != -ENOIOCTLCMD ) +return retval;
Missing break.
drivers/tty/tty_io.c long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · line 2633
Quoted 3 lines
drivers/tty/tty_io.c +0
-0case TIOCGPTPEER :/* Special because the struct file is needed */ return ptm_open_peer (file, tty, (int )arg);
Johan
Re: [PATCH 04/50] mos7720: bury dead TIOCM... in ->ioctl()
In reply to Al ViroQuoted 8 lines · Al Viro
From: Al Viro <[email protected]>
These ioctls never reach driver's ->ioctl() -
tty_ioctl()handles them on its own. ->tiocm[gs]et() is what actually gets called, and mos7720 provides those, with results equivalent to what the unreachable code would be doing when called.Signed-off-by Al Viro <[email protected]>
Re: [PATCH 08/50] greybus/uart: switch to ->[sg]et_serial()
In reply to Al ViroQuoted 3 lines · Al Viro
From: Al Viro <[email protected]>
Signed-off-by Al Viro <[email protected]>
Re: [PATCH 17/50] usb-serial: begin switching to ->[sg]et_serial()
In reply to Al ViroQuoted 20 lines · Al Viro
From: Al Viro <[email protected]>
add such methods for
usb_serial_driver, providetty_operations->[sg]et_serial() calling those. For now the lack of methods in driver means ENOIOCTLCMD from usb-serial ->[sg]et_serial(), makingtty_ioctl()fall back to calling ->ioctl(). Once all drivers are converted, we'll be returning-ENOTTYinstead, completing the switchover.Signed-off-by Al Viro <[email protected]>--- drivers/usb/serial/usb-serial.c | 18 ++++++++++++++++++ include/linux/usb/serial.h | 2 ++ 2 files changed, 20 insertions(+)drivers/usb/serial/usb-serial.c +0
-0
drivers/usb/serial/usb-serial.c static void serial_unthrottle(struct tty_struct *tty) · line 401
Quoted 6 lines
drivers/usb/serial/usb-serial.c +3
-0@@ -396,6 +396,22 @@ static void serial_unthrottle(struct tty_struct *tty) port->serial->type->unthrottle (tty); } +static int serial_get_serial (struct tty_struct *tty,struct serial_struct *ss) +{ +struct usb_serial_port *port = tty->driver_data;
Pleas add a newline here.
drivers/usb/serial/usb-serial.c static void serial_unthrottle(struct tty_struct *tty) · line 409
Quoted 8 lines
drivers/usb/serial/usb-serial.c +8
-0+if (port->serial->type->get_serial) +return port->serial->type->get_serial (tty, ss); +return -ENOIOCTLCMD ; +} + +static int serial_set_serial (struct tty_struct *tty,struct serial_struct *ss) +{ +struct usb_serial_port *port = tty->driver_data;
And here.
drivers/usb/serial/usb-serial.c static void serial_unthrottle(struct tty_struct *tty) · line 413
Quoted 4 lines
drivers/usb/serial/usb-serial.c +4
-0+if (port->serial->type->set_serial) +return port->serial->type->get_serial (tty, ss); +return -ENOIOCTLCMD ; +}
Re: [PATCH 19/50] ark3116: switch to ->get_serial()
In reply to Al ViroQuoted 3 lines · Al Viro
From: Al Viro <[email protected]>
Signed-off-by Al Viro <[email protected]>
Re: [PATCH 20/50] f81232: switch to ->get_serial()
In reply to Al ViroQuoted 3 lines · Al Viro
From: Al Viro <[email protected]>
Signed-off-by Al Viro <[email protected]>
Re: [PATCH 21/50] f81534: switch to ->get_serial()
In reply to Al ViroQuoted 3 lines · Al Viro
From: Al Viro <[email protected]>
Signed-off-by Al Viro <[email protected]>
Re: [PATCH 22/50] fdti_sio: switch to ->[sg]et_serial()
In reply to Al ViroQuoted 3 lines · Al Viro
From: Al Viro <[email protected]>
Signed-off-by Al Viro <[email protected]>
Re: [PATCH 23/50] io_edgeport: switch to ->get_serial()
In reply to Al ViroQuoted 13 lines · Al Viro
From: Al Viro <[email protected]>
Signed-off-by Al Viro <[email protected]>--- drivers/usb/serial/io_edgeport.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-)drivers/usb/serial/io_edgeport.c +0
-0
drivers/usb/serial/io_edgeport.c static int edge_ioctl(struct tty_struct *tty, · line 1670
Quoted 4 lines
drivers/usb/serial/io_edgeport.c +0
-1@@ -1667,17 +1663,12 @@ static int edge_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) {struct usb_serial_port *port = tty->driver_data; -DEFINE_WAIT (wait);
hmm, why was there no gcc warning about this leftover?
drivers/usb/serial/io_edgeport.c static int edge_ioctl(struct tty_struct *tty, · line 1674
Quoted 13 lines
drivers/usb/serial/io_edgeport.c +0
-4struct edgeport_port *edge_port =usb_get_serial_port_data (port);switch (cmd) {case TIOCSERGETLSR :dev_dbg (&port->dev,"%s TIOCSERGETLSR\n" , __func__);return get_lsr_info (edge_port, (unsigned int __user *) arg); - -case TIOCGSERIAL : -dev_dbg (&port->dev,"%s TIOCGSERIAL\n" , __func__); -return get_serial_info (edge_port, (struct serial_struct __user *) arg); }return -ENOIOCTLCMD ; }
Re: [PATCH 24/50] io_ti: switch to ->get_serial()
In reply to Al ViroQuoted 3 lines · Al Viro
From: Al Viro <[email protected]>
Signed-off-by Al Viro <[email protected]>
Re: [PATCH 25/50] mos7720: switch to ->get_serial()
In reply to Al ViroQuoted 27 lines · Al Viro
From: Al Viro <[email protected]>
Signed-off-by Al Viro <[email protected]>--- drivers/usb/serial/mos7720.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-)drivers/usb/serial/mos7720.c +2
-9@@ -1786,24 +1786,22 @@ static int mos7720_tiocmset(struct tty_struct *tty,return 0 ; } -static int get_serial_info (struct moschip_port *mos7720_port, -struct serial_struct __user *retinfo) +static int get_serial_info (struct tty_struct *tty, +struct serial_struct *ss) { -struct serial_struct tmp; - -memset (&tmp,0 ,sizeof (tmp)); - - tmp.type =PORT_16550A ; - tmp.line = mos7720_port->port->minor; - tmp.port = mos7720_port->port->port_number;
drivers/usb/serial/mos7720.c static int mos7720_tiocmset(struct tty_struct *tty, · line 1793
Quoted 10 lines
drivers/usb/serial/mos7720.c +2
-8- tmp.irq =0 ; - tmp.xmit_fifo_size =NUM_URBS *URB_TRANSFER_BUFFER_SIZE ; - tmp.baud_base =9600 ; - tmp.close_delay =5 *HZ ; - tmp.closing_wait =30 *HZ ; - -if (copy_to_user (retinfo, &tmp,sizeof (*retinfo))) -return -EFAULT ; +struct usb_serial_port *port = tty->driver_data; +struct moschip_port *mos7720_port;
Newline please.
drivers/usb/serial/mos7720.c static int mos7720_tiocmset(struct tty_struct *tty, · line 1796
Quoted 3 lines
drivers/usb/serial/mos7720.c +3
-0+ mos7720_port =usb_get_serial_port_data (port); +if (mos7720_port ==NULL ) +return -ENODEV ;
And no need to check for NULL, even if the current ioctl does so...
drivers/usb/serial/mos7720.c static int mos7720_tiocmset(struct tty_struct *tty, · line 1806
Quoted 10 lines
drivers/usb/serial/mos7720.c +8
-0+ ss->type =PORT_16550A ; + ss->line = mos7720_port->port->minor; + ss->port = mos7720_port->port->port_number; + ss->irq =0 ; + ss->xmit_fifo_size =NUM_URBS *URB_TRANSFER_BUFFER_SIZE ; + ss->baud_base =9600 ; + ss->close_delay =5 *HZ ; + ss->closing_wait =30 *HZ ;return 0 ; }
Re: [PATCH 26/50] mos7840: switch to ->get_serial()
In reply to Al ViroQuoted 17 lines · Al Viro
From: Al Viro <[email protected]>
Signed-off-by Al Viro <[email protected]>--- drivers/usb/serial/mos7840.c | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-)drivers/usb/serial/mos7840.c +0
-2@@ -1931,27 +1931,27 @@ static int mos7840_get_lsr_info(struct tty_struct *tty,* function to get information about serial port *****************************************************************************/ -static int mos7840_get_serial_info (struct moschip_port *mos7840_port, -struct serial_struct __user *retinfo)
drivers/usb/serial/mos7840.c static int mos7840_get_lsr_info(struct tty_struct *tty, · line 1941
Quoted 10 lines
drivers/usb/serial/mos7840.c +5
-2+static int mos7840_get_serial_info (struct tty_struct *tty, +struct serial_struct *ss) { -struct serial_struct tmp; +struct usb_serial_port *port = tty->driver_data; +struct moschip_port *mos7840_port; -if (mos7840_port ==NULL ) +if (mos7840_port_paranoia_check (port, __func__))return -1 ;
This really isn't necessary either even if you're just mimicking the current ioctl code.
Quoted 4 lines
drivers/usb/serial/mos7840.c +0
-3-memset (&tmp,0 ,sizeof (tmp)); - - tmp.type =PORT_16550A ;
drivers/usb/serial/mos7840.c static int mos7840_get_lsr_info(struct tty_struct *tty, · line 1945
Quoted 10 lines
drivers/usb/serial/mos7840.c +3
-7- tmp.line = mos7840_port->port->minor; - tmp.port = mos7840_port->port->port_number; - tmp.irq =0 ; - tmp.xmit_fifo_size =NUM_URBS *URB_TRANSFER_BUFFER_SIZE ; - tmp.baud_base =9600 ; - tmp.close_delay =5 *HZ ; - tmp.closing_wait =30 *HZ ; + mos7840_port =mos7840_get_port_private (port); +if (mos7840_port ==NULL ) +return -1 ;
Same here.
drivers/usb/serial/mos7840.c static int mos7840_get_lsr_info(struct tty_struct *tty, · line 1956
Quoted 12 lines
drivers/usb/serial/mos7840.c +8
-2-if (copy_to_user (retinfo, &tmp,sizeof (*retinfo))) -return -EFAULT ; + ss->type =PORT_16550A ; + ss->line = mos7840_port->port->minor; + ss->port = mos7840_port->port->port_number; + ss->irq =0 ; + ss->xmit_fifo_size =NUM_URBS *URB_TRANSFER_BUFFER_SIZE ; + ss->baud_base =9600 ; + ss->close_delay =5 *HZ ; + ss->closing_wait =30 *HZ ;return 0 ; }
Re: [PATCH 27/50] opticon: switch to ->get_serial()
In reply to Al ViroQuoted 3 lines · Al Viro
From: Al Viro <[email protected]>
Signed-off-by Al Viro <[email protected]>
Re: [PATCH 28/50] pl2303: switch to ->get_serial()
In reply to Al ViroQuoted 3 lines · Al Viro
From: Al Viro <[email protected]>
Signed-off-by Al Viro <[email protected]>
Re: [PATCH 29/50] quatech2: switch to ->get_serial()
In reply to Al ViroQuoted 3 lines · Al Viro
From: Al Viro <[email protected]>
Signed-off-by Al Viro <[email protected]>
Re: [PATCH 30/50] ssu100: switch to ->get_serial()
In reply to Al ViroQuoted 3 lines · Al Viro
From: Al Viro <[email protected]>
Signed-off-by Al Viro <[email protected]>
Re: [PATCH 31/50] ti_usb_3410_5052: switch to ->[sg]et_serial()
In reply to Al ViroQuoted 3 lines · Al Viro
From: Al Viro <[email protected]>
Signed-off-by Al Viro <[email protected]>
Re: [PATCH 32/50] whiteheat: switch to ->get_serial()
In reply to Al ViroQuoted 6 lines · Al Viro
From: Al Viro <[email protected]>
... and fix the return value - on success it used to have ioctl(2) fill the user-supplied struct
serial_structand return-ENOTTY.Signed-off-by Al Viro <[email protected]>
Re: [PATCH 33/50] usb_wwan: switch to ->[sg]et_serial()
In reply to Al ViroQuoted 3 lines · Al Viro
From: Al Viro <[email protected]>
Signed-off-by Al Viro <[email protected]>
Re: [PATCH 34/50] complete ->[sg]et_serial() switchover
In reply to Al ViroQuoted 3 lines · Al Viro
From: Al Viro <[email protected]>
Signed-off-by Al Viro <[email protected]>
Re: [PATCH 42/50] remove fallback to drivers for TIOCGICOUNT
In reply to Al ViroQuoted 5 lines · Al Viro
From: Al Viro <[email protected]>
none of them handles it anyway.
Signed-off-by Al Viro <[email protected]>
Al Viro
maintainerQuoted 4 lines · Arnd Bergmann
This does sound very appealing, but there is a small downside:
The difference between ".compat_ioctl = NULL" and ".compat_ioctl=native_ioctl" is now very subtle, and I wouldn't necessarily expect casual readers to understand that.
???
One is "all non-generics take pointers to wordsize-neutral objects", another "all non-generics take integers".
That solution certainly needs to be documented more than just in commit message, though; IMO the method descriptions next to declaration are the best place for that. Will update...
Quoted 4 lines
If we go with my
file_operationspatch forgeneric_compat_ioctl_ptrargand addgeneric_compat_ioctl_intarg, we can do the same thing here with ldisc_compat_ioctl_ptrarg/ldisc_compat_ioctl_intarg to make it a little more consistent with fops and self-documenting.
No, we can't - ldisc ->ioctl() (or ->compat_ioctl()) doesn't get ldisc in arguments. Besides, indirect calls are costly these days...
Quoted 10 lines
(quoted diff) +4
-0+ if (retval == -ENOIOCTLCMD && _IOC_TYPE(cmd) == 'T') { + retval = tty_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); + WARN_ON_ONCE(retval != -ENOIOCTLCMD && retval != -ENOTTY); + }Seeing that you list every single 'T' command in
tty_compat_ioctl()that we handle in the native case, thatWARN_ON_ONCEshould not trigger for any input, but it would catch (and warn about) any of those that might get added in the future to the native code path without the compat entry.
Anything adding new ioctls needs careful review anyway. And blind bets upon that stuff taking compat pointer are, AFAICS, completely unfounded.
Arnd Bergmann
maintainerRe: [PATCH 02/50] move compat handling of tty ioctls to tty_compat_ioctl()
In reply to Al ViroQuoted 13 lines · Al Viro
From: Al Viro <[email protected]>
ioctls that are
* callable only viatty_ioctl()
* not driver-specific
* not demand data structure conversions
* either always need passing arg as is or always demandcompat_ptr()
get intercepted intty_compat_ioctl()from the very beginning and redirecter totty_ioctl(). As the result, their entries infs/compat_ioctl.c(some of those had been missing, BTW) got removed, as well asn_tty_compat_ioctl_helper()(now it's never called with any cmd it would accept).
Quoted 1 line
Signed-off-by Al Viro <[email protected]>
One more thing I just remembered when looking at my obsolete patches:
Your patch is fixing a couple of ioctl commands (I had identified only TIOCVHANGUP and TIOCGPTPEER, you found a couple more)
It would be good to mark those as cc:[email protected] so we can also get the fixes into older kernels. Looking through the series again, I did not spot anything else that we need in stable, in particular I would not bother with the compat_ptr() fixups there, and the many cleanups of dead code and setserial wouldn't be stable material anyway, but missing translation seems important enough.
Looking at the changes in your patches, these are the ones that you add in tty_compat_ioctl() that did not have a corresponding entry in fs/compat_ioctl.c:
+ case TCSETX: + case TCSETXF: + case TCSETXW: + case TIOCGETC: + case TIOCGETP: + case TIOCGPTPEER: + case TIOCSERCONFIG: + case TIOCSETC: + case TIOCSETN: + case TIOCSETP: + case TIOCVHANGUP:
Should these all be added in a stable backport patch?
Arnd
Al Viro
maintainerRe: [PATCH 05/50] tty_ioctl(): start taking TIOC[SG]SERIAL into separate methods
In reply to Johan HovoldQuoted 12 lines · Johan Hovold
Quoted 11 lines · Al Viro
From: Al Viro <[email protected]>
->set_serial() and ->get_serial() resp., both taking tty and a kernel pointer to
serial_struct.Signed-off-by Al Viro <[email protected]>--- drivers/tty/tty_io.c | 36 ++++++++++++++++++++++++++++++------ include/linux/tty_driver.h | 3 +++ 2 files changed, 33 insertions(+), 6 deletions(-)
Quoted 11 lines
drivers/tty/tty_io.c line 100
Quoted 9 lines
drivers/tty/tty_io.c +1
-0@@ -97,6 +97,7 @@#include <linux/seq_file.h> #include <linux/serial.h> #include <linux/ratelimit.h> +#include <linux/compat.h> Looks like you don't need this (just yet anyway).
Actually, that should've been added several commits earlier ;-)
Quoted 8 lines
Quoted 5 lines
drivers/tty/tty_io.c +0
-0#include <linux/uaccess.h> @@ -2455,22 +2456,40 @@ static int tty_tiocgicount(struct tty_struct *tty, void __user *arg)return 0 ; }[...]
Quoted 6 lines
drivers/tty/tty_io.c static int tty_tiocgicount(struct tty_struct *tty, void __user *arg) · line 2484
Quoted 4 lines
drivers/tty/tty_io.c +4
-0+static int tty_tiocgserial (struct tty_struct *tty,struct serial_struct __user *ss) +{ +struct serial_struct v; +int err;Missing newline.
Umm... Matter of taste, but since you work in that area more often than I do... Note, BTW, that tty_tiocgicount() just a bit above that place also doesn't follow that style. Anyway, I don't care either way - if you want an empty line in that, no problem.
Quoted 5 lines
drivers/tty/tty_io.c static int tty_tiocgicount(struct tty_struct *tty, void __user *arg) · line 2487
Quoted 3 lines
drivers/tty/tty_io.c +3
-0+memset (&v,0 ,sizeof (struct serial_struct )); + +if (!tty->ops->set_serial)You want
get_serialhere.
Nice catch. Fixed.
Quoted 7 lines
Quoted 7 lines
drivers/tty/tty_io.c +5
-0+return -ENOIOCTLCMD ; + err = tty->ops->get_serial (tty, &v); +if (!err &©_to_user (ss, &v,sizeof (struct serial_struct ))) + err = -EFAULT ; +return err; }
Quoted 12 lines
drivers/tty/tty_io.c long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · line 2626
Quoted 10 lines
/*
drivers/tty/tty_io.c +3
-2@@ -2602,8 +2621,13 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) }break ;case TIOCSSERIAL : -tty_warn_deprecated_flags (p); -break ; + retval =tty_tiocsserial (tty, p); +if (retval != -ENOIOCTLCMD ) +return retval;Missing break.
*blink*
Right you are... that's a bisect hazard (in the end of the series returns become unconditional anyway). Fixed.
Al Viro
maintainerRe: [PATCH 17/50] usb-serial: begin switching to ->[sg]et_serial()
In reply to Johan HovoldQuoted 11 lines · Johan Hovold
drivers/usb/serial/usb-serial.c static void serial_unthrottle(struct tty_struct *tty) · line 409
Quoted 8 lines
drivers/usb/serial/usb-serial.c +8
-0+if (port->serial->type->get_serial) +return port->serial->type->get_serial (tty, ss); +return -ENOIOCTLCMD ; +} + +static int serial_set_serial (struct tty_struct *tty,struct serial_struct *ss) +{ +struct usb_serial_port *port = tty->driver_data;And here.
Quoted 2 lines
drivers/usb/serial/usb-serial.c static void serial_unthrottle(struct tty_struct *tty) · line 411
Quoted 2 lines
drivers/usb/serial/usb-serial.c +2
-0+if (port->serial->type->set_serial) +return port->serial->type->get_serial (tty, ss);
... and another cut'n'paste braino - it's set_serial, of course.
Johan Hovold
maintainerRe: [PATCH 17/50] usb-serial: begin switching to ->[sg]et_serial()
Quoted 12 lines · Al Viro
Quoted 11 lines · Johan Hovold
drivers/usb/serial/usb-serial.c static void serial_unthrottle(struct tty_struct *tty) · line 409
Quoted 8 lines
drivers/usb/serial/usb-serial.c +8
-0+if (port->serial->type->get_serial) +return port->serial->type->get_serial (tty, ss); +return -ENOIOCTLCMD ; +} + +static int serial_set_serial (struct tty_struct *tty,struct serial_struct *ss) +{ +struct usb_serial_port *port = tty->driver_data;And here.
Quoted 4 lines
Quoted 2 lines
drivers/usb/serial/usb-serial.c static void serial_unthrottle(struct tty_struct *tty) · line 411
Quoted 2 lines
drivers/usb/serial/usb-serial.c +2
-0+if (port->serial->type->set_serial) +return port->serial->type->get_serial (tty, ss);... and another cut'n'paste braino - it's
set_serial, of course.
Bah, I thought I'd checked them all. :)
Thanks,
Johan
Arnd Bergmann
maintainerQuoted 8 lines · Al Viro
Quoted 4 lines · Arnd Bergmann
This does sound very appealing, but there is a small downside:
The difference between ".compat_ioctl = NULL" and ".compat_ioctl=native_ioctl" is now very subtle, and I wouldn't necessarily expect casual readers to understand that.
Quoted 4 lines
???
One is "all non-generics take pointers to wordsize-neutral objects", another "all non-generics take integers".
Yes, I understand that distinction, I'm just trying to look at it from teh perspective of the majority of developers that roughtly understand what compat mode is but have never deal with arch/s390 and compat_ptr() conversion but simply try to get stuff working.
Quoted 3 lines
That solution certainly needs to be documented more than just in commit message, though; IMO the method descriptions next to declaration are the best place for that. Will update...
That helps of course.
Quoted 7 lines
Quoted 4 lines
If we go with my
file_operationspatch forgeneric_compat_ioctl_ptrargand addgeneric_compat_ioctl_intarg, we can do the same thing here with ldisc_compat_ioctl_ptrarg/ldisc_compat_ioctl_intarg to make it a little more consistent with fops and self-documenting.No, we can't - ldisc ->ioctl() (or ->compat_ioctl()) doesn't get ldisc in arguments. Besides, indirect calls are costly these days...
Ah right. I suppose the argument list could be changed, or we could call tty_ldisc_ref()/tty_ldisc_deref() again (not sure if that's safe when we already hold the reference).
Quoted 5 lines
Quoted 5 lines
(quoted diff) +4
-0+ if (retval == -ENOIOCTLCMD && _IOC_TYPE(cmd) == 'T') { + retval = tty_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); + WARN_ON_ONCE(retval != -ENOIOCTLCMD && retval != -ENOTTY); + }
Quoted 8 lines
Quoted 5 lines
Seeing that you list every single 'T' command in
tty_compat_ioctl()that we handle in the native case, thatWARN_ON_ONCEshould not trigger for any input, but it would catch (and warn about) any of those that might get added in the future to the native code path without the compat entry.Anything adding new ioctls needs careful review anyway. And blind bets upon that stuff taking compat pointer are, AFAICS, completely unfounded.
I was basing it only on statistics: only two commands out of the whole set take a translation, and the worst case that would happen if we add a new command without a compat handler is that user space doesn't get what it wants but we do get the WARN_ON. In comparison, without that check, user space never gets what it wants for that command (always -ENOTTY) but no indication that this is a kernel bug.
Arnd
Re: [PATCH 05/50] tty_ioctl(): start taking TIOC[SG]SERIAL into separate methods
In reply to Al ViroQuoted 46 lines · Al Viro
Quoted 17 lines · Johan Hovold
Quoted 15 lines · Al Viro
From: Al Viro <[email protected]>
->set_serial() and ->get_serial() resp., both taking tty and a kernel pointer to
serial_struct.Signed-off-by Al Viro <[email protected]>--- drivers/tty/tty_io.c | 36 ++++++++++++++++++++++++++++++------ include/linux/tty_driver.h | 3 +++ 2 files changed, 33 insertions(+), 6 deletions(-)drivers/tty/tty_io.c +0
-0Quoted 5 lines
drivers/tty/tty_io.c static int tty_tiocgicount(struct tty_struct *tty, void __user *arg) · line 2487
Quoted 3 lines
drivers/tty/tty_io.c +3
-0+memset (&v,0 ,sizeof (struct serial_struct )); + +if (!tty->ops->set_serial)You want
get_serialhere.Nice catch. Fixed.
Quoted 7 lines
Quoted 7 lines
drivers/tty/tty_io.c +5
-0+return -ENOIOCTLCMD ; + err = tty->ops->get_serial (tty, &v); +if (!err &©_to_user (ss, &v,sizeof (struct serial_struct ))) + err = -EFAULT ; +return err; }Quoted 12 lines
drivers/tty/tty_io.c long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · line 2626
Quoted 10 lines
/*
drivers/tty/tty_io.c +3
-2@@ -2602,8 +2621,13 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) }break ;case TIOCSSERIAL : -tty_warn_deprecated_flags (p); -break ; + retval =tty_tiocsserial (tty, p); +if (retval != -ENOIOCTLCMD ) +return retval;Missing break.
Quoted 3 lines
*blink*
Right you are... that's a bisect hazard (in the end of the series returns become unconditional anyway). Fixed.
What's in your work branch now looks good, so feel free to add:
Thanks,
Johan
gregkh
maintainerRe: [PATCH 02/50] move compat handling of tty ioctls to tty_compat_ioctl()
In reply to Arnd BergmannQuoted 44 lines · Arnd Bergmann
Quoted 13 lines · Al Viro
From: Al Viro <[email protected]>
ioctls that are
* callable only viatty_ioctl()
* not driver-specific
* not demand data structure conversions
* either always need passing arg as is or always demandcompat_ptr()
get intercepted intty_compat_ioctl()from the very beginning and redirecter totty_ioctl(). As the result, their entries infs/compat_ioctl.c(some of those had been missing, BTW) got removed, as well asn_tty_compat_ioctl_helper()(now it's never called with any cmd it would accept).Quoted 1 line
Signed-off-by Al Viro <[email protected]>One more thing I just remembered when looking at my obsolete patches:
Your patch is fixing a couple of ioctl commands (I had identified only TIOCVHANGUP and TIOCGPTPEER, you found a couple more)It would be good to mark those as cc:[email protected] so we can also get the fixes into older kernels. Looking through the series again, I did not spot anything else that we need in stable, in particular I would not bother with the
compat_ptr()fixups there, and the many cleanups of dead code and setserial wouldn't be stable material anyway, but missing translation seems important enough.Looking at the changes in your patches, these are the ones that you add in
tty_compat_ioctl()that did not have a corresponding entry infs/compat_ioctl.c:(quoted diff) +11
-0+ case TCSETX: + case TCSETXF: + case TCSETXW: + case TIOCGETC: + case TIOCGETP: + case TIOCGPTPEER: + case TIOCSERCONFIG: + case TIOCSETC: + case TIOCSETN: + case TIOCSETP: + case TIOCVHANGUP:
Quoted 1 line
Should these all be added in a stable backport patch?
Why? What is being "fixed" here that anyone has noticed before that is causing problems in those old kernels? If no one has complained about the lack of compat fixups, well... :)
thanks,
greg k-h
Arnd Bergmann
maintainerRe: [PATCH 02/50] move compat handling of tty ioctls to tty_compat_ioctl()
Quoted 16 lines · gregkh
Quoted 14 lines · Arnd Bergmann
On Thu, Sep 13, 2018 at 4:40 AM Al Viro <[email protected]> wrote:
(quoted diff) +11
-0+ case TCSETX: + case TCSETXF: + case TCSETXW: + case TIOCGETC: + case TIOCGETP: + case TIOCGPTPEER: + case TIOCSERCONFIG: + case TIOCSETC: + case TIOCSETN: + case TIOCSETP: + case TIOCVHANGUP:
Quoted 5 lines
Quoted 1 line
Should these all be added in a stable backport patch?
Why? What is being "fixed" here that anyone has noticed before that is causing problems in those old kernels? If no one has complained about the lack of compat fixups, well... :)
Most of the individual ones don't matter:
TCSETX/TCSETXF/TCSETXW/TCGETX never did anything, we don't care about them.
TIOCSERCONFIG has always been broken in compat mode, not sure who calls it in practice. This is 'setserial autoconfig'.
TIOCGETC/TIOCGETP/TIOCSETC/TIOCSETN/TIOCSETP
are only defined on alpha, mips, powerpc and sparc to start with. They seem to only be there for compatibility with some Unix version for those architectures but were never part of the normal Linux API or the compat set, so I guess they also don't matter.
The two that I think we may care about are:
TIOCGPTPEER is a fairly recent regression from commit 311fc65c9fb9 ("pty: Repair TIOCGPTPEER") in 4.14 after it was added in 4.13.
TIOCVHANGUP was introduced to be used by systemd in commit 3c95c985fa91 ("tty: add TIOCVHANGUP to allow clean tty shutdown of all ttys").
https://raspberrypi.stackexchange.com/questions/54143
has a bug report noting a problem with Raspbian systemd that was related to TIOCVHANGUP. I don't think it's the missing compat line that caused it, but the same system would try to run TIOCVHANGUP in compat mode on Raspberry Pi3 when using a 64-bit kernel with raspbian, so there are definitely callers.
Arnd
gregkh
maintainerRe: [PATCH 02/50] move compat handling of tty ioctls to tty_compat_ioctl()
Quoted 44 lines · Arnd Bergmann
Quoted 16 lines · gregkh
Quoted 14 lines · Arnd Bergmann
On Thu, Sep 13, 2018 at 4:40 AM Al Viro <[email protected]> wrote:
(quoted diff) +11
-0+ case TCSETX: + case TCSETXF: + case TCSETXW: + case TIOCGETC: + case TIOCGETP: + case TIOCGPTPEER: + case TIOCSERCONFIG: + case TIOCSETC: + case TIOCSETN: + case TIOCSETP: + case TIOCVHANGUP:Quoted 5 lines
Quoted 1 line
Should these all be added in a stable backport patch?
Why? What is being "fixed" here that anyone has noticed before that is causing problems in those old kernels? If no one has complained about the lack of compat fixups, well... :)
Most of the individual ones don't matter:
TCSETX/TCSETXF/TCSETXW/TCGETX never did anything, we don't care about them.
TIOCSERCONFIG has always been broken in compat mode, not sure who calls it in practice. This is 'setserial autoconfig'.
TIOCGETC/TIOCGETP/TIOCSETC/TIOCSETN/TIOCSETP
are only defined on alpha, mips, powerpc and sparc to start with. They seem to only be there for compatibility with some Unix version for those architectures but were never part of the normal Linux API or the compat set, so I guess they also don't matter.The two that I think we may care about are:
TIOCGPTPEER is a fairly recent regression from commit
311fc65c9fb9("pty: Repair TIOCGPTPEER") in 4.14 after it was added in 4.13.
Quoted 10 lines
TIOCVHANGUP was introduced to be used by systemd in commit
3c95c985fa91("tty: add TIOCVHANGUP to allow clean tty shutdown of all ttys").
https://raspberrypi.stackexchange.com/questions/54143
has a bug report noting a problem with Raspbian systemd that was related to TIOCVHANGUP. I don't think it's the missing compat line that caused it, but the same system would try to run TIOCVHANGUP in compat mode on Raspberry Pi3 when using a 64-bit kernel with raspbian, so there are definitely callers.
Ah, ok, that makes sense, I forgot about the new ioctls and didn't realize it was a regression.
greg k-h
Re: [PATCH 09/50] amiserial: switch to ->[sg]et_serial()
In reply to Al ViroHi Al,
Quoted 6 lines · Al Viro
From: Al Viro <[email protected]>
Signed-off-by Al Viro <[email protected]>
drivers/tty/amiserial.c static void rs_unthrottle(struct tty_struct * tty) · line 1026
Quoted 10 lines
drivers/tty/amiserial.c +2
-4-static int set_serial_info (struct tty_struct *tty,struct serial_state *state, -struct serial_struct __user * new_info) +static int set_serial_info (struct tty_struct *tty,struct serial_struct *ss) { +struct serial_state *state = tty->driver_data;struct tty_port *port = &state->tport; -struct serial_struct new_serial;bool change_spd; -int retval =0 ;
"retval" is still used...
Quoted 72 lines
drivers/tty/amiserial.c +19
-19-if (copy_from_user (&new_serial,new_info,sizeof (new_serial))) -return -EFAULT ; +if (serial_paranoia_check (state, tty->name,"rs_ioctl" )) +return -ENODEV ;tty_lock (tty); - change_spd = ((new_serial.flags ^ port->flags) &ASYNC_SPD_MASK ) || - new_serial.custom_divisor != state->custom_divisor; -if (new_serial.irq || new_serial.port != state->port || - new_serial.xmit_fifo_size != state->xmit_fifo_size) { + change_spd = ((ss->flags ^ port->flags) &ASYNC_SPD_MASK ) || + ss->custom_divisor != state->custom_divisor; +if (ss->irq || ss->port != state->port || + ss->xmit_fifo_size != state->xmit_fifo_size) {tty_unlock (tty);return -EINVAL ; }if (!serial_isroot ()) { -if ((new_serial.baud_base != state->baud_base) || - (new_serial.close_delay != port->close_delay) || - (new_serial.xmit_fifo_size != state->xmit_fifo_size) || - ((new_serial.flags & ~ASYNC_USR_MASK ) != +if ((ss->baud_base != state->baud_base) || + (ss->close_delay != port->close_delay) || + (ss->xmit_fifo_size != state->xmit_fifo_size) || + ((ss->flags & ~ASYNC_USR_MASK ) != (port->flags & ~ASYNC_USR_MASK ))) {tty_unlock (tty);return -EPERM ; } port->flags = ((port->flags & ~ASYNC_USR_MASK ) | - (new_serial.flags &ASYNC_USR_MASK )); - state->custom_divisor = new_serial.custom_divisor; + (ss->flags &ASYNC_USR_MASK )); + state->custom_divisor = ss->custom_divisor; goto check_and_exit; } -if (new_serial.baud_base <9600 ) { +if (ss->baud_base <9600 ) {tty_unlock (tty);return -EINVAL ; }@@ -1062,19 +1059,19 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,* At this point, we start making changes..... */ - state->baud_base = new_serial.baud_base; + state->baud_base = ss->baud_base; port->flags = ((port->flags & ~ASYNC_FLAGS ) | - (new_serial.flags &ASYNC_FLAGS )); - state->custom_divisor = new_serial.custom_divisor; - port->close_delay = new_serial.close_delay *HZ /100 ; - port->closing_wait = new_serial.closing_wait *HZ /100 ; + (ss->flags &ASYNC_FLAGS )); + state->custom_divisor = ss->custom_divisor; + port->close_delay = ss->close_delay *HZ /100 ; + port->closing_wait = ss->closing_wait *HZ /100 ; port->low_latency = (port->flags &ASYNC_LOW_LATENCY ) ?1 :0 ; check_and_exit:if (tty_port_initialized (port)) {if (change_spd) {/* warn about deprecation unless clearing */ -if (new_serial.flags &ASYNC_SPD_MASK ) +if (ss->flags &ASYNC_SPD_MASK )dev_warn_ratelimited (tty->dev,"use of SPD flags is deprecated\n" );change_speed (tty, state,NULL ); }
drivers/tty/amiserial.c static int set_serial_info(struct tty_struct *tty, struct serial_state *state, · line 1081
Quoted 1 line
drivers/tty/amiserial.c +0
-0@@ -1084,7 +1081,6 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,return retval;
... here, and in the line above (out of context). leading to
drivers/tty/amiserial.c:1076:3: error: 'retval' undeclared (first use in this function)
http://kisskb.ellerman.id.au/kisskb/buildresult/13544535/
http://kisskb.ellerman.id.au/kisskb/buildresult/13544413/
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Al Viro
maintainerRe: [PATCH 09/50] amiserial: switch to ->[sg]et_serial()
Quoted 5 lines · Geert Uytterhoeven
drivers/tty/amiserial.c:1076:3: error: 'retval' undeclared (first use in this function)http://kisskb.ellerman.id.au/kisskb/buildresult/13544535/
http://kisskb.ellerman.id.au/kisskb/buildresult/13544413/
Fixed and folded.