]> git.hungrycats.org Git - linux/commitdiff
HID: roccat: koneplus: reject short button reports
authorJiale Yao <yaojiale02@163.com>
Thu, 24 Sep 2026 14:29:12 +0000 (22:29 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Nov 2026 17:10:51 +0000 (12:10 -0500)
commit d879e17a8b4c572c0b53b4e42a36849484e8f00c 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, for a
button report, read the complete struct koneplus_mouse_report_button.  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: 47dbdbffe15b ("HID: roccat: Add support for Roccat Kone[+] v2")
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-koneplus.c

index f80a60539a967e0351eaa0b4276ad1c103375358..df39868d7e6ae40355f3acabf9a42b09c7c2dca4 100644 (file)
@@ -523,6 +523,9 @@ static int koneplus_raw_event(struct hid_device *hdev,
        if (koneplus == NULL)
                return 0;
 
+       if (size < sizeof(struct koneplus_mouse_report_button))
+               return 0;
+
        koneplus_keep_values_up_to_date(koneplus, data);
 
        if (koneplus->roccat_claimed)