From: Jiale Yao <yaojiale02@163.com>
To: Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>,
Rahul Rameshbabu <sergeantsagara@protonmail.com>,
Johannes Roith <johannes@gnu-linux.rocks>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Jiale Yao <yaojiale02@163.com>, stable@vger.kernel.org
Subject: [PATCH 06/10] HID: mcp2200: validate READ_ALL response length
Date: Thu, 24 Sep 2026 22:44:09 +0800 [thread overview]
Message-ID: <20260924144414.1192037-7-yaojiale02@163.com> (raw)
In-Reply-To: <20260924144414.1192037-1-yaojiale02@163.com>
The HID core invokes raw_event callbacks before validating the report
length. mcp2200_raw_event() casts a READ_ALL response to struct
mcp_read_all_resp and reads fields through offset ten without checking that
the response contains the structure.
A one-byte READ_ALL response reproduced the issue under KASAN:
BUG: KASAN: slab-out-of-bounds in mcp2200_raw_event+0x24b/0x3a0
Read of size 1 by task hidtrigger/89
Call Trace:
mcp2200_raw_event+0x24b/0x3a0
kasan_report+0x139/0x170
Reject an incomplete READ_ALL response with a protocol error before reading
its fields. The common completion path then wakes the command waiter with
the error instead of leaving it to time out.
Commit 47669bec44fe ("HID: asus: refactor the two workqueues and init
sequence") added the same kind of raw_event length validation to hid-asus.
Fixes: 740329d7120f ("HID: mcp2200: added driver for GPIOs of MCP2200")
Cc: stable@vger.kernel.org
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/hid/hid-mcp2200.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/hid/hid-mcp2200.c b/drivers/hid/hid-mcp2200.c
index dafdd5b4a079..c6fd5fb5d578 100644
--- a/drivers/hid/hid-mcp2200.c
+++ b/drivers/hid/hid-mcp2200.c
@@ -301,6 +301,11 @@ static int mcp2200_raw_event(struct hid_device *hdev, struct hid_report *report,
switch (data[0]) {
case READ_ALL:
+ if (size < sizeof(*all_resp)) {
+ mcp->status = -EPROTO;
+ break;
+ }
+
all_resp = (struct mcp_read_all_resp *) data;
mcp->status = 0;
mcp->gpio_inval = all_resp->io_port_val_bmap;
--
2.34.1
next prev parent reply other threads:[~2026-09-24 14:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 14:44 [PATCH 00/10] HID: validate short reports in raw_event callbacks Jiale Yao
2026-09-24 14:44 ` [PATCH 01/10] HID: alps: reject short input reports Jiale Yao
2026-09-24 14:44 ` [PATCH 02/10] HID: cougar: reject short special-key reports Jiale Yao
2026-09-24 14:44 ` [PATCH 03/10] HID: cp2112: validate response report lengths Jiale Yao
2026-09-24 14:44 ` [PATCH 04/10] HID: elo: reject short touchscreen reports Jiale Yao
2026-09-24 14:44 ` [PATCH 05/10] HID: logitech-dj: validate unnumbered keyboard reports Jiale Yao
2026-09-24 14:44 ` Jiale Yao [this message]
2026-09-24 14:44 ` [PATCH 07/10] HID: mcp2221: validate response report length Jiale Yao
2026-09-24 14:44 ` [PATCH 08/10] HID: prodikeys: validate fixed-format MIDI reports Jiale Yao
2026-09-24 14:44 ` [PATCH 09/10] HID: pxrc: reject short input reports Jiale Yao
2026-09-24 14:44 ` [PATCH 10/10] HID: zydacron: validate key report length Jiale Yao
2026-10-16 9:37 ` [PATCH 00/10] HID: validate short reports in raw_event callbacks Jiri Kosina
-- strict thread matches above, loose matches on Subject: below --
2026-09-24 14:13 Jiale Yao
2026-09-24 14:13 ` [PATCH 06/10] HID: mcp2200: validate READ_ALL response length Jiale Yao
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=20260924144414.1192037-7-yaojiale02@163.com \
--to=yaojiale02@163.com \
--cc=bentiss@kernel.org \
--cc=jikos@kernel.org \
--cc=johannes@gnu-linux.rocks \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sergeantsagara@protonmail.com \
--cc=stable@vger.kernel.org \
/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