mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
HID: fix HIDIOCGRDESC memory access in hidraw
Fix bogus copying of data into userspace when HIDIOCGRDESC is issued. HID-transport layer makes sure that dev->hid->rdesc is not larger than HID_MAX_DESCRIPTOR_SIZE. Noticed-by: Al Viro <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
23fd50450a
commit
57d292bd7e
3 changed files with 24 additions and 14 deletions
|
|
@ -229,9 +229,15 @@ static int hidraw_ioctl(struct inode *inode, struct file *file, unsigned int cmd
|
|||
|
||||
if (get_user(len, (int __user *)arg))
|
||||
return -EFAULT;
|
||||
if (copy_to_user(*((__u8 **)(user_arg +
|
||||
sizeof(__u32))),
|
||||
dev->hid->rdesc, len))
|
||||
|
||||
if (len > HID_MAX_DESCRIPTOR_SIZE - 1)
|
||||
return -EINVAL;
|
||||
|
||||
if (copy_to_user(user_arg + offsetof(
|
||||
struct hidraw_report_descriptor,
|
||||
value[0]),
|
||||
dev->hid->rdesc,
|
||||
min(dev->hid->rsize, len)))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue