From: sashiko-bot@kernel.org
To: "Shunbo Shi" <shishunbo@cmss.chinamobile.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH v3 1/4] usb: gadget: f_hid: fix sleep-in-atomic-context in f_hidg_get_report()
Date: Thu, 12 Nov 2026 01:15:32 +0000 [thread overview]
Message-ID: <sashiko-outbox-210050@kernel.org> (raw)
In-Reply-To: <20261112010928.23716-2-shishunbo@cmss.chinamobile.com>
> The second copy_from_user() in f_hidg_get_report() is called while
> holding hidg->get_report_spinlock with interrupts disabled. If the
> user page backing the ioctl buffer is not resident, copy_from_user()
> takes a page fault and sleeps, which is not allowed with a spinlock
> held: it triggers might_sleep() warnings with
> CONFIG_DEBUG_ATOMIC_SLEEP and can deadlock the scheduler on other
> CPUs spinning on the lock.
>
> The first copy_from_user() into the freshly allocated entry is
> already done before the spinlock is taken; only the "report already
> exists, update it" branch still copies inside the critical section.
>
> Since the data has already been fully copied into entry->report_data
> before taking the lock, updating an existing report only needs a
> plain assignment between two kernel-memory objects, which is safe
> inside the spinlock.
>
> Fixes: a139c98f760e ("USB: gadget: f_hid: Add GET_REPORT via userspace IOCTL")
> Signed-off-by: Shunbo Shi <shishunbo@cmss.chinamobile.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261112010928.23716-1-shishunbo@cmss.chinamobile.com?part=1
next prev parent reply other threads:[~2026-11-12 1:15 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=sashiko-outbox-210050@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shishunbo@cmss.chinamobile.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.