[PATCH 4/4] HID: roccat-savu: reject short special reports
From: Yousef Alhouseen
Date: Sun Jun 28 2026 - 12:37:03 EST
savu_report_to_chrdev() casts special reports to a five-byte structure and
reads all of its payload fields without checking the received size. A
malformed USB device can therefore trigger out-of-bounds reads from the
input buffer when the character device is claimed.
Pass the report size into the helper and require the complete structure.
Fixes: 6a2a6390cf09 ("HID: roccat: add support for Roccat Savu")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Yousef Alhouseen <alhouseenyousef@xxxxxxxxx>
---
drivers/hid/hid-roccat-savu.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-roccat-savu.c b/drivers/hid/hid-roccat-savu.c
index 679136933560..04fa4c50cfa4 100644
--- a/drivers/hid/hid-roccat-savu.c
+++ b/drivers/hid/hid-roccat-savu.c
@@ -152,12 +152,13 @@ static void savu_remove(struct hid_device *hdev)
}
static void savu_report_to_chrdev(struct roccat_common2_device const *savu,
- u8 const *data)
+ u8 const *data, int size)
{
struct savu_roccat_report roccat_report;
struct savu_mouse_report_special const *special_report;
- if (data[0] != SAVU_MOUSE_REPORT_NUMBER_SPECIAL)
+ if (data[0] != SAVU_MOUSE_REPORT_NUMBER_SPECIAL ||
+ size < sizeof(*special_report))
return;
special_report = (struct savu_mouse_report_special const *)data;
@@ -183,7 +184,7 @@ static int savu_raw_event(struct hid_device *hdev,
return 0;
if (savu->roccat_claimed)
- savu_report_to_chrdev(savu, data);
+ savu_report_to_chrdev(savu, data, size);
return 0;
}
--
2.54.0