* Re: [PATCH] usb: musb: Fix musb_gadget.c rxstate may cause request->buf overflow problems
[not found] <59fe30106aec46ff9ec1261fbb609606@inspur.com>
@ 2022-07-26 17:12 ` gregkh
0 siblings, 0 replies; 3+ messages in thread
From: gregkh @ 2022-07-26 17:12 UTC (permalink / raw)
To: Andy Guo (郭卫斌)
Cc: b-liu@ti.com, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
On Tue, Jul 26, 2022 at 01:59:48AM +0000, Andy Guo (郭卫斌) wrote:
> when the rxstate function executes the 'goto buffer_aint_mapped' code
> branch, it will always copy the fifocnt bytes data to request->buf,
> which may cause request->buf out of bounds. for Ethernet-over-USB will
> cause skb_over_panic when a packet larger than mtu is recived.
>
> Fix it by add the length check :
> fifocnt = min_t(unsigned, request->length - request->actual, fifocnt);
>
> Signed-off-by: guoweibin < <mailto:guoweibin@inspur.com>
> guoweibin@inspur.com>
> ---
> drivers/usb/musb/musb_gadget.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
> index 51274b87f46c..4ad5a1f31d7e 100644
> --- a/drivers/usb/musb/musb_gadget.c
> +++ b/drivers/usb/musb/musb_gadget.c
> @@ -760,6 +760,7 @@ static void rxstate(struct musb *musb, struct
> musb_request *req)
> musb_writew(epio, MUSB_RXCSR, csr);
>
> buffer_aint_mapped:
> + fifo_count = min_t(unsigned, request->length - request->actual,
> fifo_count);
> musb_read_fifo(musb_ep->hw_ep, fifo_count, (u8 *)
> (request->buf + request->actual));
> request->actual += fifo_count;
>
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- Your patch is malformed (tabs converted to spaces, linewrapped, etc.)
and can not be applied. Please read the file,
Documentation/email-clients.txt in order to fix this.
- Your patch was attached, please place it inline so that it can be
applied directly from the email message itself.
- It looks like you did not use your "real" name for the patch on either
the Signed-off-by: line, or the From: line (both of which have to
match). Please read the kernel file, Documentation/SubmittingPatches
for how to do this correctly.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] usb: musb: Fix musb_gadget.c rxstate may cause request->buf overflow problems
@ 2022-07-27 7:21 Andy Guo (郭卫斌)
2022-07-27 7:33 ` gregkh
0 siblings, 1 reply; 3+ messages in thread
From: Andy Guo (郭卫斌) @ 2022-07-27 7:21 UTC (permalink / raw)
To: b-liu@ti.com, gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 1052 bytes --]
when the rxstate function executes the 'goto buffer_aint_mapped' code
branch, it will always copy the fifocnt bytes data to request->buf,
which may cause request->buf out of bounds. for Ethernet-over-USB will
cause skb_over_panic when a packet larger than mtu is recived.
Fix it by add the length check :
fifocnt = min_t(unsigned, request->length - request->actual, fifocnt);
Signed-off-by: guoweibin <guoweibin@inspur.com>
---
drivers/usb/musb/musb_gadget.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 51274b87f46c..4ad5a1f31d7e 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -760,6 +760,7 @@ static void rxstate(struct musb *musb, struct musb_request *req)
musb_writew(epio, MUSB_RXCSR, csr);
buffer_aint_mapped:
+ fifo_count = min_t(unsigned, request->length - request->actual, fifo_count);
musb_read_fifo(musb_ep->hw_ep, fifo_count, (u8 *)
(request->buf + request->actual));
request->actual += fifo_count;
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 3801 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: musb: Fix musb_gadget.c rxstate may cause request->buf overflow problems
2022-07-27 7:21 [PATCH] usb: musb: Fix musb_gadget.c rxstate may cause request->buf overflow problems Andy Guo (郭卫斌)
@ 2022-07-27 7:33 ` gregkh
0 siblings, 0 replies; 3+ messages in thread
From: gregkh @ 2022-07-27 7:33 UTC (permalink / raw)
To: Andy Guo (郭卫斌)
Cc: b-liu@ti.com, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
On Wed, Jul 27, 2022 at 07:21:39AM +0000, Andy Guo (郭卫斌) wrote:
> when the rxstate function executes the 'goto buffer_aint_mapped' code
> branch, it will always copy the fifocnt bytes data to request->buf,
> which may cause request->buf out of bounds. for Ethernet-over-USB will
> cause skb_over_panic when a packet larger than mtu is recived.
>
> Fix it by add the length check :
> fifocnt = min_t(unsigned, request->length - request->actual, fifocnt);
>
> Signed-off-by: guoweibin <guoweibin@inspur.com>
> ---
> drivers/usb/musb/musb_gadget.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
> index 51274b87f46c..4ad5a1f31d7e 100644
> --- a/drivers/usb/musb/musb_gadget.c
> +++ b/drivers/usb/musb/musb_gadget.c
> @@ -760,6 +760,7 @@ static void rxstate(struct musb *musb, struct musb_request *req)
> musb_writew(epio, MUSB_RXCSR, csr);
>
> buffer_aint_mapped:
> + fifo_count = min_t(unsigned, request->length - request->actual, fifo_count);
> musb_read_fifo(musb_ep->hw_ep, fifo_count, (u8 *)
> (request->buf + request->actual));
> request->actual += fifo_count;
>
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- It looks like you did not use your "real" name for the patch on either
the Signed-off-by: line, or the From: line (both of which have to
match). Please read the kernel file, Documentation/SubmittingPatches
for how to do this correctly.
- This looks like a new version of a previously submitted patch, but you
did not list below the --- line any changes from the previous version.
Please read the section entitled "The canonical patch format" in the
kernel file, Documentation/SubmittingPatches for what needs to be done
here to properly describe this.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-27 7:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-27 7:21 [PATCH] usb: musb: Fix musb_gadget.c rxstate may cause request->buf overflow problems Andy Guo (郭卫斌)
2022-07-27 7:33 ` gregkh
[not found] <59fe30106aec46ff9ec1261fbb609606@inspur.com>
2022-07-26 17:12 ` gregkh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).