Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tristan Madani" <tristmd@gmail.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH 8/8] HID: prodikeys: validate report size in raw_event callback
Date: Sun, 18 Oct 2026 21:44:11 +0000	[thread overview]
Message-ID: <sashiko-outbox-176410@kernel.org> (raw)
In-Reply-To: <20261018213754.1951187-9-tristmd@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] HID: prodikeys: pk_raw_event() drops 3-byte report 0x03 MIDI packets
--

commit 2a171eaec1ee7f4c5cfc52b5bb2b8e59c517ae46
Author: Tristan Madani <tristan@talencesecurity.com>

HID: prodikeys: validate report size in raw_event callback

This patch adds a minimum report size check at the beginning of
pk_raw_event() to prevent out-of-bounds reads on short reports.

> diff --git a/drivers/hid/hid-prodikeys.c b/drivers/hid/hid-prodikeys.c
> index fba01e4fcab1c..c1419e6703777 100644
> --- a/drivers/hid/hid-prodikeys.c
> +++ b/drivers/hid/hid-prodikeys.c
> @@ -768,6 +768,9 @@ static int pk_raw_event(struct hid_device *hdev, struct hid_report *report,
>  	struct pcmidi_snd *pm = hid_get_drvdata(hdev);
>  	int ret = 0;
>  
> +	if (size < 4)
> +		return 0;
> +
>  	if (1 == pm->ifnum) {
>  		if (report->id == data[0])
>  			switch (report->id) {

[Severity: Medium]
Could checking size < 4 before inspecting report->id drop valid 3-byte
packets for report 0x03?

In drivers/hid/hid-prodikeys.c, pk_raw_event() calls pcmidi_handle_report(),
which dispatches three report IDs:

	switch (report_id) {
	case 0x01: /* midi keys (qwerty)*/
		ret = pcmidi_handle_report1(pm, data);
		break;
	case 0x03: /* midi keyboard (musical)*/
		ret = pcmidi_handle_report3(pm, data, size);
		break;
	case 0x04: /* multimedia/midi keys (qwerty)*/
		ret = pcmidi_handle_report4(pm, data);
		break;
	}

While pcmidi_handle_report1() and pcmidi_handle_report4() unconditionally
read a 24-bit bitmask from data[1..3] and require size >= 4,
pcmidi_handle_report3() computes the number of note/velocity pairs from
size:

	unsigned num_notes = (size-1)/2;
	for (j = 0; j < num_notes; j++)	{
		note = data[j*2+1];
		velocity = data[j*2+2];

A single-note report 0x03 has a 1-byte report ID followed by one 2-byte
note/velocity pair (size == 3), which pcmidi_handle_report3() already bounds
checks via num_notes.

Should the size < 4 check be restricted to reports 0x01 and 0x04 so that
3-byte report 0x03 MIDI events are not lost?

>
>
>

[]▷

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261018213754.1951187-1-tristmd@gmail.com?part=8

      reply	other threads:[~2026-10-18 21:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-18 21:37 [PATCH 0/8] HID: validate report size in raw_event callbacks Tristan Madani
2026-10-18 21:37 ` [PATCH 1/8] HID: pxrc: validate report size in raw_event callback Tristan Madani
2026-10-18 21:37 ` [PATCH 2/8] HID: alps: validate report size in raw_event callbacks Tristan Madani
2026-10-18 21:45   ` sashiko-bot
2026-10-18 21:37 ` [PATCH 3/8] HID: mcp2200: validate report size in raw_event callback Tristan Madani
2026-10-18 21:37 ` [PATCH 4/8] HID: cougar: " Tristan Madani
2026-10-18 21:37 ` [PATCH 5/8] HID: zydacron: " Tristan Madani
2026-10-18 21:37 ` [PATCH 6/8] HID: oxp: validate report size in raw_event callbacks Tristan Madani
2026-10-18 21:48   ` sashiko-bot
2026-10-18 21:37 ` [PATCH 7/8] HID: cp2112: validate report size in raw_event callback Tristan Madani
2026-10-18 21:37 ` [PATCH 8/8] HID: prodikeys: " Tristan Madani
2026-10-18 21:44   ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-176410@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tristmd@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox