WARNING in dln2_start_rx_urbs/usb_submit_urb
Subsystems (2)
#syz test: https://github.com/google/kasan.git b1aa9d83
From 6f3de1e2c53fcee54d90a6891df9cea763eca86b Mon Sep 17 00:00:00 2001
From: Oliver Neukum <[email protected]>
Date: Wed, 20 Nov 2019 16:15:13 +0100
Subject: [PATCH] mfd: dln2: more sanity checking for endpoints
It is not enough to check for the number of endpoints. The types must also be correct.
--- drivers/mfd/dln2.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/mfd/dln2.c +11 -2
@@ -722,6 +722,8 @@ static int dln2_probe(struct usb_interface *interface, const struct usb_device_id *usb_id) {struct usb_host_interface *hostif = interface->cur_altsetting; +struct usb_endpoint_descriptor *epin; +struct usb_endpoint_descriptor *epout;struct device *dev = &interface->dev;struct dln2_dev *dln2;int ret;
@@ -731,12 +733,19 @@ static int dln2_probe(struct usb_interface *interface, hostif->desc.bNumEndpoints < 2)return -ENODEV ; + epin = &hostif->endpoint[0 ].desc; + epout = &hostif->endpoint[1 ].desc; +if (!usb_endpoint_is_bulk_out (epout)) +return -ENODEV ; +if (!usb_endpoint_is_bulk_in (epin)) +return -ENODEV ; + dln2 =kzalloc (sizeof (*dln2),GFP_KERNEL );if (!dln2)return -ENOMEM ; - dln2->ep_out = hostif->endpoint[0 ].desc.bEndpointAddress; - dln2->ep_in = hostif->endpoint[1 ].desc.bEndpointAddress; + dln2->ep_out = epout->bEndpointAddress; + dln2->ep_in = epin->bEndpointAddress; dln2->usb_dev =usb_get_dev (interface_to_usbdev (interface)); dln2->interface = interface;usb_set_intfdata (interface, dln2);
Signature · 1 line
2.16.4
syzbot
syzbotsyzbot has tested the proposed patch and the reproducer did not trigger crash:
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger crash:
Tested on:
commit: b1aa9d83 usb: raw: add raw-gadget interface git tree: https://github.com/google/kasan.git kernel config: https://syzkaller.appspot.com/x/.config?x=79de80330003b5f7 dashboard link: https://syzkaller.appspot.com/bug?extid=48a2851be24583b864dc compiler: gcc (GCC) 9.0.0 20181231 (experimental) patch: https://syzkaller.appspot.com/x/patch.diff?x=1555d686e00000
Note: testing is done by a robot and is best-effort only.
Quoted 7 lines · Oliver Neukum
#syz test: https://github.com/google/kasan.git
b1aa9d83From
6f3de1e2c53fcee54d90a6891df9cea763eca86bMon Sep 17 00:00:00 2001
From: Oliver Neukum <[email protected]>
Date: Wed, 20 Nov 2019 16:15:13 +0100
Subject: [PATCH] mfd: dln2: more sanity checking for endpoints
Quoted 8 lines
It is not enough to check for the number of endpoints. The types must also be correct.
Reported-by [email protected]Signed-off-by Oliver Neukum <[email protected]>--- drivers/mfd/dln2.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
Looks okay in principle.
It would be great if one of the USB guys could take a quick look.
Is this not something that could be done at a subsystem level?
Quoted 35 lines
drivers/mfd/dln2.c +11
-2@@ -722,6 +722,8 @@ static int dln2_probe(struct usb_interface *interface, const struct usb_device_id *usb_id) {struct usb_host_interface *hostif = interface->cur_altsetting; +struct usb_endpoint_descriptor *epin; +struct usb_endpoint_descriptor *epout;struct device *dev = &interface->dev;struct dln2_dev *dln2;int ret;@@ -731,12 +733,19 @@ static int dln2_probe(struct usb_interface *interface, hostif->desc.bNumEndpoints < 2)return -ENODEV ; + epin = &hostif->endpoint[0 ].desc; + epout = &hostif->endpoint[1 ].desc; +if (!usb_endpoint_is_bulk_out (epout)) +return -ENODEV ; +if (!usb_endpoint_is_bulk_in (epin)) +return -ENODEV ; + dln2 =kzalloc (sizeof (*dln2),GFP_KERNEL );if (!dln2)return -ENOMEM ; - dln2->ep_out = hostif->endpoint[0 ].desc.bEndpointAddress; - dln2->ep_in = hostif->endpoint[1 ].desc.bEndpointAddress; + dln2->ep_out = epout->bEndpointAddress; + dln2->ep_in = epin->bEndpointAddress; dln2->usb_dev =usb_get_dev (interface_to_usbdev (interface)); dln2->interface = interface;usb_set_intfdata (interface, dln2);
Signature · 4 lines
Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Greg KH
maintainerQuoted 18 lines · Lee Jones
Quoted 7 lines · Oliver Neukum
#syz test: https://github.com/google/kasan.git
b1aa9d83From
6f3de1e2c53fcee54d90a6891df9cea763eca86bMon Sep 17 00:00:00 2001
From: Oliver Neukum <[email protected]>
Date: Wed, 20 Nov 2019 16:15:13 +0100
Subject: [PATCH] mfd: dln2: more sanity checking for endpointsQuoted 8 lines
It is not enough to check for the number of endpoints. The types must also be correct.
Reported-by [email protected]Signed-off-by Oliver Neukum <[email protected]>--- drivers/mfd/dln2.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
Quoted 5 lines
Looks okay in principle.
It would be great if one of the USB guys could take a quick look.
Is this not something that could be done at a subsystem level?
We have functions in the USB core for this, look at usb_find_common_endpoints() for an example of this. You can convert the driver to use this, or use the usb helper functions that Oliver is using here in a much simpler patch :)
thanks,
greg k-h