Re: WARNING in usbhid_raw_request/usb_submit_urb (3)
From: Alan Stern
Date: Wed Apr 22 2020 - 21:18:28 EST
On Thu, 2 Apr 2020, syzbot wrote:
> Hello,
>
> syzbot has tested the proposed patch but the reproducer still triggered crash:
> WARNING in usbhid_raw_request/usb_submit_urb
>
> ------------[ cut here ]------------
> usb 1-1: BOGUS urb xfer, pipe 2 != type 2, pipe 0x80005600, ep attr 0x00, ep addr 0xff
This means that the ep_out[0] pointer was NULL. Let's try to find out
why.
Alan Stern
#syz test: https://github.com/google/kasan.git 0fa84af8
Index: usb-devel/drivers/usb/core/hub.c
===================================================================
--- usb-devel.orig/drivers/usb/core/hub.c
+++ usb-devel/drivers/usb/core/hub.c
@@ -4437,9 +4437,11 @@ int hub_port_debounce(struct usb_hub *hu
void usb_ep0_reinit(struct usb_device *udev)
{
+ udev->alan1 = 2;
usb_disable_endpoint(udev, 0 + USB_DIR_IN, true);
usb_disable_endpoint(udev, 0 + USB_DIR_OUT, true);
usb_enable_endpoint(udev, &udev->ep0, true);
+ udev->alan1 = 3;
}
EXPORT_SYMBOL_GPL(usb_ep0_reinit);
Index: usb-devel/drivers/usb/core/message.c
===================================================================
--- usb-devel.orig/drivers/usb/core/message.c
+++ usb-devel/drivers/usb/core/message.c
@@ -1198,6 +1198,10 @@ void usb_disable_interface(struct usb_de
int i;
for (i = 0; i < alt->desc.bNumEndpoints; ++i) {
+ if ((alt->endpoint[i].desc.bEndpointAddress & 0x0f) == 0)
+ dev_info(&dev->dev, "Ep 0 is %d in interface %d-%d\n",
+ i, alt->desc.bInterfaceNumber,
+ alt->desc.bAlternateSetting);
usb_disable_endpoint(dev,
alt->endpoint[i].desc.bEndpointAddress,
reset_hardware);
@@ -1275,6 +1279,8 @@ void usb_disable_device(struct usb_devic
mutex_unlock(hcd->bandwidth_mutex);
/* Second pass: remove endpoint pointers */
}
+ if (!skip_ep0)
+ dev->alan1 = 1;
for (i = skip_ep0; i < 16; ++i) {
usb_disable_endpoint(dev, i, true);
usb_disable_endpoint(dev, i + USB_DIR_IN, true);
Index: usb-devel/drivers/usb/core/urb.c
===================================================================
--- usb-devel.orig/drivers/usb/core/urb.c
+++ usb-devel/drivers/usb/core/urb.c
@@ -204,8 +204,12 @@ int usb_urb_ep_type_check(const struct u
const struct usb_host_endpoint *ep;
ep = usb_pipe_endpoint(urb->dev, urb->pipe);
- if (!ep)
+ if (!ep) {
+ dev_info(&urb->dev->dev, "Ep %d disabled: %d %d\n",
+ usb_pipeendpoint(urb->pipe),
+ urb->dev->alan1, urb->dev->alan2);
return -EINVAL;
+ }
if (usb_pipetype(urb->pipe) != pipetypes[usb_endpoint_type(&ep->desc)])
return -EINVAL;
return 0;
Index: usb-devel/include/linux/usb.h
===================================================================
--- usb-devel.orig/include/linux/usb.h
+++ usb-devel/include/linux/usb.h
@@ -629,6 +629,7 @@ struct usb3_lpm_parameters {
* usb_set_device_state().
*/
struct usb_device {
+ int alan1, alan2;
int devnum;
char devpath[16];
u32 route;