]> git.hungrycats.org Git - linux/commitdiff
HID: prodikeys: validate fixed-format MIDI reports
authorJiale Yao <yaojiale02@163.com>
Thu, 24 Sep 2026 14:44:11 +0000 (22:44 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Nov 2026 17:10:50 +0000 (12:10 -0500)
commit 0ff37294c41bd925258893310398bc2b45fcd4a7 upstream.

The HID core invokes raw_event callbacks before validating the report
length.  Prodikeys reports 0x01 and 0x04 are passed to handlers that always
read bytes one through three, regardless of the supplied size.  A truncated
report can therefore cause an out-of-bounds read.

Require four bytes for the two fixed-format reports.  Keep report 0x03 on
its existing variable-length path, which derives the number of note pairs
from size and only accesses complete pairs.

Commit 47669bec44fe ("HID: asus: refactor the two workqueues and init
sequence") added the same kind of raw_event length validation to hid-asus.

Fixes: 3a370ca1dcf8 ("HID: Prodikeys PC-MIDI HID Driver")
Cc: stable@vger.kernel.org
Signed-off-by: Jiale Yao <yaojiale02@163.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hid/hid-prodikeys.c

index fba01e4fcab1c76c408d77ac9e9049cd89571e6d..bf5add40d3e1527beaa8b034c42713c9c01641fa 100644 (file)
@@ -772,8 +772,13 @@ static int pk_raw_event(struct hid_device *hdev, struct hid_report *report,
                if (report->id == data[0])
                        switch (report->id) {
                        case 0x01: /* midi keys (qwerty)*/
-                       case 0x03: /* midi keyboard (musical)*/
                        case 0x04: /* extra/midi keys (qwerty)*/
+                               if (size < 4)
+                                       break;
+                               ret = pcmidi_handle_report(pm, report->id,
+                                                          data, size);
+                               break;
+                       case 0x03: /* midi keyboard (musical)*/
                                ret = pcmidi_handle_report(pm,
                                                report->id, data, size);
                                break;