USB: serial: fix invalid user-pointer checks
Subsystems (2)
Johan Hovold
maintainerPATCH 1/1 USB: serial: fix invalid user-pointer checks
Drop invalid user-pointer checks from ioctl handlers.
A NULL-pointer can be valid in user space and copy_to_user() takes care of sanity checking.
--- drivers/usb/serial/ftdi_sio.c | 5 ----- drivers/usb/serial/io_edgeport.c | 3 --- drivers/usb/serial/io_ti.c | 3 --- drivers/usb/serial/mos7720.c | 3 --- drivers/usb/serial/mos7840.c | 3 --- drivers/usb/serial/opticon.c | 3 --- drivers/usb/serial/quatech2.c | 3 --- drivers/usb/serial/ssu100.c | 3 --- drivers/usb/serial/ti_usb_3410_5052.c | 3 --- drivers/usb/serial/usb_wwan.c | 3 --- 10 files changed, 32 deletions(-)
drivers/usb/serial/ftdi_sio.c +0 -5
@@ -1455,8 +1455,6 @@ static int get_serial_info(struct usb_serial_port *port,struct ftdi_private *priv =usb_get_serial_port_data (port);struct serial_struct tmp; -if (!retinfo) -return -EFAULT ;memset (&tmp,0 ,sizeof (tmp)); tmp.flags = priv->flags; tmp.baud_base = priv->baud_base;
@@ -1538,9 +1536,6 @@ static int get_lsr_info(struct usb_serial_port *port,struct ftdi_private *priv =usb_get_serial_port_data (port);unsigned int result =0 ; -if (!retinfo) -return -EFAULT ; -if (priv->transmit_empty) result =TIOCSER_TEMT ;
drivers/usb/serial/io_edgeport.c +0 -3
@@ -1554,9 +1554,6 @@ static int get_serial_info(struct edgeport_port *edge_port, {struct serial_struct tmp; -if (!retinfo) -return -EFAULT ; -memset (&tmp,0 ,sizeof (tmp)); tmp.type =PORT_16550A ;
drivers/usb/serial/io_ti.c +0 -3
@@ -2459,9 +2459,6 @@ static int get_serial_info(struct edgeport_port *edge_port,struct serial_struct tmp;unsigned cwait; -if (!retinfo) -return -EFAULT ; - cwait = edge_port->port->port.closing_wait;if (cwait !=ASYNC_CLOSING_WAIT_NONE ) cwait =jiffies_to_msecs (cwait) /10 ;
drivers/usb/serial/mos7720.c +0 -3
@@ -1861,9 +1861,6 @@ static int get_serial_info(struct moschip_port *mos7720_port, {struct serial_struct tmp; -if (!retinfo) -return -EFAULT ; -memset (&tmp,0 ,sizeof (tmp)); tmp.type =PORT_16550A ;
drivers/usb/serial/mos7840.c +0 -3
@@ -1956,9 +1956,6 @@ static int mos7840_get_serial_info(struct moschip_port *mos7840_port,if (mos7840_port ==NULL )return -1 ; -if (!retinfo) -return -EFAULT ; -memset (&tmp,0 ,sizeof (tmp)); tmp.type =PORT_16550A ;
drivers/usb/serial/opticon.c +0 -3
@@ -336,9 +336,6 @@ static int get_serial_info(struct usb_serial_port *port, {struct serial_struct tmp; -if (!serial) -return -EFAULT ; -memset (&tmp,0x00 ,sizeof (tmp));/* fake emulate a 16550 uart to make userspace code happy */
drivers/usb/serial/quatech2.c +0 -3
@@ -463,9 +463,6 @@ static int get_serial_info(struct usb_serial_port *port, {struct serial_struct tmp; -if (!retinfo) -return -EFAULT ; -memset (&tmp,0 ,sizeof (tmp)); tmp.line = port->minor; tmp.port =0 ;
drivers/usb/serial/ssu100.c +0 -3
@@ -318,9 +318,6 @@ static int get_serial_info(struct usb_serial_port *port, {struct serial_struct tmp; -if (!retinfo) -return -EFAULT ; -memset (&tmp,0 ,sizeof (tmp)); tmp.line = port->minor; tmp.port =0 ;
drivers/usb/serial/ti_usb_3410_5052.c +0 -3
@@ -1426,9 +1426,6 @@ static int ti_get_serial_info(struct ti_port *tport,struct serial_struct ret_serial;unsigned cwait; -if (!ret_arg) -return -EFAULT ; - cwait = port->port.closing_wait;if (cwait !=ASYNC_CLOSING_WAIT_NONE ) cwait =jiffies_to_msecs (cwait) /10 ;
drivers/usb/serial/usb_wwan.c +0 -3
@@ -140,9 +140,6 @@ static int get_serial_info(struct usb_serial_port *port, {struct serial_struct tmp; -if (!retinfo) -return -EFAULT ; -memset (&tmp,0 ,sizeof (tmp)); tmp.line = port->minor; tmp.port = port->port_number;
Signature · 1 line
2.7.3
Quoted 5 lines · Johan Hovold
Drop invalid user-pointer checks from ioctl handlers.
A NULL-pointer can be valid in user space and
copy_to_user()takes care
of sanity checking.
Shouldn't we bail out early in these cases?
Regards
Oliver
Johan Hovold
maintainerQuoted 8 lines · Oliver Neukum
Quoted 5 lines · Johan Hovold
Drop invalid user-pointer checks from ioctl handlers.
A NULL-pointer can be valid in user space and
copy_to_user()takes care
of sanity checking.Shouldn't we bail out early in these cases?
I don't think it's worth it, and this is also the general pattern for such ioctls. The added overhead for an error case like this is really negligible.
Thanks,
Johan
Quoted 8 lines · Johan Hovold
Quoted 7 lines · Oliver Neukum
Quoted 5 lines · Johan Hovold
Drop invalid user-pointer checks from ioctl handlers.
A NULL-pointer can be valid in user space and
copy_to_user()takes care
of sanity checking.
Quoted 5 lines
Quoted 1 line
Shouldn't we bail out early in these cases?
I don't think it's worth it, and this is also the general pattern for such ioctls. The added overhead for an error case like this is really negligible.
OK, as you say.
Regards
Oliver
Johan Hovold
maintainerQuoted 9 lines · Oliver Neukum
Quoted 8 lines · Johan Hovold
Quoted 7 lines · Oliver Neukum
Quoted 5 lines · Johan Hovold
Drop invalid user-pointer checks from ioctl handlers.
A NULL-pointer can be valid in user space and
copy_to_user()takes care
of sanity checking.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Shouldn't we bail out early in these cases?
I don't think it's worth it, and this is also the general pattern for such ioctls. The added overhead for an error case like this is really negligible.
OK, as you say.
Also remember that access_ok() is not a sufficient sanity check, and would specifically fail to catch the NULL-pointer case.
Thanks,
Johan