]> git.hungrycats.org Git - linux/commitdiff
HID: roccat: pyra: reject short button reports
authorJiale Yao <yaojiale02@163.com>
Thu, 24 Sep 2026 14:29:15 +0000 (22:29 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Nov 2026 17:06:11 +0000 (12:06 -0500)
commit 493268f459bb6aeeecbc77f2204c11ad74d05213 upstream.

The raw event callback runs before HID core validates and zero-pads the
report.  It passes the buffer to helpers which inspect data[0] and read a
complete struct pyra_mouse_event_button for button reports.  A truncated
report can therefore cause an out-of-bounds read.

Require enough data for the button report before calling either helper.
Commit 47669bec44fe ("HID: asus: refactor the two workqueues and init
sequence") added the same kind of raw-event length validation to hid-asus.

Fixes: cb7cf3da0daa ("HID: roccat: add driver for Roccat Pyra mouse")
Cc: stable@vger.kernel.org
Signed-off-by: Jiale Yao <yaojiale02@163.com>
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hid/hid-roccat-pyra.c

index de2da6086e0b93080c4ba21b7b0437992adcc478..af7e506e80ebc27b225f0eff25db23ddec75014e 100644 (file)
@@ -557,6 +557,9 @@ static int pyra_raw_event(struct hid_device *hdev, struct hid_report *report,
        if (pyra == NULL)
                return 0;
 
+       if (size < sizeof(struct pyra_mouse_event_button))
+               return 0;
+
        pyra_keep_values_up_to_date(pyra, data);
 
        if (pyra->roccat_claimed)