aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2018-10-15 16:55:04 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-10-16 07:09:36 -0400
commit665c365a77fbfeabe52694aedf3446d5f2f1ce42 (patch)
treeff6a03294a000077f970491d8e6db196b99b1ff2
parentc02588a352defaf985fc1816eb6232663159e1b8 (diff)
USB: fix the usbfs flag sanitization for control transfers
Commit 7a68d9fb8510 ("USB: usbdevfs: sanitize flags more") checks the transfer flags for URBs submitted from userspace via usbfs. However, the check for whether the USBDEVFS_URB_SHORT_NOT_OK flag should be allowed for a control transfer was added in the wrong place, before the code has properly determined the direction of the control transfer. (Control transfers are special because for them, the direction is set by the bRequestType byte of the Setup packet rather than direction bit of the endpoint address.) This patch moves code which sets up the allow_short flag for control transfers down after is_in has been set to the correct value. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Reported-and-tested-by: syzbot+24a30223a4b609bb802e@syzkaller.appspotmail.com Fixes: 7a68d9fb8510 ("USB: usbdevfs: sanitize flags more") CC: Oliver Neukum <oneukum@suse.com> CC: <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/core/devio.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 244417d0dfd1..ffccd40ea67d 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1474,8 +1474,6 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
1474 u = 0; 1474 u = 0;
1475 switch (uurb->type) { 1475 switch (uurb->type) {
1476 case USBDEVFS_URB_TYPE_CONTROL: 1476 case USBDEVFS_URB_TYPE_CONTROL:
1477 if (is_in)
1478 allow_short = true;
1479 if (!usb_endpoint_xfer_control(&ep->desc)) 1477 if (!usb_endpoint_xfer_control(&ep->desc))
1480 return -EINVAL; 1478 return -EINVAL;
1481 /* min 8 byte setup packet */ 1479 /* min 8 byte setup packet */
@@ -1505,6 +1503,8 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
1505 is_in = 0; 1503 is_in = 0;
1506 uurb->endpoint &= ~USB_DIR_IN; 1504 uurb->endpoint &= ~USB_DIR_IN;
1507 } 1505 }
1506 if (is_in)
1507 allow_short = true;
1508 snoop(&ps->dev->dev, "control urb: bRequestType=%02x " 1508 snoop(&ps->dev->dev, "control urb: bRequestType=%02x "
1509 "bRequest=%02x wValue=%04x " 1509 "bRequest=%02x wValue=%04x "
1510 "wIndex=%04x wLength=%04x\n", 1510 "wIndex=%04x wLength=%04x\n",