Skip to content

Commit b12fece

Browse files
pietroborrelloJiri Kosina
authored andcommitted
HID: check empty report_list in hid_validate_values()
Add a check for empty report_list in hid_validate_values(). The missing check causes a type confusion when issuing a list_entry() on an empty report_list. The problem is caused by the assumption that the device must have valid report_list. While this will be true for all normal HID devices, a suitably malicious device can violate the assumption. Fixes: 1b15d2e ("HID: core: fix validation of report id 0") Signed-off-by: Pietro Borrello <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 2a33ad4 commit b12fece

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/hid/hid-core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,8 @@ struct hid_report *hid_validate_values(struct hid_device *hid,
993993
* Validating on id 0 means we should examine the first
994994
* report in the list.
995995
*/
996-
report = list_entry(
997-
hid->report_enum[type].report_list.next,
996+
report = list_first_entry_or_null(
997+
&hid->report_enum[type].report_list,
998998
struct hid_report, list);
999999
} else {
10001000
report = hid->report_enum[type].report_id_hash[id];

0 commit comments

Comments
 (0)