From: Alan Stern <stern@rowland.harvard.edu>
To: "zhuyan (M)" <zhuyan34@huawei.com>
Cc: Greg KH <gregkh@linuxfoundation.org>,
"anton@enomsg.org" <anton@enomsg.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] usb:host: fix divide-by-zero in function fhci_queue_urb
Date: Thu, 18 Apr 2019 10:33:52 -0400 (EDT) [thread overview]
Message-ID: <Pine.LNX.4.44L0.1904181022320.1513-100000@iolanthe.rowland.org> (raw)
In-Reply-To: <2e3a7b4df8744b508b866db40bb8cf28@huawei.com>
On Thu, 18 Apr 2019, zhuyan (M) wrote:
> > > @@ -765,11 +765,12 @@ void fhci_queue_urb(struct fhci_hcd *fhci,
> > > struct urb *urb)
> > >
> > > switch (ed->mode) {
> > > case FHCI_TF_BULK:
> > > + max_pkt_size = usb_endpoint_maxp(&urb->ep->desc);
> > > if (urb->transfer_flags & URB_ZERO_PACKET &&
> > > urb->transfer_buffer_length > 0 &&
> > > + (max_pkt_size != 0) &&
> >
> > Now you shouldn't need to add this extra test.
> >
> > Alan Stern
> But the return value of usb_endpoint_maxp() may be 0.
> Do we need to take protective measures?
Yes, we do. But the protective measures don't belong in the fhci
driver.
They should go in core/config.c:usb_parse_endpoint(). That routine
already has code to check for maxpacket sizes that are too large; you
can add code that checks for maxpacket sizes that are too small.
In theory an interrupt or isochronous endpoint might have maxpacket set
to 0 -- we could warn about these and accept them -- but this is not
allowed for bulk endpoints (see section 5.8.3 of the USB 2.0
specification). In fact, bulk endpoints are not allowed to have
maxpacket size smaller than 8.
Maybe if you make this change then fhci-hcd won't need any
modifications at all.
Alan Stern
next prev parent reply other threads:[~2019-04-18 14:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-18 9:31 [PATCH v2] usb:host: fix divide-by-zero in function fhci_queue_urb zhuyan (M)
2019-04-18 14:33 ` Alan Stern [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-04-18 9:58 zhuyan (M)
2019-04-17 17:05 zhuyan (M)
2019-04-17 18:59 ` Alan Stern
2019-04-17 19:49 ` Greg KH
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=Pine.LNX.4.44L0.1904181022320.1513-100000@iolanthe.rowland.org \
--to=stern@rowland.harvard.edu \
--cc=anton@enomsg.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=zhuyan34@huawei.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).