Am 02.05.2025 um 05:30 hat Nicholas Piggin geschrieben:
> Errors in incoming USB MSD packet format or context would typically
> be guest software errors. Log these under guest errors.
> 
> Signed-off-by: Nicholas Piggin <npig...@gmail.com>

> +static bool check_valid_csw(USBPacket *p)
> +{
> +    if (p->iov.size < CSW_SIZE) {
> +        qemu_log_mask(LOG_GUEST_ERROR, "usb-msd: Bad CSW size %zu\n",
> +                      p->iov.size);
> +        return false;
> +    }
> +    return true;
> +}

I feel this name might be a bit misleading. The spec says a CSW is valid
if its size is exactly 13 bytes, the signature is correct and the tag
matches the CBW tag. Of course, this is something that the host would
check after the device completes the request, not the device when it
receives the CSW.

Maybe just validate_csw_size() or something?

The logic looks good to me, though.

Reviewed-by: Kevin Wolf <kw...@redhat.com>


Reply via email to