Skip to content

Commit 0f877a9

Browse files
mrwigglewafflesroxanan1996
authored andcommitted
hid: asus: asus_report_fixup: fix potential read out of bounds
BugLink: https://bugs.launchpad.net/bugs/2075154 commit 89e1ee1 upstream. syzbot reported a potential read out of bounds in asus_report_fixup. this patch adds checks so that a read out of bounds will not occur Signed-off-by: Andrew Ballance <[email protected]> Reported-by: <[email protected]> Closes: https://syzkaller.appspot.com/bug?extid=07762f019fd03d01f04c Fixes: 59d2f5b ("HID: asus: fix more n-key report descriptors if n-key quirked") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Benjamin Tissoires <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Manuel Diewald <[email protected]> Signed-off-by: Stefan Bader <[email protected]>
1 parent 8ed2e95 commit 0f877a9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/hid/hid-asus.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,8 +1235,8 @@ static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
12351235
}
12361236

12371237
/* match many more n-key devices */
1238-
if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) {
1239-
for (int i = 0; i < *rsize + 1; i++) {
1238+
if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD && *rsize > 15) {
1239+
for (int i = 0; i < *rsize - 15; i++) {
12401240
/* offset to the count from 0x5a report part always 14 */
12411241
if (rdesc[i] == 0x85 && rdesc[i + 1] == 0x5a &&
12421242
rdesc[i + 14] == 0x95 && rdesc[i + 15] == 0x05) {

0 commit comments

Comments
 (0)