From: Nicholas Chin <nic.c3.14@gmail.com>
To: linux-usb@vger.kernel.org
Subject: URB data not available through binary usbmon interface when URB_DMA_SG_COMBINED set
Date: Wed, 27 Aug 2025 23:05:17 -0600 [thread overview]
Message-ID: <87e75621-f12e-49cb-ad8d-581e4151216d@gmail.com> (raw)
Hello,
Recently I've been working on reverse engineering the USB protocol of
the Digilent Analog Discovery 2, which uses an FT232H in FIFO mode. I
noticed that tools such as Wireshark and usbdump, which rely on the
binary usbmon interface, were showing many URBs with no data, even
though I would expect a payload to be present. Looking at the fields in
the URB, it seems that the len_urb field of struct mon_bin_hdr was a
non-zero value, but the len_cap field was set to zero.
With the legacy text interface, I am able to see data in the same URBs
that the binary interface was not showing.
I did some digging and logging of drivers/usb/mon/mon_bin.c and found
that the len_cap field was being zeroed in mon_bin_event() due to a
positive return value of the mon_bin_get_data() call.
Looking into that function, it seems that it returns without copying any
data if urb->num_sgs is non zero and the URB_DMA_SG_COMBINED flag is set
in the urb->transfer flags. The comment around that code indicates that
"If IOMMU coalescing occured, we cannot trust sg_page" which I assume is
supposed to be the reason for this behavior.
The analogous function in the text interface, mon_text_get_data(), does
not check URB_DMA_SG_COMBINED, and instead just reads the first 32 bytes
of the first sg buffer.
Could someone please explain why/if this behavior is required if
URB_DMA_SG_COMBINED flag is set? Is there a way that usbmon could return
data in this situation?
I would assume that if the full data is able to make its way to
userspace then it should be possible for usbmon to also access that data.
Regards,
Nicholas
next reply other threads:[~2025-08-28 5:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-28 5:05 Nicholas Chin [this message]
2025-08-28 15:22 ` URB data not available through binary usbmon interface when URB_DMA_SG_COMBINED set Alan Stern
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=87e75621-f12e-49cb-ad8d-581e4151216d@gmail.com \
--to=nic.c3.14@gmail.com \
--cc=linux-usb@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).