* [PATCH v3 1/1] usb: musb: gadget: misplaced out of bounds check
@ 2018-03-20 18:42 ` Heinrich Schuchardt
0 siblings, 0 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2018-03-20 18:42 UTC (permalink / raw)
To: Bin Liu
Cc: Sergei Shtylyov, Greg Kroah-Hartman, linux-usb, linux-kernel,
Heinrich Schuchardt
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>
---
v3
Remove superfluous braces.
v2
Only the 4 low bits of epnum are relevant for indexing.
---
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;
}
--
2.16.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [v3,1/1] usb: musb: gadget: misplaced out of bounds check
@ 2018-03-20 18:42 ` Heinrich Schuchardt
0 siblings, 0 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2018-03-20 18:42 UTC (permalink / raw)
To: Bin Liu
Cc: Sergei Shtylyov, Greg Kroah-Hartman, linux-usb, linux-kernel,
Heinrich Schuchardt
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>
---
v3
Remove superfluous braces.
v2
Only the 4 low bits of epnum are relevant for indexing.
---
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] 4+ messages in thread
* Re: [PATCH v3 1/1] usb: musb: gadget: misplaced out of bounds check
@ 2018-03-20 18:55 ` Bin Liu
0 siblings, 0 replies; 4+ messages in thread
From: Bin Liu @ 2018-03-20 18:55 UTC (permalink / raw)
To: Heinrich Schuchardt
Cc: Sergei Shtylyov, Greg Kroah-Hartman, linux-usb, linux-kernel
Hi,
On Tue, Mar 20, 2018 at 07:42:48PM +0100, Heinrich Schuchardt wrote:
> 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>
> ---
> v3
> Remove superfluous braces.
> v2
> Only the 4 low bits of epnum are relevant for indexing.
> ---
> drivers/usb/musb/musb_gadget_ep0.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
Applied. Thanks.
Regards,
-Bin.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [v3,1/1] usb: musb: gadget: misplaced out of bounds check
@ 2018-03-20 18:55 ` Bin Liu
0 siblings, 0 replies; 4+ messages in thread
From: Bin Liu @ 2018-03-20 18:55 UTC (permalink / raw)
To: Heinrich Schuchardt
Cc: Sergei Shtylyov, Greg Kroah-Hartman, linux-usb, linux-kernel
Hi,
On Tue, Mar 20, 2018 at 07:42:48PM +0100, Heinrich Schuchardt wrote:
> 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>
> ---
> v3
> Remove superfluous braces.
> v2
> Only the 4 low bits of epnum are relevant for indexing.
> ---
> drivers/usb/musb/musb_gadget_ep0.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
Applied. Thanks.
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] 4+ messages in thread
end of thread, other threads:[~2018-03-20 18:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-20 18:42 [PATCH v3 1/1] usb: musb: gadget: misplaced out of bounds check Heinrich Schuchardt
2018-03-20 18:42 ` [v3,1/1] " Heinrich Schuchardt
2018-03-20 18:55 ` [PATCH v3 1/1] " Bin Liu
2018-03-20 18:55 ` [v3,1/1] " 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.