All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Tommaso Califano" <tcalifano@redhat.com>
To: "Junjie Cao" <junjie.cao@linux.dev>,
	"Tommaso Califano" <tcalifano@redhat.com>
Cc: qemu-devel@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	qemu-stable@nongnu.org, "Thomas Huth" <thuth@redhat.com>
Subject: Re: [PATCH 6/9] hw/usb/dev-mtp: Detect end of SendObject data correctly
Date: Wed, 18 Nov 2026 17:50:39 +0100	[thread overview]
Message-ID: <DMYHPLN68VZR.1N2Y3IUDLVD6I@redhat.com> (raw)
In-Reply-To: <20261115142800.1299746-1-junjie.cao@linux.dev>

On Sun Nov 15, 2026 at 3:28 PM CET, Junjie Cao wrote:
> On Thu, Nov 12, 2026 at 06:49:03PM +0100, Tommaso Califano wrote:
>> +        if ((p->iov.size % p->ep->max_packet_size) || !p->iov.size ||
>
> max_packet_size is 0 until the guest sets a configuration
> (usb_ep_reset()), and dev-mtp handles bulk packets before that. From
> qtest, OpenSession, SendObjectInfo and SendObject without
> SET_CONFIGURATION write the file on master; with the series applied
> QEMU dies with SIGFPE on this line.
>

Thanks for pointing it out, I'll modify the guard in:
  !p->iov.size ||
  (p->ep->max_packet_size && (p->iov.size % p->ep->max_packet_size)

This should prevent the crash in that case.

>> +         *  - A Zero Length Packet
>
> usb_mtp_handle_data() stalls every OUT packet shorter than the
> container header before it gets here, so the !p->iov.size arm is not
> reached. With libmtp 1.1.20 in a Linux guest on xHCI or EHCI, a 500
> byte file (512 with the header) now lands intact, but mtp-sendfile
> still fails with "PTP I/O Error": the ZLP that ends the data phase
> (MTP 1.1, Appendix H) gets the "packet too small" STALL.
>

I'll add a new check before the stall response.

Thanks,
Tommaso



  reply	other threads:[~2026-11-18 16:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 17:48 [PATCH 0/9] hw/usb/dev-mtp: Collection of bug fixes Tommaso Califano
2026-11-12 17:48 ` [PATCH 1/9] hw/usb/dev-mtp: Fix recursive delete of directories Tommaso Califano
2026-11-15 14:27   ` Junjie Cao
2026-11-12 17:48 ` [PATCH 2/9] hw/usb/dev-mtp: Reset pending write state on cancel, reset and error Tommaso Califano
2026-11-13  8:33   ` marcandre.lureau
2026-11-13 11:46     ` Tommaso Califano
2026-11-12 17:49 ` [PATCH 3/9] hw/usb/dev-mtp: Check length of class control request Tommaso Califano
2026-11-13  8:33   ` marcandre.lureau
2026-11-12 17:49 ` [PATCH 4/9] hw/usb/dev-mtp: Handle invalid characters in utf16_to_str() Tommaso Califano
2026-11-13  8:33   ` marcandre.lureau
2026-11-13 13:16     ` Tommaso Califano
2026-11-12 17:49 ` [PATCH 5/9] hw/usb/dev-mtp: Validate container length on first data packet Tommaso Califano
2026-11-13  8:33   ` marcandre.lureau
2026-11-13 13:18     ` Tommaso Califano
2026-11-12 17:49 ` [PATCH 6/9] hw/usb/dev-mtp: Detect end of SendObject data correctly Tommaso Califano
2026-11-15 14:28   ` Junjie Cao
2026-11-18 16:50     ` Tommaso Califano [this message]
2026-11-12 17:49 ` [PATCH 7/9] hw/usb/dev-mtp: Zero-initialize command and params in handle_data Tommaso Califano
2026-11-12 17:49 ` [PATCH 8/9] hw/usb/dev-mtp: Fix assert failures in usb_mtp_write_metadata() Tommaso Califano
2026-11-12 17:49 ` [PATCH 9/9] hw/usb/dev-mtp: Stop processing SendObjectInfo after an error Tommaso Califano
2026-11-15 14:28   ` Junjie Cao

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=DMYHPLN68VZR.1N2Y3IUDLVD6I@redhat.com \
    --to=tcalifano@redhat.com \
    --cc=armbru@redhat.com \
    --cc=junjie.cao@linux.dev \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@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.