Created attachment 255207 [details] Patch to hidraw.c correcting the defect. hidraw(4) HIDRAW_GET_REPORT is documented to update hgd_actlen on return with the number of bytes copied. It does not do this.
Created attachment 255223 [details] Patch to uhid.c correcting the defect. uhid(4) also appears to have the same issue.
That is certainly a bug. Thank you for the report. These patches require some changes: In uhid.c ugd->ugd_actlen should be equal to imin(ugd->ugd_maxlen, size) rather than size In hidraw.c ugd->ugd_actlen should be taken from 4th parameter of preceding hid_get_report() call.
Created attachment 255239 [details] Patch to hidraw.c, uhid.c correcting the defect. Update with required changes, per feedback.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=0b5d86b38ae9aec92ef96b9227a404a2df3c9234 commit 0b5d86b38ae9aec92ef96b9227a404a2df3c9234 Author: Matthew Nygard Dodd <Matthew.Nygard.Dodd@gmail.com> AuthorDate: 2024-11-18 04:15:01 +0000 Commit: Vladimir Kondratyev <wulf@FreeBSD.org> CommitDate: 2024-11-18 04:31:24 +0000 uhid(4): update ugd_actlen in USB_GET_REPORT ioctl USB_GET_REPORT ioctl is documented to update ugd_actlen on return with the number of bytes copied. It does not do this. Reviewed by: wulf PR: 282790 MFC after: 1 week sys/dev/usb/input/uhid.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=f4f46a2eef3be6d19c65a4ca4ee70f365dd5be4f commit f4f46a2eef3be6d19c65a4ca4ee70f365dd5be4f Author: Matthew Nygard Dodd <Matthew.Nygard.Dodd@gmail.com> AuthorDate: 2024-11-18 04:25:10 +0000 Commit: Vladimir Kondratyev <wulf@FreeBSD.org> CommitDate: 2024-11-18 04:31:39 +0000 hidraw(4): update hgd_actlen in HIDRAW_GET_REPORT ioctl HIDRAW_GET_REPORT ioctl is documented to update hgd_actlen on return with the number of bytes copied. It does not do this. Reviewed by: wulf PR: 282790 MFC after: 1 week sys/dev/hid/hidraw.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)