mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] usb: dwc2: fix the incorrect bitmaps for the ports of multi_tt hub
@ 2018-05-21 10:12 William Wu
  2018-05-21 23:41 ` Doug Anderson
  2018-05-29 14:45 ` Minas Harutyunyan
  0 siblings, 2 replies; 3+ messages in thread
From: William Wu @ 2018-05-21 10:12 UTC (permalink / raw)
  To: hminas, felipe.balbi, gregkh
  Cc: sergei.shtylyov, heiko, linux-kernel, linux-usb, linux-rockchip,
	frank.wang, huangtao, dianders, daniel.meng, John.Youn,
	william.wu, fml

The dwc2_get_ls_map() use ttport to reference into the
bitmap if we're on a multi_tt hub. But the bitmaps index
from 0 to (hub->maxchild - 1), while the ttport index from
1 to hub->maxchild. This will cause invalid memory access
when the number of ttport is hub->maxchild.

Without this patch, I can easily meet a Kernel panic issue
if connect a low-speed USB mouse with the max port of FE2.1
multi-tt hub (1a40:0201) on rk3288 platform.

Signed-off-by: William Wu <william.wu@rock-chips.com>
---
 drivers/usb/dwc2/hcd_queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c
index d7c3d6c..9c55d1a 100644
--- a/drivers/usb/dwc2/hcd_queue.c
+++ b/drivers/usb/dwc2/hcd_queue.c
@@ -383,7 +383,7 @@ static unsigned long *dwc2_get_ls_map(struct dwc2_hsotg *hsotg,
 	/* Get the map and adjust if this is a multi_tt hub */
 	map = qh->dwc_tt->periodic_bitmaps;
 	if (qh->dwc_tt->usb_tt->multi)
-		map += DWC2_ELEMENTS_PER_LS_BITMAP * qh->ttport;
+		map += DWC2_ELEMENTS_PER_LS_BITMAP * (qh->ttport - 1);
 
 	return map;
 }
-- 
2.0.0



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: dwc2: fix the incorrect bitmaps for the ports of multi_tt hub
  2018-05-21 10:12 [PATCH] usb: dwc2: fix the incorrect bitmaps for the ports of multi_tt hub William Wu
@ 2018-05-21 23:41 ` Doug Anderson
  2018-05-29 14:45 ` Minas Harutyunyan
  1 sibling, 0 replies; 3+ messages in thread
From: Doug Anderson @ 2018-05-21 23:41 UTC (permalink / raw)
  To: William Wu
  Cc: hminas, felipe.balbi, Greg Kroah-Hartman, Sergei Shtylyov,
	Heiko Stübner, LKML, linux-usb,
	open list:ARM/Rockchip SoC..., Frank Wang, 黄涛,
	daniel.meng, John Youn, fml, stable

Hi,

On Mon, May 21, 2018 at 3:12 AM, William Wu <william.wu@rock-chips.com> wrote:
> The dwc2_get_ls_map() use ttport to reference into the
> bitmap if we're on a multi_tt hub. But the bitmaps index
> from 0 to (hub->maxchild - 1), while the ttport index from
> 1 to hub->maxchild. This will cause invalid memory access
> when the number of ttport is hub->maxchild.
>
> Without this patch, I can easily meet a Kernel panic issue
> if connect a low-speed USB mouse with the max port of FE2.1
> multi-tt hub (1a40:0201) on rk3288 platform.
>
> Signed-off-by: William Wu <william.wu@rock-chips.com>
> ---
>  drivers/usb/dwc2/hcd_queue.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c
> index d7c3d6c..9c55d1a 100644
> --- a/drivers/usb/dwc2/hcd_queue.c
> +++ b/drivers/usb/dwc2/hcd_queue.c
> @@ -383,7 +383,7 @@ static unsigned long *dwc2_get_ls_map(struct dwc2_hsotg *hsotg,
>         /* Get the map and adjust if this is a multi_tt hub */
>         map = qh->dwc_tt->periodic_bitmaps;
>         if (qh->dwc_tt->usb_tt->multi)
> -               map += DWC2_ELEMENTS_PER_LS_BITMAP * qh->ttport;
> +               map += DWC2_ELEMENTS_PER_LS_BITMAP * (qh->ttport - 1);

Oops, thanks for the fix.

Fixes: 9f9f09b048f5 ("usb: dwc2: host: Totally redo the microframe scheduler")
Cc: stable@vger.kernel.org
Reviewed-by: Douglas Anderson <dianders@chromium.org>

-Doug

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: dwc2: fix the incorrect bitmaps for the ports of multi_tt hub
  2018-05-21 10:12 [PATCH] usb: dwc2: fix the incorrect bitmaps for the ports of multi_tt hub William Wu
  2018-05-21 23:41 ` Doug Anderson
@ 2018-05-29 14:45 ` Minas Harutyunyan
  1 sibling, 0 replies; 3+ messages in thread
From: Minas Harutyunyan @ 2018-05-29 14:45 UTC (permalink / raw)
  To: William Wu, Minas.Harutyunyan, felipe.balbi, gregkh
  Cc: sergei.shtylyov, heiko, linux-kernel, linux-usb, linux-rockchip,
	frank.wang, huangtao, dianders, daniel.meng, John.Youn, fml

Acked-by Minas Harutyunyan hminas@synopsys.com>

On 5/21/2018 2:13 PM, William Wu wrote:
> The dwc2_get_ls_map() use ttport to reference into the
> bitmap if we're on a multi_tt hub. But the bitmaps index
> from 0 to (hub->maxchild - 1), while the ttport index from
> 1 to hub->maxchild. This will cause invalid memory access
> when the number of ttport is hub->maxchild.
> 
> Without this patch, I can easily meet a Kernel panic issue
> if connect a low-speed USB mouse with the max port of FE2.1
> multi-tt hub (1a40:0201) on rk3288 platform.
> 
> Signed-off-by: William Wu <william.wu@rock-chips.com>
> ---
>   drivers/usb/dwc2/hcd_queue.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c
> index d7c3d6c..9c55d1a 100644
> --- a/drivers/usb/dwc2/hcd_queue.c
> +++ b/drivers/usb/dwc2/hcd_queue.c
> @@ -383,7 +383,7 @@ static unsigned long *dwc2_get_ls_map(struct dwc2_hsotg *hsotg,
>   	/* Get the map and adjust if this is a multi_tt hub */
>   	map = qh->dwc_tt->periodic_bitmaps;
>   	if (qh->dwc_tt->usb_tt->multi)
> -		map += DWC2_ELEMENTS_PER_LS_BITMAP * qh->ttport;
> +		map += DWC2_ELEMENTS_PER_LS_BITMAP * (qh->ttport - 1);
>   
>   	return map;
>   }
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-29 14:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-21 10:12 [PATCH] usb: dwc2: fix the incorrect bitmaps for the ports of multi_tt hub William Wu
2018-05-21 23:41 ` Doug Anderson
2018-05-29 14:45 ` Minas Harutyunyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®