From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Haiyang Zhang <haiyangz@microsoft.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>,
Michael Bommarito <michael.bommarito@gmail.com>,
"K. Y. Srinivasan" <kys@microsoft.com>,
linux-hyperv@vger.kernel.org, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 06/10] HID: hyperv: Validate VMBus packet and payload bounds on receive
Date: Mon, 23 Nov 2026 15:50:50 +0000 [thread overview]
Message-ID: <20261123155138.2907049-7-lee@kernel.org> (raw)
In-Reply-To: <20261123155138.2907049-1-lee@kernel.org>
mousevsc_on_receive() dereferences pipe_msg and hid_msg_hdr without
verifying hv_pkt_datalen(packet), passes the untrusted pipe_msg->size
to mousevsc_on_receive_device_info() without checking that the VMBus
packet actually contains pipe_msg->size bytes, and copies up to
sizeof(input_dev->input_buf) (16 KiB) from input_report->buffer in
SYNTH_HID_INPUT_REPORT without checking input_report->header.size
against the received packet buffer.
Validate that hv_pkt_datalen(packet) covers the pipe and SynthHID
headers, that pipe_msg->size fits within the received VMBus packet, and
that input_report->header.size fits within pipe_msg->size.
Fixes: b95f5bcb811e ("HID: Move the hid-hyperv driver out of staging")
Fixes: 934b7778aa7b ("HID: hyperv: validate initial device info bounds")
Closes: https://sashiko.dev/#/bug/linux-03d64dd2-820e-44e2-ba9e-b4a70f1e55ec
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/hid/hid-hyperv.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/hid/hid-hyperv.c b/drivers/hid/hid-hyperv.c
index cfc061dbdd24..1de03e38f363 100644
--- a/drivers/hid/hid-hyperv.c
+++ b/drivers/hid/hid-hyperv.c
@@ -272,14 +272,22 @@ static void mousevsc_on_receive(struct hv_device *device,
struct synthhid_msg_hdr *hid_msg_hdr;
struct mousevsc_dev *input_dev = hv_get_drvdata(device);
struct synthhid_input_report *input_report;
+ u32 pkt_len = hv_pkt_datalen(packet);
size_t len;
+ if (pkt_len < sizeof(struct pipe_prt_msg) + sizeof(struct synthhid_msg_hdr))
+ return;
+
pipe_msg = (struct pipe_prt_msg *)((unsigned long)packet +
(packet->offset8 << 3));
if (pipe_msg->type != PIPE_MESSAGE_DATA)
return;
+ if (pipe_msg->size < sizeof(struct synthhid_msg_hdr) ||
+ pipe_msg->size > pkt_len - sizeof(struct pipe_prt_msg))
+ return;
+
hid_msg_hdr = (struct synthhid_msg_hdr *)pipe_msg->data;
switch (hid_msg_hdr->type) {
@@ -317,6 +325,10 @@ static void mousevsc_on_receive(struct hv_device *device,
if (!input_dev->init_complete)
break;
+ if (input_report->header.size >
+ pipe_msg->size - sizeof(*input_report))
+ break;
+
len = min(input_report->header.size,
(u32)sizeof(input_dev->input_buf));
memcpy(input_dev->input_buf, input_report->buffer, len);
--
2.56.1.750.gf70dc682cf-goog
next prev parent reply other threads:[~2026-11-23 15:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 15:50 [PATCH 00/10] HID: Assorted bug fixes across HID core and drivers Lee Jones
2026-11-23 15:50 ` [PATCH 01/10] HID: core: Protect hid->inputs traversal in hid_check_keys_pressed() Lee Jones
2026-11-23 15:50 ` [PATCH 02/10] HID: mcp2221: Synchronise rxbuf access against raw_event callback Lee Jones
2026-11-23 15:50 ` [PATCH 03/10] HID: logitech-hidpp: Synchronise send_receive_buf against raw events Lee Jones
2026-11-23 16:14 ` sashiko-bot
2026-11-23 15:50 ` [PATCH 04/10] HID: sensor-hub: Serialise synchronous read teardown under data->lock Lee Jones
2026-11-23 16:13 ` sashiko-bot
2026-11-23 20:08 ` Srinivas Pandruvada
2026-11-23 15:50 ` [PATCH 05/10] HID: roccat: pyra: Resolve USB device from parent in actual_profile Lee Jones
2026-11-23 15:50 ` Lee Jones [this message]
2026-11-25 21:25 ` [PATCH 06/10] HID: hyperv: Validate VMBus packet and payload bounds on receive Hamza Mahfooz
2026-11-23 15:50 ` [PATCH 07/10] HID: hid-goodix-spi: Validate package sizes in goodix_hid_irq() Lee Jones
2026-11-23 15:50 ` [PATCH 08/10] HID: wacom: Stop HID hardware before releasing resources on mode change Lee Jones
2026-11-23 16:08 ` sashiko-bot
2026-11-23 15:50 ` [PATCH 09/10] HID: debug: Hold driver_input_lock while dumping raw report descriptor Lee Jones
2026-11-23 15:50 ` [PATCH 10/10] HID: playstation: Cancel DualSense output worker on create failure Lee Jones
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=20261123155138.2907049-7-lee@kernel.org \
--to=lee@kernel.org \
--cc=bentiss@kernel.org \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=jikos@kernel.org \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.bommarito@gmail.com \
--cc=stable@vger.kernel.org \
--cc=wei.liu@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.