Descriptionozone: evdev: Fix possibility of stuck keys
There's a couple possible ways to get keys stuck down:
(1) User unplugs the device while holding a key. A key release is queued
by the kernel but races the unplug event. The unplug arrives first and we
tear everything down without ever dispatching a release event.
(2) Key release gets dropped in-kernel due to queue overruns. We never
get the release, and continue processing without dispatching a release
event. We do get a SYN_DROPPED event to notify us that events were lost.
If stuck, a key can be pressed again to unstick it.
Fix these cases by keeping track of pressed keys for every keyboard
device, and releasing everything during teardown & following queue
overruns.
Also unify with the path added for key filtering. With the additional
state, we can tell that we have an outstanding press and avoid filtering
the corresponding release.
BUG=463002
TEST=
(1) Tested unplug by unplugging devices with shift held.
Shift gets properly released rather than being stuck.
(NB: Could not reproduce without adding a delay to expose the race).
(2) Tested SYN_DROPPED by suspending chrome with key pressed,
releasing it, and then pressing more keys to cause an overrun.
(suspended via kill -STOP <browser>)
(3) event_unittests
Committed: https://crrev.com/48b636eefc4e4aa68c474680519e13ef4a337870
Cr-Commit-Position: refs/heads/master@{#319656}
Patch Set 1 #
Messages
Total messages: 11 (4 generated)
|