stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] USB: usbfs: Filter flags passed in from user space
@ 2017-11-23 14:28 Oliver Neukum
  2017-11-23 14:57 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Oliver Neukum @ 2017-11-23 14:28 UTC (permalink / raw)
  To: stable, linux-usb, gregKH, stern; +Cc: Oliver Neukum

USBDEVFS_URB_ISO_ASAP must be accepted only for ISO endpoints.
Improve sanity checking.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
 drivers/usb/core/devio.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 705c573d0257..701ddada389a 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1442,14 +1442,18 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
 	int number_of_packets = 0;
 	unsigned int stream_id = 0;
 	void *buf;
-
-	if (uurb->flags & ~(USBDEVFS_URB_ISO_ASAP |
-				USBDEVFS_URB_SHORT_NOT_OK |
+	unsigned long mask =	USBDEVFS_URB_SHORT_NOT_OK |
 				USBDEVFS_URB_BULK_CONTINUATION |
 				USBDEVFS_URB_NO_FSBR |
-				USBDEVFS_URB_ZERO_PACKET |
-				USBDEVFS_URB_NO_INTERRUPT))
-		return -EINVAL;
+				USBDEVFS_URB_ZERO_PACKET | 
+				USBDEVFS_URB_NO_INTERRUPT;
+	/* USBDEVFS_URB_ISO_ASAP is a special case */
+	if (uurb->type == USBDEVFS_URB_TYPE_ISO)
+		mask |= USBDEVFS_URB_ISO_ASAP;
+
+	if (uurb->flags & ~mask)
+			return -EINVAL;
+
 	if ((unsigned int)uurb->buffer_length >= USBFS_XFER_MAX)
 		return -EINVAL;
 	if (uurb->buffer_length > 0 && !uurb->buffer)
-- 
2.13.6

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

* Re: [PATCH] USB: usbfs: Filter flags passed in from user space
  2017-11-23 14:28 [PATCH] USB: usbfs: Filter flags passed in from user space Oliver Neukum
@ 2017-11-23 14:57 ` Greg KH
  2017-11-23 15:06   ` Oliver Neukum
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2017-11-23 14:57 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: stable, linux-usb, stern

On Thu, Nov 23, 2017 at 03:28:34PM +0100, Oliver Neukum wrote:
> USBDEVFS_URB_ISO_ASAP must be accepted only for ISO endpoints.
> Improve sanity checking.
> 
> Signed-off-by: Oliver Neukum <oneukum@suse.com>
> ---
>  drivers/usb/core/devio.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)

Didn't we do something like this already?

Or was it something else?  Was this triggered by some testing?

thanks,

greg k-h

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

* Re: [PATCH] USB: usbfs: Filter flags passed in from user space
  2017-11-23 14:57 ` Greg KH
@ 2017-11-23 15:06   ` Oliver Neukum
  2017-11-23 15:19     ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Oliver Neukum @ 2017-11-23 15:06 UTC (permalink / raw)
  To: Greg KH; +Cc: stern, linux-usb, stable

Am Donnerstag, den 23.11.2017, 15:57 +0100 schrieb Greg KH:
> On Thu, Nov 23, 2017 at 03:28:34PM +0100, Oliver Neukum wrote:
> > 
> > USBDEVFS_URB_ISO_ASAP must be accepted only for ISO endpoints.
> > Improve sanity checking.
> > 
> > Signed-off-by: Oliver Neukum <oneukum@suse.com>
> > ---
> >  drivers/usb/core/devio.c | 16 ++++++++++------
> >  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> Didn't we do something like this already?

I sent a patch. Alan found it insufficient.

> Or was it something else?  Was this triggered by some testing?

Alexey's syzkaller tests showed that you can trigger it.

	Regards
		Oliver

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

* Re: [PATCH] USB: usbfs: Filter flags passed in from user space
  2017-11-23 15:06   ` Oliver Neukum
@ 2017-11-23 15:19     ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2017-11-23 15:19 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: stern, linux-usb, stable

On Thu, Nov 23, 2017 at 04:06:28PM +0100, Oliver Neukum wrote:
> Am Donnerstag, den 23.11.2017, 15:57 +0100 schrieb Greg KH:
> > On Thu, Nov 23, 2017 at 03:28:34PM +0100, Oliver Neukum wrote:
> > > 
> > > USBDEVFS_URB_ISO_ASAP must be accepted only for ISO endpoints.
> > > Improve sanity checking.
> > > 
> > > Signed-off-by: Oliver Neukum <oneukum@suse.com>
> > > ---
> > >  drivers/usb/core/devio.c | 16 ++++++++++------
> > >  1 file changed, 10 insertions(+), 6 deletions(-)
> > 
> > Didn't we do something like this already?
> 
> I sent a patch. Alan found it insufficient.

Ah, ok.

> > Or was it something else?  Was this triggered by some testing?
> 
> Alexey's syzkaller tests showed that you can trigger it.

Then a nice "Reported-by:" would be good to add, as would a stable tree
inclusion, right?

thanks,

greg k-h

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

end of thread, other threads:[~2017-11-23 15:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-23 14:28 [PATCH] USB: usbfs: Filter flags passed in from user space Oliver Neukum
2017-11-23 14:57 ` Greg KH
2017-11-23 15:06   ` Oliver Neukum
2017-11-23 15:19     ` Greg KH

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).