Skip to content

Commit e716eda

Browse files
lag-linaroBenjamin Tissoires
authored andcommitted
HID: multitouch: Check to ensure report responses match the request
It is possible for a malicious (or clumsy) device to respond to a specific report's feature request using a completely different report ID. This can cause confusion in the HID core resulting in nasty side-effects such as OOB writes. Add a check to ensure that the report ID in the response, matches the one that was requested. If it doesn't, omit reporting the raw event and return early. Signed-off-by: Lee Jones <lee@kernel.org> Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
1 parent f7a4c78 commit e716eda

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

drivers/hid/hid-multitouch.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,19 @@ static void mt_get_feature(struct hid_device *hdev, struct hid_report *report)
526526
dev_warn(&hdev->dev, "failed to fetch feature %d\n",
527527
report->id);
528528
} else {
529+
/* The report ID in the request and the response should match */
530+
if (report->id != buf[0]) {
531+
hid_err(hdev, "Returned feature report did not match the request\n");
532+
goto free;
533+
}
534+
529535
ret = hid_report_raw_event(hdev, HID_FEATURE_REPORT, buf,
530536
size, 0);
531537
if (ret)
532538
dev_warn(&hdev->dev, "failed to report feature\n");
533539
}
534540

541+
free:
535542
kfree(buf);
536543
}
537544

0 commit comments

Comments
 (0)