Re: [PATCH v2] usb: usbtmc: reject invalid interrupt endpoints

From: Michal Pecio

Date: Thu Apr 30 2026 - 16:49:09 EST


On Thu, 30 Apr 2026 15:31:55 -0300, Heitor Alves de Siqueira wrote:
> > I think a minimal fix which mostly preserves existing behavior would
> > be adding "urb->actual_length == 2" as a requirement for all USB488
> > notifications. Then any truncated message will be ignored and logged.
>
> Yes, that's my understanding as well! Although I don't think bNotify2
> would ever be zero in practice, this sounds like a good approach. I'll
> submit a v3 with this change plus the endpoint check from v2, hopefully
> that'll improve things for these edge cases.

With actual_length check, wMaxPacketSize check isn't critical anymore
because actual_length won't exceed URB buffer size.

> > wMaxPacketSize is a separate issue indeed and it seems that a USB488
> > device could legally set it to 1, though it would be crazy. Your v1
> > patch would probably make such devices work, if anyone cares.
>
> Honestly, I'm also more inclined to just reject endpoints with this
> configuration. This seems like a very niche edge-case, I'd be surprised
> if real hardware operated like this (famous last words? heh). I'm not
> sure if this would even be valid/legal, given your previous point on
> bNotify2 being one byte.

USBTMC spec refers to USB 2.0 section 5.7.3, which states that an
interrupt transfer may take multiple packets until either the IRP (URB)
is filled or a packet shorter than wMaxPacketSize (possibly 0) is sent.

So slow, inefficient and unlikely to exist - yes.
But illegal - not really. Such endpoint can deliver 2 byte messages.

Also, a non-USB488 device may be sending different, very simple 1 byte
messages, perhaps vendor specific ones. None of them are recognized by
the driver, but other functionality of such device could still work, so
rejecting it is overkill.

> Considering these devices do not work at all currently, checking if
> wMaxPacketSize and urb->actual_length are big enough seems like a
> saner approach and won't require bigger changes to the driver.

The only change to support USB488 devices with wMaxPacketSize == 1
should be increasing URB size to at least 2 bytes. But I wouldn't
bother when no such HW is known to exist, and surely not as part of
a barely related bugfix patch.

Regards,
Michal