Skip to content

Commit

Permalink
usb: usbtest: avoid integer overflow in test_ctrl_queue()
Browse files Browse the repository at this point in the history
Avoid overflowing context.count = param->sglen * param->iterations,
where both `sglen' and `iterations' are from userspace.

| test_ctrl_queue()
| usbtest_ioctl()

Keep -EOPNOTSUPP for error code.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Xi Wang authored and Greg Kroah-Hartman committed Apr 17, 2012
1 parent 8963c48 commit e65cdfa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/usb/misc/usbtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,9 @@ test_ctrl_queue(struct usbtest_dev *dev, struct usbtest_param *param)
struct ctrl_ctx context;
int i;

if (param->sglen == 0 || param->iterations > UINT_MAX / param->sglen)
return -EOPNOTSUPP;

spin_lock_init(&context.lock);
context.dev = dev;
init_completion(&context.complete);
Expand Down Expand Up @@ -1981,8 +1984,6 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)

/* queued control messaging */
case 10:
if (param->sglen == 0)
break;
retval = 0;
dev_info(&intf->dev,
"TEST 10: queue %d control calls, %d times\n",
Expand Down

0 comments on commit e65cdfa

Please sign in to comment.