From: Peter Chen <peter.chen@kernel.org>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg KH <greg@kroah.com>, Johan Hovold <johan@kernel.org>,
USB mailing list <linux-usb@vger.kernel.org>,
syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] USB: core: Avoid WARNings for 0-length descriptor requests
Date: Mon, 7 Jun 2021 10:31:32 +0800 [thread overview]
Message-ID: <20210607023132.GA25045@nchen> (raw)
In-Reply-To: <20210604161039.GI1676809@rowland.harvard.edu>
On 21-06-04 12:10:39, Alan Stern wrote:
> The USB core has utility routines to retrieve various types of
> descriptors. These routines will now provoke a WARN if they are asked
> to retrieve 0 bytes (USB "receive" requests must not have zero
> length), so avert this by checking the size argument at the start.
>
> Reported-and-tested-by: syzbot+7dbcd9ff34dc4ed45240@syzkaller.appspotmail.com
> Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
> CC: Johan Hovold <johan@kernel.org>
>
> ---
>
>
> [as1962]
>
>
> drivers/usb/core/message.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> Index: usb-devel/drivers/usb/core/message.c
> ===================================================================
> --- usb-devel.orig/drivers/usb/core/message.c
> +++ usb-devel/drivers/usb/core/message.c
> @@ -783,6 +783,8 @@ int usb_get_descriptor(struct usb_device
> int i;
> int result;
>
> + if (size <= 0) /* No point in asking for no data */
> + return -EINVAL;
One blank line after if {}
> memset(buf, 0, size); /* Make sure we parse really received data */
>
> for (i = 0; i < 3; ++i) {
> @@ -832,6 +834,8 @@ static int usb_get_string(struct usb_dev
> int i;
> int result;
>
> + if (size <= 0) /* No point in asking for no data */
> + return -EINVAL;
One blank line after if {}
> for (i = 0; i < 3; ++i) {
> /* retry on length 0 or stall; some devices are flakey */
> result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
--
Thanks,
Peter Chen
next prev parent reply other threads:[~2021-06-07 2:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-02 23:30 [syzbot] WARNING in usb_new_device/usb_submit_urb syzbot
2021-06-03 1:43 ` Alan Stern
2021-06-03 2:45 ` syzbot
2021-06-04 16:10 ` [PATCH] USB: core: Avoid WARNings for 0-length descriptor requests Alan Stern
2021-06-07 2:31 ` Peter Chen [this message]
2021-06-07 7:57 ` Johan Hovold
2021-06-07 15:23 ` [PATCH v2] " Alan Stern
2021-06-07 15:26 ` Johan Hovold
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=20210607023132.GA25045@nchen \
--to=peter.chen@kernel.org \
--cc=greg@kroah.com \
--cc=johan@kernel.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