linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] USB: serial: suppress driver bind attributes
@ 2020-01-16 16:07 Johan Hovold
  2020-01-16 16:18 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Johan Hovold @ 2020-01-16 16:07 UTC (permalink / raw)
  To: Johan Hovold; +Cc: linux-usb, stable

USB-serial drivers must not be unbound from their ports before the
corresponding USB driver is unbound from the parent interface so
suppress the bind and unbind attributes.

Unbinding a serial driver while it's port is open is a sure way to
trigger a crash as any driver state is released on unbind while port
hangup is handled on the parent USB interface level. Drivers for
multiport devices where ports share a resource such as an interrupt
endpoint also generally cannot handle individual ports going away.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/serial/usb-serial.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 8f066bb55d7d..dc7a65b9ec98 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -1317,6 +1317,9 @@ static int usb_serial_register(struct usb_serial_driver *driver)
 		return -EINVAL;
 	}
 
+	/* Prevent individual ports from being unbound. */
+	driver->driver.suppress_bind_attrs = true;
+
 	usb_serial_operations_init(driver);
 
 	/* Add this device to our list of devices */
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] USB: serial: suppress driver bind attributes
  2020-01-16 16:07 [PATCH] USB: serial: suppress driver bind attributes Johan Hovold
@ 2020-01-16 16:18 ` Greg KH
  2020-01-16 16:24   ` Johan Hovold
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2020-01-16 16:18 UTC (permalink / raw)
  To: Johan Hovold; +Cc: linux-usb, stable

On Thu, Jan 16, 2020 at 05:07:05PM +0100, Johan Hovold wrote:
> USB-serial drivers must not be unbound from their ports before the
> corresponding USB driver is unbound from the parent interface so
> suppress the bind and unbind attributes.
> 
> Unbinding a serial driver while it's port is open is a sure way to
> trigger a crash as any driver state is released on unbind while port
> hangup is handled on the parent USB interface level. Drivers for
> multiport devices where ports share a resource such as an interrupt
> endpoint also generally cannot handle individual ports going away.
> 
> Cc: stable <stable@vger.kernel.org>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>  drivers/usb/serial/usb-serial.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
> index 8f066bb55d7d..dc7a65b9ec98 100644
> --- a/drivers/usb/serial/usb-serial.c
> +++ b/drivers/usb/serial/usb-serial.c
> @@ -1317,6 +1317,9 @@ static int usb_serial_register(struct usb_serial_driver *driver)
>  		return -EINVAL;
>  	}
>  
> +	/* Prevent individual ports from being unbound. */
> +	driver->driver.suppress_bind_attrs = true;

We can still unbind the usb driver though, right?  If so, this is fine
with me.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] USB: serial: suppress driver bind attributes
  2020-01-16 16:18 ` Greg KH
@ 2020-01-16 16:24   ` Johan Hovold
  2020-01-16 19:06     ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Johan Hovold @ 2020-01-16 16:24 UTC (permalink / raw)
  To: Greg KH; +Cc: Johan Hovold, linux-usb, stable

On Thu, Jan 16, 2020 at 05:18:29PM +0100, Greg Kroah-Hartman wrote:
> On Thu, Jan 16, 2020 at 05:07:05PM +0100, Johan Hovold wrote:
> > USB-serial drivers must not be unbound from their ports before the
> > corresponding USB driver is unbound from the parent interface so
> > suppress the bind and unbind attributes.
> > 
> > Unbinding a serial driver while it's port is open is a sure way to
> > trigger a crash as any driver state is released on unbind while port
> > hangup is handled on the parent USB interface level. Drivers for
> > multiport devices where ports share a resource such as an interrupt
> > endpoint also generally cannot handle individual ports going away.
> > 
> > Cc: stable <stable@vger.kernel.org>
> > Signed-off-by: Johan Hovold <johan@kernel.org>
> > ---
> >  drivers/usb/serial/usb-serial.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
> > index 8f066bb55d7d..dc7a65b9ec98 100644
> > --- a/drivers/usb/serial/usb-serial.c
> > +++ b/drivers/usb/serial/usb-serial.c
> > @@ -1317,6 +1317,9 @@ static int usb_serial_register(struct usb_serial_driver *driver)
> >  		return -EINVAL;
> >  	}
> >  
> > +	/* Prevent individual ports from being unbound. */
> > +	driver->driver.suppress_bind_attrs = true;
> 
> We can still unbind the usb driver though, right?  If so, this is fine
> with me.

Right, this is only about disabling individual ports, something which
essentially no subdriver can handle while a port is open (e.g. port-data
set to NULL while port is still open... boom).

Johan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] USB: serial: suppress driver bind attributes
  2020-01-16 16:24   ` Johan Hovold
@ 2020-01-16 19:06     ` Greg KH
  2020-01-17 10:13       ` Johan Hovold
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2020-01-16 19:06 UTC (permalink / raw)
  To: Johan Hovold; +Cc: linux-usb, stable

On Thu, Jan 16, 2020 at 05:24:24PM +0100, Johan Hovold wrote:
> On Thu, Jan 16, 2020 at 05:18:29PM +0100, Greg Kroah-Hartman wrote:
> > On Thu, Jan 16, 2020 at 05:07:05PM +0100, Johan Hovold wrote:
> > > USB-serial drivers must not be unbound from their ports before the
> > > corresponding USB driver is unbound from the parent interface so
> > > suppress the bind and unbind attributes.
> > > 
> > > Unbinding a serial driver while it's port is open is a sure way to
> > > trigger a crash as any driver state is released on unbind while port
> > > hangup is handled on the parent USB interface level. Drivers for
> > > multiport devices where ports share a resource such as an interrupt
> > > endpoint also generally cannot handle individual ports going away.
> > > 
> > > Cc: stable <stable@vger.kernel.org>
> > > Signed-off-by: Johan Hovold <johan@kernel.org>
> > > ---
> > >  drivers/usb/serial/usb-serial.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
> > > index 8f066bb55d7d..dc7a65b9ec98 100644
> > > --- a/drivers/usb/serial/usb-serial.c
> > > +++ b/drivers/usb/serial/usb-serial.c
> > > @@ -1317,6 +1317,9 @@ static int usb_serial_register(struct usb_serial_driver *driver)
> > >  		return -EINVAL;
> > >  	}
> > >  
> > > +	/* Prevent individual ports from being unbound. */
> > > +	driver->driver.suppress_bind_attrs = true;
> > 
> > We can still unbind the usb driver though, right?  If so, this is fine
> > with me.
> 
> Right, this is only about disabling individual ports, something which
> essentially no subdriver can handle while a port is open (e.g. port-data
> set to NULL while port is still open... boom).

Ok, thanks for verifying, and sorry for writing that bug in the first
place :)

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] USB: serial: suppress driver bind attributes
  2020-01-16 19:06     ` Greg KH
@ 2020-01-17 10:13       ` Johan Hovold
  0 siblings, 0 replies; 5+ messages in thread
From: Johan Hovold @ 2020-01-17 10:13 UTC (permalink / raw)
  To: Greg KH; +Cc: Johan Hovold, linux-usb, stable

On Thu, Jan 16, 2020 at 08:06:06PM +0100, Greg Kroah-Hartman wrote:
> On Thu, Jan 16, 2020 at 05:24:24PM +0100, Johan Hovold wrote:
> > On Thu, Jan 16, 2020 at 05:18:29PM +0100, Greg Kroah-Hartman wrote:
> > > On Thu, Jan 16, 2020 at 05:07:05PM +0100, Johan Hovold wrote:
> > > > USB-serial drivers must not be unbound from their ports before the
> > > > corresponding USB driver is unbound from the parent interface so
> > > > suppress the bind and unbind attributes.
> > > > 
> > > > Unbinding a serial driver while it's port is open is a sure way to
> > > > trigger a crash as any driver state is released on unbind while port
> > > > hangup is handled on the parent USB interface level. Drivers for
> > > > multiport devices where ports share a resource such as an interrupt
> > > > endpoint also generally cannot handle individual ports going away.
> > > > 
> > > > Cc: stable <stable@vger.kernel.org>
> > > > Signed-off-by: Johan Hovold <johan@kernel.org>
> > > > ---
> > > >  drivers/usb/serial/usb-serial.c | 3 +++
> > > >  1 file changed, 3 insertions(+)
> > > > 
> > > > diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
> > > > index 8f066bb55d7d..dc7a65b9ec98 100644
> > > > --- a/drivers/usb/serial/usb-serial.c
> > > > +++ b/drivers/usb/serial/usb-serial.c
> > > > @@ -1317,6 +1317,9 @@ static int usb_serial_register(struct usb_serial_driver *driver)
> > > >  		return -EINVAL;
> > > >  	}
> > > >  
> > > > +	/* Prevent individual ports from being unbound. */
> > > > +	driver->driver.suppress_bind_attrs = true;
> > > 
> > > We can still unbind the usb driver though, right?  If so, this is fine
> > > with me.
> > 
> > Right, this is only about disabling individual ports, something which
> > essentially no subdriver can handle while a port is open (e.g. port-data
> > set to NULL while port is still open... boom).
> 
> Ok, thanks for verifying, and sorry for writing that bug in the first
> place :)
> 
> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Heh, thanks for reviewing.

Johan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-01-17 10:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-16 16:07 [PATCH] USB: serial: suppress driver bind attributes Johan Hovold
2020-01-16 16:18 ` Greg KH
2020-01-16 16:24   ` Johan Hovold
2020-01-16 19:06     ` Greg KH
2020-01-17 10:13       ` Johan Hovold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).