Linux USB
 help / color / mirror / Atom feed
* [PATCH 0/3] usb: gadget: f_hid: three GET_REPORT fixes
@ 2026-11-11  2:16 Shunbo Shi
  2026-11-11  2:16 ` [PATCH 1/3] usb: gadget: f_hid: fix sleep-in-atomic-context in f_hidg_get_report() Shunbo Shi
                   ` (4 more replies)
  0 siblings, 5 replies; 25+ messages in thread
From: Shunbo Shi @ 2026-11-11  2:16 UTC (permalink / raw)
  To: nkapron, gregkh; +Cc: linux-usb, linux-kernel

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



^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2026-11-12  1:53 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-11  2:16 [PATCH 0/3] usb: gadget: f_hid: three GET_REPORT fixes Shunbo Shi
2026-11-11  2:16 ` [PATCH 1/3] usb: gadget: f_hid: fix sleep-in-atomic-context in f_hidg_get_report() Shunbo Shi
2026-11-11  2:48   ` sashiko-bot
2026-11-11  2:16 ` [PATCH 2/3] usb: gadget: f_hid: fix report_list entries leak Shunbo Shi
2026-11-11  2:52   ` sashiko-bot
2026-11-11  2:16 ` [PATCH 3/3] usb: gadget: f_hid: fix race between userspace report update and GET_REPORT response Shunbo Shi
2026-11-11  3:03   ` sashiko-bot
2026-11-11  8:13 ` [PATCH v2 0/4] usb: gadget: f_hid: three GET_REPORT fixes Shunbo Shi
2026-11-11  8:13   ` [PATCH v2 1/4] usb: gadget: f_hid: fix sleep-in-atomic-context in f_hidg_get_report() Shunbo Shi
2026-11-11  8:19     ` sashiko-bot
2026-11-11  8:13   ` [PATCH v2 2/4] usb: gadget: f_hid: fix report_list entries leak Shunbo Shi
2026-11-11  8:17     ` sashiko-bot
2026-11-11  8:13   ` [PATCH v2 3/4] usb: gadget: f_hid: fix race between userspace report update and GET_REPORT response Shunbo Shi
2026-11-11  8:32     ` sashiko-bot
2026-11-11  8:13   ` [PATCH v2 4/4] usb: gadget: f_hid: fix get_req leak when usb_gstrings_attach() fails Shunbo Shi
2026-11-11  8:22     ` sashiko-bot
2026-11-12  1:09 ` [PATCH v3 0/4] usb: gadget: f_hid: three GET_REPORT fixes Shunbo Shi
2026-11-12  1:09   ` [PATCH v3 1/4] usb: gadget: f_hid: fix sleep-in-atomic-context in f_hidg_get_report() Shunbo Shi
2026-11-12  1:15     ` sashiko-bot
2026-11-12  1:09   ` [PATCH v3 2/4] usb: gadget: f_hid: fix report_list entries leak Shunbo Shi
2026-11-12  1:14     ` sashiko-bot
2026-11-12  1:09   ` [PATCH v3 3/4] usb: gadget: f_hid: fix race between userspace report update and GET_REPORT response Shunbo Shi
2026-11-12  1:53     ` sashiko-bot
2026-11-12  1:09   ` [PATCH v3 4/4] usb: gadget: f_hid: fix get_req leak when usb_gstrings_attach() fails Shunbo Shi
2026-11-12  1:17     ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox