summaryrefslogtreecommitdiff
path: root/Kernel/Devices/HID
diff options
context:
space:
mode:
authorJelle Raaijmakers <jelle@gmta.nl>2021-10-24 20:29:50 +0200
committerAndreas Kling <kling@serenityos.org>2021-10-24 21:59:08 +0200
commit4131b3585164761e3841bb1c9609b302658ee2c0 (patch)
treef21087153904ec87b6ca67f2dfbc03fe270e1a39 /Kernel/Devices/HID
parent8b3232121be0909ac885bc4e86ebbebdd0b9f6db (diff)
downloadserenity-4131b3585164761e3841bb1c9609b302658ee2c0.zip
Kernel: Prevent VMWareMouseDevice from handling invalid mouse packets
Bit 3 is set here: https://github.com/qemu/qemu/blob/c5b2f559814104f4145f8bc310f4d33c7ead8f49/hw/input/ps2.c#L736 Spurious mouse packets can be received without this bit set, for example when double-clicking and keeping the mouse button depressed instead of releasing it the second time (i.e. mousedown > mouseup > mousedown). We should not process such packets. This makes interaction with our buttons much smoother! Fixes #5881.
Diffstat (limited to 'Kernel/Devices/HID')
-rw-r--r--Kernel/Devices/HID/VMWareMouseDevice.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/Kernel/Devices/HID/VMWareMouseDevice.cpp b/Kernel/Devices/HID/VMWareMouseDevice.cpp
index f2a6908153..05ba5f0d19 100644
--- a/Kernel/Devices/HID/VMWareMouseDevice.cpp
+++ b/Kernel/Devices/HID/VMWareMouseDevice.cpp
@@ -25,10 +25,11 @@ UNMAP_AFTER_INIT RefPtr<VMWareMouseDevice> VMWareMouseDevice::try_to_initialize(
return {};
}
-void VMWareMouseDevice::irq_handle_byte_read(u8)
+void VMWareMouseDevice::irq_handle_byte_read(u8 byte)
{
VERIFY(VMWareBackdoor::the());
VERIFY(VMWareBackdoor::the()->vmmouse_is_absolute());
+
// We won't receive complete packets with the backdoor enabled,
// we will only get one byte for each event, which we'll just
// discard. If we were to wait until we *think* that we got a
@@ -36,6 +37,12 @@ void VMWareMouseDevice::irq_handle_byte_read(u8)
// because we wouldn't read the appropriate number of mouse
// packets from VMWareBackdoor.
auto mouse_packet = VMWareBackdoor::the()->receive_mouse_packet();
+
+ // Only process packets with bit 3 set.
+ // Note that this needs to happen _after_ invoking receive_mouse_packet() above
+ if (!(byte & 0x8))
+ return;
+
if (mouse_packet.has_value()) {
m_entropy_source.add_random_event(mouse_packet.value());
{