Linux-HyperV List
 help / color / mirror / Atom feed
* [PATCH v2 00/10] HID: Fix race conditions, UAFs, and bounds bugs
@ 2026-11-27 17:06 Lee Jones
  2026-11-27 17:06 ` [PATCH v2 06/10] HID: hyperv: Validate VMBus packet and payload bounds on receive Lee Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Lee Jones @ 2026-11-27 17:06 UTC (permalink / raw)
  To: lee, bpf
  Cc: linux-kernel, Barnabás Pőcze, Benoît Sevens,
	Filipe Laíns, He, Bo, K. Y. Srinivasan, Zhang, Jun,
	Andreas Gal, Andy Shevchenko, Bastien Nocera, Benjamin Tissoires,
	Charles Wang, Dexuan Cui, Dmitry Torokhov, Haiyang Zhang,
	Jason Gerecke, Jiangshan Yi, Jiri Kosina, Jonathan Cameron,
	linux-hyperv, linux-i2c, linux-iio, linux-input, Lopez Casado,
	Marcel Holtmann, message to, Michael Bommarito, Michael Haboustak,
	Pan Chuang, Ping Cheng, Rishi Gupta, Roderick Colenbrander,
	Srinivas Pandruvada, Stefan Achatz, Tianchu Chen, Vojtech Pavlik,
	Wei Liu, Zhang Lixu

These issues were reported by Sashiko.

This v2 series addresses Srinivas Pandruvada's review feedback on
hid-sensor-hub and collects Reviewed-by and Tested-by tags from v1.

v1 => v2:
 - Drop kfree() from sensor_hub_raw_event() and clear hsdev->pending.status before complete() under data->lock in patch 04, per Srinivas Pandruvada's review.
 - Add Hamza Mahfooz's Reviewed-by tag on patch 06.
 - Add Ping Cheng's Reviewed-by and Tested-by tags on patch 08.

Cc: "Barnabás Pőcze" <pobrn@protonmail.com>
Cc: "Benoît Sevens" <bsevens@google.com>
Cc: "Filipe Laíns" <lains@riseup.net>
Cc: "He, Bo" <bo.he@intel.com>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: "Zhang, Jun" <jun.zhang@intel.com>
Cc: Andreas Gal <gal@cs.uni-magdeburg.de>
Cc: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Bastien Nocera <hadess@hadess.net>
Cc: Benjamin Tissoires <bentiss@kernel.org>
Cc: bpf@vger.kernel.org
Cc: Charles Wang <charles.goodix@gmail.com>
Cc: Dexuan Cui <decui@microsoft.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Jason Gerecke <jason.gerecke@wacom.com>
Cc: Jiangshan Yi <yijiangshan@kylinos.cn>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: linux-hyperv@vger.kernel.org
Cc: linux-i2c@vger.kernel.org
Cc: linux-iio@vger.kernel.org
Cc: linux-input@vger.kernel.org
Cc: Lopez Casado <nlopezcasad@logitech.com>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: message to <vojtech@ucw.cz>
Cc: Michael Bommarito <michael.bommarito@gmail.com>
Cc: Michael Haboustak <mike-@cinci.rr.com>
Cc: Pan Chuang <panchuang@vivo.com>
Cc: Ping Cheng <ping.cheng@wacom.com>
Cc: Rishi Gupta <gupt21@gmail.com>
Cc: Roderick Colenbrander <roderick.colenbrander@sony.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Stefan Achatz <erazor_de@users.sourceforge.net>
Cc: Tianchu Chen <flynnnchen@tencent.com>
Cc: Vojtech Pavlik <vojtech@suse.cz>
Cc: Wei Liu <wei.liu@kernel.org>
Cc: Zhang Lixu <lixu.zhang@intel.com>

Lee Jones (10):
  HID: core: Protect hid->inputs traversal in hid_check_keys_pressed()
  HID: mcp2221: Synchronise rxbuf access against raw_event callback
  HID: logitech-hidpp: Synchronise send_receive_buf against raw events
  HID: sensor-hub: Serialise synchronous read teardown under data->lock
  HID: roccat: pyra: Resolve USB device from parent in actual_profile
  HID: hyperv: Validate VMBus packet and payload bounds on receive
  HID: hid-goodix-spi: Validate package sizes in goodix_hid_irq()
  HID: wacom: Stop HID hardware before releasing resources on mode
    change
  HID: debug: Hold driver_input_lock while dumping raw report descriptor
  HID: playstation: Cancel DualSense output worker on create failure

 drivers/hid/hid-core.c           | 16 ++++++---
 drivers/hid/hid-debug.c          | 12 ++++---
 drivers/hid/hid-goodix-spi.c     | 34 +++++++++++++------
 drivers/hid/hid-hyperv.c         | 12 +++++++
 drivers/hid/hid-logitech-hidpp.c | 58 +++++++++++++++++++++-----------
 drivers/hid/hid-mcp2221.c        | 47 ++++++++++++++------------
 drivers/hid/hid-playstation.c    |  1 +
 drivers/hid/hid-roccat-pyra.c    |  9 +++--
 drivers/hid/hid-sensor-hub.c     | 29 ++++++++++++----
 drivers/hid/wacom_sys.c          |  4 +--
 10 files changed, 150 insertions(+), 72 deletions(-)

-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH v2 06/10] HID: hyperv: Validate VMBus packet and payload bounds on receive
  2026-11-27 17:06 [PATCH v2 00/10] HID: Fix race conditions, UAFs, and bounds bugs Lee Jones
@ 2026-11-27 17:06 ` Lee Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2026-11-27 17:06 UTC (permalink / raw)
  To: lee, Haiyang Zhang, Wei Liu, Dexuan Cui, Jiri Kosina,
	Benjamin Tissoires, Michael Bommarito, K. Y. Srinivasan,
	linux-hyperv, linux-input, linux-kernel
  Cc: stable, Hamza Mahfooz

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
Reviewed-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
Signed-off-by: Lee Jones <lee@kernel.org>
---
v1 => v2:
 - Add Reviewed-by tag from Hamza Mahfooz.

 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.839.g22a8290db9-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-27 17:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 17:06 [PATCH v2 00/10] HID: Fix race conditions, UAFs, and bounds bugs Lee Jones
2026-11-27 17:06 ` [PATCH v2 06/10] HID: hyperv: Validate VMBus packet and payload bounds on receive Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox