USB: array-index-out-of-bounds in ehci_brcm_hub_control
Subsystems (3)
PATCH 1/1 USB: array-index-out-of-bounds in ehci_brcm_hub_control
There isn't enough check parameter wIndex in the function ehci_brcm_hub_control;due to the size of array port_status is 15, so it may lead to out of bounds.
Signed-off-by Haimin Zhang <[email protected]>
Reported-by TCS Robot <[email protected]>
--- drivers/usb/host/ehci-brcm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/host/ehci-brcm.c +2 -1
@@ -63,7 +63,8 @@ static int ehci_brcm_hub_control(unsigned long flags;int retval, irq_disabled =0 ; - status_reg = &ehci->regs->port_status[(wIndex &0xff ) -1 ]; +if (wIndex && wIndex <= ports) + status_reg = &ehci->regs->port_status[(wIndex &0xff ) -1 ];/* * RESUME is cleared when GetPortStatus() is called 20ms after start
Alan Stern
maintainerQuoted 15 lines · Haimin Zhang
There isn't enough check parameter
wIndexin the functionehci_brcm_hub_control;due to the size of arrayport_statusis 15, so it may lead to out of bounds.Signed-off-by Haimin Zhang <[email protected]>Reported-by TCS Robot <[email protected]>--- drivers/usb/host/ehci-brcm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/usb/host/ehci-brcm.c +0
-0
drivers/usb/host/ehci-brcm.c static int ehci_brcm_hub_control( · line 67
Quoted 6 lines
drivers/usb/host/ehci-brcm.c +2
-1@@ -63,7 +63,8 @@ static int ehci_brcm_hub_control(unsigned long flags;int retval, irq_disabled =0 ; - status_reg = &ehci->regs->port_status[(wIndex &0xff ) -1 ]; +if (wIndex && wIndex <= ports) + status_reg = &ehci->regs->port_status[(wIndex &0xff ) -1 ];
This isn't quite right because it won't work properly if the upper byte of wIndex is nonzero. You should do something like:
u32 temp; temp = (wIndex & 0xff) - 1; if (temp < ports) status_reg = &ehci->regs->port_status[temp];
Alan Stern