* usb: musb: gadget: misplaced out of bounds check
@ 2018-03-29 16:51 Bin Liu
0 siblings, 0 replies; 3+ messages in thread
From: Bin Liu @ 2018-03-29 16:51 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-usb
On Thu, Mar 29, 2018 at 06:36:42PM +0200, Greg Kroah-Hartman wrote:
> On Thu, Mar 29, 2018 at 10:48:28AM -0500, Bin Liu wrote:
> > From: Heinrich Schuchardt <xypron.glpk@gmx.de>
> >
> > musb->endpoints[] has array size MUSB_C_NUM_EPS.
> > We must check array bounds before accessing the array and not afterwards.
> >
> > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> > Signed-off-by: Bin Liu <b-liu@ti.com>
> > ---
> > drivers/usb/musb/musb_gadget_ep0.c | 14 +++++++++-----
> > 1 file changed, 9 insertions(+), 5 deletions(-)
>
> Should this also go to the stable kernels?
Your call. My understanding is this is just a potential, and the code
looks wrong - checking the boundary after used it, but the ep index
won't be able to over the boundary anyway. Though I don't have enough
security knowledge to judge if the bug has an security hole...
Regards,
-Bin.
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* usb: musb: gadget: misplaced out of bounds check
@ 2018-03-29 16:36 Greg Kroah-Hartman
0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2018-03-29 16:36 UTC (permalink / raw)
To: Bin Liu; +Cc: linux-usb
On Thu, Mar 29, 2018 at 10:48:28AM -0500, Bin Liu wrote:
> From: Heinrich Schuchardt <xypron.glpk@gmx.de>
>
> musb->endpoints[] has array size MUSB_C_NUM_EPS.
> We must check array bounds before accessing the array and not afterwards.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Signed-off-by: Bin Liu <b-liu@ti.com>
> ---
> drivers/usb/musb/musb_gadget_ep0.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
Should this also go to the stable kernels?
thanks,
greg k-h
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* usb: musb: gadget: misplaced out of bounds check
@ 2018-03-29 15:48 Bin Liu
0 siblings, 0 replies; 3+ messages in thread
From: Bin Liu @ 2018-03-29 15:48 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-usb, Bin Liu
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
musb->endpoints[] has array size MUSB_C_NUM_EPS.
We must check array bounds before accessing the array and not afterwards.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Bin Liu <b-liu@ti.com>
---
drivers/usb/musb/musb_gadget_ep0.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c
index 18da4873e52e..91a5027b5c1f 100644
--- a/drivers/usb/musb/musb_gadget_ep0.c
+++ b/drivers/usb/musb/musb_gadget_ep0.c
@@ -89,15 +89,19 @@ static int service_tx_status_request(
}
is_in = epnum & USB_DIR_IN;
- if (is_in) {
- epnum &= 0x0f;
+ epnum &= 0x0f;
+ if (epnum >= MUSB_C_NUM_EPS) {
+ handled = -EINVAL;
+ break;
+ }
+
+ if (is_in)
ep = &musb->endpoints[epnum].ep_in;
- } else {
+ else
ep = &musb->endpoints[epnum].ep_out;
- }
regs = musb->endpoints[epnum].regs;
- if (epnum >= MUSB_C_NUM_EPS || !ep->desc) {
+ if (!ep->desc) {
handled = -EINVAL;
break;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-03-29 16:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-29 16:51 usb: musb: gadget: misplaced out of bounds check Bin Liu
-- strict thread matches above, loose matches on Subject: below --
2018-03-29 16:36 Greg Kroah-Hartman
2018-03-29 15:48 Bin Liu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.