From: Johan Hovold <johan@kernel.org>
To: Oliver Neukum <oneukum@suse.com>
Cc: gregkh@linuxfoundation.org, stern@rowland.harvard.edu,
liulongfang@huawei.com, linux-usb@vger.kernel.org
Subject: Re: [PATCH] USB: hub: make sure stale buffers are not enumerated
Date: Mon, 24 Jul 2023 15:52:30 +0200 [thread overview]
Message-ID: <ZL6CHnYEmxssGXRG@hovoldconsulting.com> (raw)
In-Reply-To: <20230724124057.12975-1-oneukum@suse.com>
On Mon, Jul 24, 2023 at 02:40:57PM +0200, Oliver Neukum wrote:
> Quoting Alan Stern on why we cannot just check errors:
>
> The operation carried out here is deliberately unsafe (for full-speed
> devices). It is made before we know the actual maxpacket size for ep0,
> and as a result it might return an error code even when it works okay.
> This shouldn't happen, but a lot of USB hardware is unreliable.
>
> Therefore we must not ignore the result merely because r < 0. If we do
> that, the kernel might stop working with some devices.
>
> He is absolutely right. However, we must make sure that in case
> we read nothing or a short answer, the buffer contains nothing
> that can be misinterpreted as a valid answer.
> So we have to zero it before we use it for IO.
This patch is neither correct or needed. The current implementation sets
buf->bMaxPacketSize0 = 0
before reading the descriptor and makes sure that that field is non-zero
before accessing buf->bDescriptorType which lies before bMaxPacketSize0.
It may be subtle, but it looks correct.
Johan
next prev parent reply other threads:[~2023-07-24 13:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-24 12:40 [PATCH] USB: hub: make sure stale buffers are not enumerated Oliver Neukum
2023-07-24 13:52 ` Johan Hovold [this message]
2023-07-24 14:24 ` Oliver Neukum
2023-07-24 14:29 ` Alan Stern
2023-07-24 14:31 ` Oliver Neukum
2023-07-24 15:10 ` Alan Stern
2023-07-24 14:13 ` 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=ZL6CHnYEmxssGXRG@hovoldconsulting.com \
--to=johan@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=liulongfang@huawei.com \
--cc=oneukum@suse.com \
--cc=stern@rowland.harvard.edu \
/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