Skip to content

Commit 25a097f

Browse files
peilin-yeJiri Kosina
authored andcommitted
HID: hiddev: Fix slab-out-of-bounds write in hiddev_ioctl_usage()
`uref->usage_index` is not always being properly checked, causing hiddev_ioctl_usage() to go out of bounds under some cases. Fix it. Reported-by: syzbot+34ee1b45d88571c2fa8b@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?id=f2aebe90b8c56806b050a20b36f51ed6acabe802 Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent 627a499 commit 25a097f

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

drivers/hid/usbhid/hiddev.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,12 +519,16 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd,
519519

520520
switch (cmd) {
521521
case HIDIOCGUSAGE:
522+
if (uref->usage_index >= field->report_count)
523+
goto inval;
522524
uref->value = field->value[uref->usage_index];
523525
if (copy_to_user(user_arg, uref, sizeof(*uref)))
524526
goto fault;
525527
goto goodreturn;
526528

527529
case HIDIOCSUSAGE:
530+
if (uref->usage_index >= field->report_count)
531+
goto inval;
528532
field->value[uref->usage_index] = uref->value;
529533
goto goodreturn;
530534

0 commit comments

Comments
 (0)