Alan Stern 54f83b8c8e USB: gadget: Reject endpoints with 0 maxpacket value
Endpoints with a maxpacket length of 0 are probably useless.  They
can't transfer any data, and it's not at all unlikely that a UDC will
crash or hang when trying to handle a non-zero-length usb_request for
such an endpoint.  Indeed, dummy-hcd gets a divide error when trying
to calculate the remainder of a transfer length by the maxpacket
value, as discovered by the syzbot fuzzer.

Currently the gadget core does not check for endpoints having a
maxpacket value of 0.  This patch adds a check to usb_ep_enable(),
preventing such endpoints from being used.

As far as I know, none of the gadget drivers in the kernel tries to
create an endpoint with maxpacket = 0, but until now there has been
nothing to prevent userspace programs under gadgetfs or configfs from
doing it.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-and-tested-by: syzbot+8ab8bf161038a8768553@syzkaller.appspotmail.com
CC: <stable@vger.kernel.org>
Acked-by: Felipe Balbi <balbi@kernel.org>

Link: https://lore.kernel.org/r/Pine.LNX.4.44L0.1910281052370.1485-100000@iolanthe.rowland.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-10-29 09:56:18 +01:00
..
2019-10-24 15:49:32 -04:00
2019-10-23 06:26:33 -04:00
2019-09-22 09:30:30 -07:00
2019-09-19 14:14:28 -07:00
2019-09-18 11:14:31 -07:00
2019-09-22 12:02:21 -07:00
2019-10-26 06:29:04 -04:00
2019-10-25 14:25:15 +02:00
2019-10-18 22:29:36 -04:00
2019-09-23 17:20:40 -04:00
2019-09-29 10:33:41 -07:00
2019-10-15 23:51:36 +02:00
2019-09-23 19:16:01 -07:00
2019-09-27 12:19:47 -07:00
2019-10-23 15:31:17 -04:00
2019-09-22 10:55:08 -07:00
2019-09-30 10:04:28 -07:00
2019-09-22 11:05:43 -07:00
2019-10-22 17:55:51 +02:00
2019-10-25 20:11:33 -04:00
2019-09-22 10:52:23 -07:00
2019-09-17 18:40:42 -07:00
2019-10-25 20:11:33 -04:00
2019-09-18 11:14:31 -07:00
2019-10-15 14:07:01 -06:00
2019-09-27 11:17:38 -07:00
2019-09-18 11:05:34 -07:00