From: Felipe Balbi <balbi@kernel.org>
To: Greg KH <gregkh@linuxfoundation.org>,
Alan Stern <stern@rowland.harvard.edu>
Cc: Jacky.Cao@sony.com, andreyknvl@google.com,
chunfeng.yun@mediatek.com, USB list <linux-usb@vger.kernel.org>,
syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] USB: gadget: Reject endpoints with 0 maxpacket value
Date: Tue, 29 Oct 2019 10:38:54 +0200 [thread overview]
Message-ID: <87sgnchroh.fsf@gmail.com> (raw)
In-Reply-To: <20191028160818.GA257088@kroah.com>
[-- Attachment #1: Type: text/plain, Size: 2166 bytes --]
Hi,
Greg KH <gregkh@linuxfoundation.org> writes:
> On Mon, Oct 28, 2019 at 10:54:26AM -0400, Alan Stern wrote:
>> 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>
>>
>> ---
>>
>>
>> [as1925]
>>
>>
>> drivers/usb/gadget/udc/core.c | 11 +++++++++++
>> 1 file changed, 11 insertions(+)
>>
>> Index: usb-devel/drivers/usb/gadget/udc/core.c
>> ===================================================================
>> --- usb-devel.orig/drivers/usb/gadget/udc/core.c
>> +++ usb-devel/drivers/usb/gadget/udc/core.c
>> @@ -98,6 +98,17 @@ int usb_ep_enable(struct usb_ep *ep)
>> if (ep->enabled)
>> goto out;
>>
>> + /* UDC drivers can't handle endpoints with maxpacket size 0 */
>> + if (usb_endpoint_maxp(ep->desc) == 0) {
>> + /*
>> + * We should log an error message here, but we can't call
>> + * dev_err() because there's no way to find the gadget
>> + * given only ep.
>> + */
>> + ret = -EINVAL;
>> + goto out;
>> + }
>> +
>> ret = ep->ops->enable(ep, ep->desc);
>> if (ret)
>> goto out;
>>
>
> Felipe, I can take this now in my tree if I can get an ack.
Definitely:
Acked-by: Felipe Balbi <balbi@kernel.org>
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next prev parent reply other threads:[~2019-10-29 8:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-24 13:58 divide error in dummy_timer syzbot
2019-10-24 15:04 ` Alan Stern
2019-10-24 15:22 ` syzbot
2019-10-24 17:05 ` Andrey Konovalov
2019-10-24 17:57 ` Alan Stern
2019-10-24 18:08 ` syzbot
2019-10-24 18:58 ` Alan Stern
2019-10-24 19:16 ` syzbot
2019-10-28 14:52 ` [PATCH] USB: Skip endpoints with 0 maxpacket length Alan Stern
2019-10-28 14:54 ` [PATCH] USB: gadget: Reject endpoints with 0 maxpacket value Alan Stern
2019-10-28 16:08 ` Greg KH
2019-10-29 8:38 ` Felipe Balbi [this message]
2019-10-24 18:55 ` divide error in dummy_timer Andrey Konovalov
2019-10-24 19:17 ` Alan Stern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sgnchroh.fsf@gmail.com \
--to=balbi@kernel.org \
--cc=Jacky.Cao@sony.com \
--cc=andreyknvl@google.com \
--cc=chunfeng.yun@mediatek.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).