From: Jinmo Yang <jinmo44.yang@gmail.com>
To: Jiri Kosina <jikos@kernel.org>, Benjamin Tissoires <bentiss@kernel.org>
Cc: Jinmo Yang <jinmo44.yang@gmail.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: HID: magicmouse: battery timer makes a sleeping HID request
Date: Sat, 28 Nov 2026 11:04:06 +0000 [thread overview]
Message-ID: <20261128110415.772810-4-jinmo44.yang@gmail.com> (raw)
Found by coverage-guided fuzzing of the HID subsystem through /dev/uhid.
No patch is attached; I am reporting the context bug first and can test
candidate fixes with the standalone reproducer.
Kernel: mainline 7.2.0-ge46c86b19f4b (arm64, KASAN)
File: drivers/hid/hid-magicmouse.c
Impact: scheduling while atomic and subsequent scheduler corruption; DoS
Repro: standalone C, approximately 62 seconds
## Report
BUG: scheduling while atomic: swapper/1/0/0x00000102
schedule_timeout
__uhid_report_queue_and_wait
uhid_hid_get_report
uhid_hid_raw_request
hid_hw_raw_request
hid_hw_request
magicmouse_fetch_battery
magicmouse_battery_timer_tick
call_timer_fn
run_timer_softirq
The preempt count 0x102 and PID 0 show that the request slept while a timer
softirq was running in the idle task.
## Analysis
magicmouse_battery_timer_tick() is a timer callback and therefore runs in
atomic context. It directly calls magicmouse_fetch_battery(), which issues:
hid_hw_request(hdev, report, HID_REQ_GET_REPORT);
Whether this sleeps depends on the transport. With uhid,
uhid_hid_raw_request() waits for a userspace UHID_GET_REPORT_REPLY through
__uhid_report_queue_and_wait(), which uses schedule_timeout(). hid_hw_request
therefore cannot be assumed atomic-safe.
The standalone reproducer creates a USB Magic Trackpad 2 uhid device with a
battery feature report, permits the probe-time request to finish, then keeps
the fd open without replying to the request made by the 60-second battery
timer. It reproduced the warning at about 62 seconds. Subsequent reports in
the same runs showed failures in __schedule and unrelated task stacks, so I
classify the impact as denial of service rather than a harmless warning.
The usual shape of a fix would be to have the timer schedule work and perform
the HID request in process context, with teardown synchronously cancelling
both timer and work.
## Upstream status
Rechecked against mainline, linux-next, HID maintainer branches, including
the magicmouse branch, and lore through 2026-11-28. The defect remains
unpatched and I found no matching submission.
reply other threads:[~2026-11-28 11:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261128110415.772810-4-jinmo44.yang@gmail.com \
--to=jinmo44.yang@gmail.com \
--cc=bentiss@kernel.org \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@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