[PATCH] usb: gadget: composite: avoid access beyond array max length

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



One of the USB CV MSC tests issues Get Max LUN request with
invalid wIndex (wIndex = 65535) parameter.

Add proper handling to prevent array index out of bounds issue.

Signed-off-by: Maulik Mankad <maulik@xxxxxx>
Cc: David Brownell <david-b@xxxxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxx>
---
Tested on OMAP4 SDP.
 drivers/usb/gadget/composite.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index f6ff845..1ba4bef 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -928,8 +928,9 @@ unknown:
 		 */
 		switch (ctrl->bRequestType & USB_RECIP_MASK) {
 		case USB_RECIP_INTERFACE:
-			if (cdev->config)
-				f = cdev->config->interface[intf];
+			if (!cdev->config || w_index >= MAX_CONFIG_INTERFACES)
+				break;
+			f = cdev->config->interface[intf];
 			break;
 
 		case USB_RECIP_ENDPOINT:
-- 
1.6.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux