From: Bin Liu <b-liu@ti.com>
To: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [1/1] usb: musb: gadget: misplaced out of bounds check
Date: Mon, 19 Mar 2018 11:26:49 -0500 [thread overview]
Message-ID: <20180319162649.GT14921@uda0271908> (raw)
Hi,
On Mon, Mar 19, 2018 at 08:12:28AM +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>
> ---
> drivers/usb/musb/musb_gadget_ep0.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c
> index 18da4873e52e..482e7c2f8dc7 100644
> --- a/drivers/usb/musb/musb_gadget_ep0.c
> +++ b/drivers/usb/musb/musb_gadget_ep0.c
> @@ -88,6 +88,11 @@ static int service_tx_status_request(
> break;
> }
>
> + if (epnum >= MUSB_C_NUM_EPS) {
only the LSB 4 bits are the EP number, bit7 is the direction flag. So
you can only compare the LSB 4 bits here.
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
WARNING: multiple messages have this Message-ID (diff)
From: Bin Liu <b-liu@ti.com>
To: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] usb: musb: gadget: misplaced out of bounds check
Date: Mon, 19 Mar 2018 11:26:49 -0500 [thread overview]
Message-ID: <20180319162649.GT14921@uda0271908> (raw)
In-Reply-To: <20180319071228.11051-1-xypron.glpk@gmx.de>
Hi,
On Mon, Mar 19, 2018 at 08:12:28AM +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>
> ---
> drivers/usb/musb/musb_gadget_ep0.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c
> index 18da4873e52e..482e7c2f8dc7 100644
> --- a/drivers/usb/musb/musb_gadget_ep0.c
> +++ b/drivers/usb/musb/musb_gadget_ep0.c
> @@ -88,6 +88,11 @@ static int service_tx_status_request(
> break;
> }
>
> + if (epnum >= MUSB_C_NUM_EPS) {
only the LSB 4 bits are the EP number, bit7 is the direction flag. So
you can only compare the LSB 4 bits here.
Regards,
-Bin.
next reply other threads:[~2018-03-19 16:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-19 16:26 Bin Liu [this message]
2018-03-19 16:26 ` [PATCH 1/1] usb: musb: gadget: misplaced out of bounds check Bin Liu
-- strict thread matches above, loose matches on Subject: below --
2018-03-19 7:12 [1/1] " Heinrich Schuchardt
2018-03-19 7:12 ` [PATCH 1/1] " Heinrich Schuchardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180319162649.GT14921@uda0271908 \
--to=b-liu@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.