[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 06/11] usb/msd: Allow CBW packet size greater than 31
From: |
Nicholas Piggin |
Subject: |
[PATCH 06/11] usb/msd: Allow CBW packet size greater than 31 |
Date: |
Thu, 12 Dec 2024 19:13:17 +1000 |
The CBW structure is 31 bytes, so CBW DATAOUT packets must be at least
31 bytes. QEMU enforces exactly 31 bytes, but this is inconsistent with
how it handles CSW packets (where it allows greater than or equal to 13
bytes) despite wording in the spec[*] being similar for both packet
types: "shall end as a short packet with exactly 31 bytes transferred".
[*] USB MSD Bulk-Only Transport 1.0
For consistency, and on the principle of being tolerant in accepting
input, relax the CBW size check.
Alternatively, both checks could be tightened to exact. Or a message
could be printed warning of possible guest error if size is not exact,
but still accept the packets.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
hw/usb/dev-storage.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index af9eb7ea8a5..064bb700cbc 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -400,7 +400,7 @@ static bool try_get_valid_cbw(USBPacket *p, struct
usb_msd_cbw *cbw)
{
uint32_t sig;
- if (p->iov.size != 31) {
+ if (p->iov.size < 31) {
qemu_log_mask(LOG_GUEST_ERROR, "usb-msd: Bad CBW size %ld\n",
p->iov.size);
return false;
--
2.45.2
- [PATCH 00/11] usb/msd: Permit relaxed ordering of IN packets, Nicholas Piggin, 2024/12/12
- [PATCH 01/11] usb/msd: Add status to usb_msd_packet_complete() function, Nicholas Piggin, 2024/12/12
- [PATCH 03/11] usb/msd: Ensure packet structure layout is correct, Nicholas Piggin, 2024/12/12
- [PATCH 02/11] usb/msd: Split in and out packet handling, Nicholas Piggin, 2024/12/12
- [PATCH 04/11] usb/msd: Improved handling of mass storage reset, Nicholas Piggin, 2024/12/12
- [PATCH 05/11] usb/msd: Improve packet validation error logging, Nicholas Piggin, 2024/12/12
- [PATCH 06/11] usb/msd: Allow CBW packet size greater than 31,
Nicholas Piggin <=
- [PATCH 07/11] usb/msd: Split async packet tracking into data and csw, Nicholas Piggin, 2024/12/12
- [PATCH 08/11] usb/msd: Add some additional assertions, Nicholas Piggin, 2024/12/12
- [PATCH 09/11] usb/msd: Rename mode to cbw_state, and tweak names, Nicholas Piggin, 2024/12/12
- [PATCH 10/11] usb/msd: Permit a DATA-IN or CSW packet before CBW packet, Nicholas Piggin, 2024/12/12
- [PATCH 11/11] usb/msd: Add more tracing, Nicholas Piggin, 2024/12/12