* [PATCH v2] hw/usb/dev-mtp: Fix assert crash on short CMD_SEND_OBJECT
@ 2026-10-08 12:29 Tommaso Califano
2026-10-08 12:35 ` Marc-André Lureau
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Tommaso Califano @ 2026-10-08 12:29 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Paolo Bonzini, Tommaso Califano,
Luigi Leonardi
In usb_mtp_get_data() there is a guest-triggerable assertion 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 fires, killing QEMU.
To prevent that is sufficient to remove the assertion, because the case
is handled by usb_mtp_write_data() which returns RES_INCOMPLETE_TRANSFER.
Fixes: 3e096650a64d ("dev-mtp: Add support for > 4GB file transfers")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3993
Signed-off-by: Tommaso Califano <tcalifano@redhat.com>
---
V2:
- Add Fixes tag.
- Correct and improve commit message readability.
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.56.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] hw/usb/dev-mtp: Fix assert crash on short CMD_SEND_OBJECT
2026-10-08 12:29 [PATCH v2] hw/usb/dev-mtp: Fix assert crash on short CMD_SEND_OBJECT Tommaso Califano
@ 2026-10-08 12:35 ` Marc-André Lureau
2026-10-08 12:38 ` Luigi Leonardi
2026-10-08 20:45 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 4+ messages in thread
From: Marc-André Lureau @ 2026-10-08 12:35 UTC (permalink / raw)
To: Tommaso Califano
Cc: qemu-devel, Philippe Mathieu-Daudé, Paolo Bonzini,
Luigi Leonardi
On Thu, Oct 8, 2026 at 4:30 PM Tommaso Califano <tcalifano@redhat.com> wrote:
>
> In usb_mtp_get_data() there is a guest-triggerable assertion 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 fires, killing QEMU.
>
> To prevent that is sufficient to remove the assertion, because the case
> is handled by usb_mtp_write_data() which returns RES_INCOMPLETE_TRANSFER.
>
> Fixes: 3e096650a64d ("dev-mtp: Add support for > 4GB file transfers")
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3993
> Signed-off-by: Tommaso Califano <tcalifano@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> V2:
> - Add Fixes tag.
> - Correct and improve commit message readability.
>
> 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.56.0
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] hw/usb/dev-mtp: Fix assert crash on short CMD_SEND_OBJECT
2026-10-08 12:29 [PATCH v2] hw/usb/dev-mtp: Fix assert crash on short CMD_SEND_OBJECT Tommaso Califano
2026-10-08 12:35 ` Marc-André Lureau
@ 2026-10-08 12:38 ` Luigi Leonardi
2026-10-08 20:45 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 4+ messages in thread
From: Luigi Leonardi @ 2026-10-08 12:38 UTC (permalink / raw)
To: Tommaso Califano; +Cc: qemu-devel, Philippe Mathieu-Daudé, Paolo Bonzini
On Thu, Oct 08, 2026 at 02:29:36PM +0200, Tommaso Califano wrote:
>In usb_mtp_get_data() there is a guest-triggerable assertion 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 fires, killing QEMU.
>
>To prevent that is sufficient to remove the assertion, because the case
>is handled by usb_mtp_write_data() which returns RES_INCOMPLETE_TRANSFER.
>
>Fixes: 3e096650a64d ("dev-mtp: Add support for > 4GB file transfers")
>Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3993
>Signed-off-by: Tommaso Califano <tcalifano@redhat.com>
Reviewed-by: Luigi Leonardi <leonardi@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] hw/usb/dev-mtp: Fix assert crash on short CMD_SEND_OBJECT
2026-10-08 12:29 [PATCH v2] hw/usb/dev-mtp: Fix assert crash on short CMD_SEND_OBJECT Tommaso Califano
2026-10-08 12:35 ` Marc-André Lureau
2026-10-08 12:38 ` Luigi Leonardi
@ 2026-10-08 20:45 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-10-08 20:45 UTC (permalink / raw)
To: Tommaso Califano, qemu-devel; +Cc: Paolo Bonzini, Luigi Leonardi
On 8/10/26 14:29, Tommaso Califano wrote:
> In usb_mtp_get_data() there is a guest-triggerable assertion 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 fires, killing QEMU.
>
> To prevent that is sufficient to remove the assertion, because the case
> is handled by usb_mtp_write_data() which returns RES_INCOMPLETE_TRANSFER.
>
> Fixes: 3e096650a64d ("dev-mtp: Add support for > 4GB file transfers")
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3993
> Signed-off-by: Tommaso Califano <tcalifano@redhat.com>
> ---
> V2:
> - Add Fixes tag.
> - Correct and improve commit message readability.
>
> hw/usb/dev-mtp.c | 3 ---
> 1 file changed, 3 deletions(-)
Queued via hw-misc, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-08 20:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-08 12:29 [PATCH v2] hw/usb/dev-mtp: Fix assert crash on short CMD_SEND_OBJECT Tommaso Califano
2026-10-08 12:35 ` Marc-André Lureau
2026-10-08 12:38 ` Luigi Leonardi
2026-10-08 20:45 ` Philippe Mathieu-Daudé
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.