summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiale Yao <yaojiale02@163.com>2026-09-24 22:44:05 +0800
committerJiri Kosina <jkosina@suse.com>2026-10-16 11:36:46 +0200
commitc6c0df8a4b73a0d563c5e64de640ef5ff525fc82 (patch)
tree7a118bffabcf3c7c840f593f8aa8dcec45b50bef
parentb2d91f0bcf2e6bfc93f3ffe8023b6df7be65d3d2 (diff)
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. Commit 47669bec44fe ("HID: asus: refactor the two workqueues and init sequence") added the same kind of raw_event length validation to hid-asus. Fixes: b8e759b8f6da ("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>
-rw-r--r--drivers/hid/hid-cougar.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/hid/hid-cougar.c b/drivers/hid/hid-cougar.c
index ad027c45f162..7156658166f5 100644
--- a/drivers/hid/hid-cougar.c
+++ b/drivers/hid/hid-cougar.c
@@ -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++) {