* [PATCH] HID: sensor-hub: reject short input reports
@ 2026-09-24 15:11 Jiale Yao
0 siblings, 0 replies; only message in thread
From: Jiale Yao @ 2026-09-24 15:11 UTC (permalink / raw)
To: Jiri Kosina, Jonathan Cameron, Srinivas Pandruvada,
Benjamin Tissoires, linux-input, linux-iio, linux-kernel
Cc: Jiale Yao, stable
The HID driver raw_event callback runs before HID core validates the
received report length. sensor_hub_raw_event() walks the fields described
by the report descriptor and advances through raw_data by each field size
without checking that the received buffer contains the complete report.
A truncated report can therefore make the field copy and capture callbacks
read beyond the received data.
Reject input reports shorter than the length derived from their report
descriptor before walking any fields. Commit 47669bec44fe ("HID: asus:
refactor the two workqueues and init sequence") added equivalent raw-event
length validation to hid-asus.
Fixes: 401ca24fb34a ("HID: sensors: introduce sensor framework")
Cc: stable@vger.kernel.org
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/hid/hid-sensor-hub.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 6470a290ebfc..d3e7bdac916c 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -542,6 +542,8 @@ static int sensor_hub_raw_event(struct hid_device *hdev,
hid_dbg(hdev, "maxfield:%d\n", report->maxfield);
if (report->type != HID_INPUT_REPORT)
return 1;
+ if (size < hid_report_len(report))
+ return 1;
ptr = raw_data;
if (report->id)
--
2.34.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-24 15:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-24 15:11 [PATCH] HID: sensor-hub: reject short input reports Jiale Yao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®