From: Luigi Leonardi <leonardi@redhat.com>
To: Tommaso Califano <tcalifan@redhat.com>
Cc: qemu-devel@nongnu.org,
"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Nguyen Dinh Phi" <phind.uet@gmail.com>
Subject: Re: [PATCH] hw/usb: Fix guest-triggerable assert crash via short CMD_SEND_OBJECT
Date: Tue, 29 Sep 2026 12:25:21 +0200 [thread overview]
Message-ID: <aruPGUjhIP6IBqTo@leonardi-redhat> (raw)
In-Reply-To: <20260917150503.143821-1-tcalifan@redhat.com>
Ciao Tommaso,
On Thu, Sep 17, 2026 at 05:05:03PM +0200, Tommaso Califano wrote:
>QEMU's USB MTP device has a guest-triggerable assertion in
>usb_mtp_get_data() that fires when a guest declares a large object
>size in CMD_SEND_OBJECT_INFO but sends fewer bytes in the
>subsequent CMD_SEND_OBJECT. The assertion compares the declared
>size against the actual bytes received.
>
>If the guest sends CMD_SEND_OBJECT_INFO with size=1000 and then
>CMD_SEND_OBJECT with only 50 bytes (short, non-64-byte-aligned
>final USB packet) the assertion fire killing QEMU.
>
>To prevent that is sufficient to remove the assertion, becouse the case
/s/becouse/because
>is handled by usb_mtp_write_data() which return RES_INCOMPLETE_TRANSFER.
>
Fixes tag and CC qemu stable?
>Resolve: https://gitlab.com/qemu-project/qemu/-/work_items/3993
/s/Resolve/Resolves
>Signed-off-by: Tommaso Califano <tcalifan@redhat.com>
>---
> hw/usb/dev-mtp.c | 3 ---
> 1 file changed, 3 deletions(-)
>
>diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
>index 1d8cfd32dc..406793fc03 100644
>--- a/hw/usb/dev-mtp.c
>+++ b/hw/usb/dev-mtp.c
>@@ -1813,9 +1813,6 @@ static void usb_mtp_get_data(MTPState *s, mtp_container *container,
> d->offset += dlen;
> d->data_offset += dlen;
> if ((p->iov.size % 64) || !p->iov.size) {
>- assert((s->dataset.size == 0xFFFFFFFF) ||
>- (s->dataset.size == d->offset));
>-
> if (d->length == MTP_WRITE_BUF_SZ) {
> d->write_status = WRITE_END;
> } else {
>--
>2.55.0
>
>
That said, code LGTM, with the changes i suggested:
Reviewed-by: Luigi Leonardi <leonardi@redhat.com>
Thanks,
Luigi
prev parent reply other threads:[~2026-09-29 10:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 15:05 [PATCH] hw/usb: Fix guest-triggerable assert crash via short CMD_SEND_OBJECT Tommaso Califano
2026-09-29 10:25 ` Luigi Leonardi [this message]
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=aruPGUjhIP6IBqTo@leonardi-redhat \
--to=leonardi@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@oss.qualcomm.com \
--cc=phind.uet@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=tcalifan@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.