[PATCH 0/3] usb: gadget: f_hid: three GET_REPORT fixes

From: Shunbo Shi

Date: Tue Nov 10 2026 - 21:17:47 EST


Cover-letter:

Hi Greg,

I found these three bugs while looking into the Sashiko AI review
report of a patch series of mine that touched f_hid.c [1]: it
flagged a data race in the GET_REPORT userspace ioctl code, and
digging into it revealed two more issues in the same feature
(a139c98f760e, v6.11):

1. sleep-in-atomic-context: the second copy_from_user() in
f_hidg_get_report() runs under spin_lock_irqsave(); a page
fault on the user buffer deadlocks the scheduler.

2. memory leak: report_list entries allocated by the ioctl are
never freed in hidg_release().

3. data race: the GET_REPORT response is served by pointing
get_req->buf directly at a report_list entry's data; the
request completes asynchronously after the spinlock is
dropped, so a concurrent ioctl updating the same entry
corrupts the data on the wire (a torn write).

All three were introduced by the same commit and are fixable
deterministically from the code. The series is on top of v7.4-rc1
and applies cleanly to usb.git testing.

[1] Sashiko review: https://sashiko.dev/ (patchset 20261110064105.20335-1)

Shunbo Shi (3):
usb: gadget: f_hid: fix sleep-in-atomic-context in f_hidg_get_report()
usb: gadget: f_hid: fix report_list entries leak
usb: gadget: f_hid: fix race between userspace report update and
GET_REPORT response

drivers/usb/gadget/function/f_hid.c | 42 ++++++++++++++++++++++---------
1 file changed, 32 insertions(+), 10 deletions(-)

--
2.53.0