mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
HID: cougar: reject short special-key reports
The HID core invokes raw_event callbacks before validating the report length. cougar_raw_event() reads the key code and action from offsets one and two without checking that those bytes are present. A short report on the special interface can therefore cause an out-of-bounds read. Consume reports that do not contain the action field before accessing the fixed offsets, consistent with the callback's handling of other reports on the special interface. Commit47669bec44("HID: asus: refactor the two workqueues and init sequence") added the same kind of raw_event length validation to hid-asus. Fixes:b8e759b8f6("HID: cougar: Add support for the Cougar 500k Gaming Keyboard") Cc: stable@vger.kernel.org Signed-off-by: Jiale Yao <yaojiale02@163.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
This commit is contained in:
parent
b2d91f0bcf
commit
c6c0df8a4b
|
|
@ -270,6 +270,9 @@ static int cougar_raw_event(struct hid_device *hdev, struct hid_report *report,
|
|||
if (!shared->enabled || !shared->input)
|
||||
return -EPERM;
|
||||
|
||||
if (size <= COUGAR_FIELD_ACTION)
|
||||
return -EPERM;
|
||||
|
||||
code = data[COUGAR_FIELD_CODE];
|
||||
action = data[COUGAR_FIELD_ACTION];
|
||||
for (i = 0; cougar_mapping[i][0]; i++) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user