Skip to content

Commit

Permalink
USB: core: limit access to rawdescriptors which were not allocated
Browse files Browse the repository at this point in the history
When using systemcall to read the rawdescriptors, make sure we won't
access to the rawdescriptors never allocated, which are number
exceed the USB_MAXCONFIG.

Reported-by: syzbot+256e56ddde8b8957eabd@syzkaller.appspotmail.com
Signed-off-by: Yanfei Xu <yanfei.xu@windriver.com>
  • Loading branch information
Yanfei Xu authored and intel-lab-lkp committed Aug 25, 2020
1 parent 28157b8 commit dda85cf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/usb/core/sysfs.c
Expand Up @@ -895,7 +895,8 @@ read_descriptors(struct file *filp, struct kobject *kobj,
* configurations (config plus subsidiary descriptors).
*/
for (cfgno = -1; cfgno < udev->descriptor.bNumConfigurations &&
nleft > 0; ++cfgno) {
nleft > 0 &&
cfgno < USB_MAXCONFIG; ++cfgno) {
if (cfgno < 0) {
src = &udev->descriptor;
srclen = sizeof(struct usb_device_descriptor);
Expand Down

0 comments on commit dda85cf

Please sign in to comment.