* HID: uhid: NULL outq entry reached with head != tail
@ 2026-11-28 11:04 Jinmo Yang
0 siblings, 0 replies; only message in thread
From: Jinmo Yang @ 2026-11-28 11:04 UTC (permalink / raw)
To: David Rheinsberg, Jiri Kosina, Benjamin Tissoires
Cc: Jinmo Yang, linux-input, linux-kernel
Found by coverage-guided fuzzing of the HID subsystem through /dev/uhid.
No patch is attached; the exact failing interleaving is not yet captured, and
I am reporting the observed queue invariant and locking mismatch for owner
review.
Kernel: mainline 7.2.0-g66498c75b4f8 (arm64, KASAN)
File: drivers/hid/uhid.c
Impact: NULL pointer read; kernel panic
Repro: syzkaller race; independently observed on a Pixel 9 Pro
## Report
KASAN reported a NULL source read in uhid_char_read():
BUG: KASAN: null-ptr-deref in uhid_char_read
Read of size 4380 at address 0x0
On a Pixel 9 Pro, hardened usercopy caught the same condition:
usercopy: Kernel memory exposure attempt detected from null address
(offset 0, size 4380)!
kernel BUG at mm/usercopy.c
usercopy_abort
__check_object_size
uhid_char_read
vfs_read
4380 is sizeof(struct uhid_event) on that kernel.
## Analysis
uhid_char_read() first decides the queue is nonempty and later copies the
tail entry:
len = min(count, sizeof(**uhid->outq));
if (copy_to_user(buffer, uhid->outq[uhid->tail], len))
...
The reports prove that uhid->outq[uhid->tail] was NULL while the head/tail
state allowed the read to proceed. The trigger churns output-event
generation and reads while repeatedly creating and destroying uhid devices.
uhid_queue() publishes the slot and head under qlock. The consumer updates
tail under qlock, but uhid_char_read() tests head against tail and
dereferences outq[tail] without holding qlock; it holds devlock instead.
Queue producers do not take devlock, so that mutex does not make the
slot/head publication atomic to the reader. On arm64, the observed state is
consistent with the reader seeing the new head before the corresponding slot
value.
I have not captured that precise load/store interleaving, so I am not claiming
more than the demonstrated NULL slot plus the source-level locking mismatch.
The original KASAN report carried only the warning taint and no preceding
memory-corruption report. The independent hardened-usercopy panic on a
shipping-derived kernel also reaches uhid_char_read directly.
## Upstream status
Rechecked against mainline, linux-next, HID maintainer branches, and lore
through 2026-11-28. The invariant violation remains unpatched and I found no
matching submission.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-28 11:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-28 11:04 HID: uhid: NULL outq entry reached with head != tail Jinmo Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®