From: Guenter Roeck <linux@roeck-us.net>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 1/1] uas: add stream number sanity checks.
Date: Thu, 9 Dec 2021 12:16:52 -0800 [thread overview]
Message-ID: <20211209201652.GA2342043@roeck-us.net> (raw)
In-Reply-To: <20210818120505.1258262-2-kraxel@redhat.com>
On Wed, Aug 18, 2021 at 02:05:05PM +0200, Gerd Hoffmann wrote:
> The device uses the guest-supplied stream number unchecked, which can
> lead to guest-triggered out-of-band access to the UASDevice->data3 and
> UASDevice->status3 fields. Add the missing checks.
>
> Fixes: CVE-2021-3713
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> Reported-by: Chen Zhe <chenzhe@huawei.com>
> Reported-by: Tan Jingguo <tanjingguo@huawei.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/usb/dev-uas.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c
> index 263056231c79..f6309a5ebfdc 100644
> --- a/hw/usb/dev-uas.c
> +++ b/hw/usb/dev-uas.c
> @@ -840,6 +840,9 @@ static void usb_uas_handle_data(USBDevice *dev, USBPacket *p)
> }
> break;
> case UAS_PIPE_ID_STATUS:
> + if (p->stream > UAS_MAX_STREAMS) {
> + goto err_stream;
> + }
> if (p->stream) {
> QTAILQ_FOREACH(st, &uas->results, next) {
> if (st->stream == p->stream) {
> @@ -867,6 +870,9 @@ static void usb_uas_handle_data(USBDevice *dev, USBPacket *p)
> break;
> case UAS_PIPE_ID_DATA_IN:
> case UAS_PIPE_ID_DATA_OUT:
> + if (p->stream > UAS_MAX_STREAMS) {
> + goto err_stream;
> + }
> if (p->stream) {
> req = usb_uas_find_request(uas, p->stream);
> } else {
> @@ -902,6 +908,11 @@ static void usb_uas_handle_data(USBDevice *dev, USBPacket *p)
> p->status = USB_RET_STALL;
> break;
> }
> +
> +err_stream:
> + error_report("%s: invalid stream %d", __func__, p->stream);
> + p->status = USB_RET_STALL;
> + return;
How is this supposed to work ? It results in messages such as the following.
qemu-system-sparc64: usb_uas_handle_data: invalid stream 1
qemu-system-sparc64: usb_uas_handle_data: invalid stream 1
It also sets the status unconditionally to USB_RET_STALL,
and UAS is simply broken after this patch is applied because
the error handling code is executed literally for each call
of usb_uas_handle_data().
Guenter
next prev parent reply other threads:[~2021-12-09 20:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-18 12:05 [PATCH 0/1] uas: add stream number sanity checks (maybe 6.1) Gerd Hoffmann
2021-08-18 12:05 ` [PATCH 1/1] uas: add stream number sanity checks Gerd Hoffmann
2021-08-18 15:12 ` Philippe Mathieu-Daudé
2021-12-09 20:16 ` Guenter Roeck [this message]
2021-08-20 11:24 ` [PATCH 0/1] uas: add stream number sanity checks (maybe 6.1) Philippe Mathieu-Daudé
2021-08-20 12:12 ` Peter Maydell
2021-08-20 13:07 ` Philippe Mathieu-Daudé
2021-08-23 9:59 ` Mauro Matteo Cascella
2021-08-23 10:18 ` Peter Maydell
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=20211209201652.GA2342043@roeck-us.net \
--to=linux@roeck-us.net \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).