* [PATCH] usb: musb: Fix musb_gadget.c rxstate overflow bug
@ 2022-09-05 1:02 guoweibin
2022-09-05 7:13 ` gregkh
0 siblings, 1 reply; 2+ messages in thread
From: guoweibin @ 2022-09-05 1:02 UTC (permalink / raw)
To: gregkh; +Cc: linux-usb, linux-kernel
From: guoweibin <guoweibin@inspur.com>
Date: Mon, 25 Jul 2022 19:27:49 +0800
Subject: [PATCH] usb: musb: Fix musb_gadget.c rxstate overflow bug
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..
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 | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 51274b87f46c..dc67fff8e941 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -760,6 +760,9 @@ static void rxstate(struct musb *musb, struct musb_request *req)
musb_writew(epio, MUSB_RXCSR, csr);
buffer_aint_mapped:
+ fifo_count = min_t(unsigned int,
+ request->length - request->actual,
+ (unsigned int)fifo_count);
musb_read_fifo(musb_ep->hw_ep, fifo_count, (u8 *)
(request->buf + request->actual));
request->actual += fifo_count;
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: musb: Fix musb_gadget.c rxstate overflow bug
2022-09-05 1:02 [PATCH] usb: musb: Fix musb_gadget.c rxstate overflow bug guoweibin
@ 2022-09-05 7:13 ` gregkh
0 siblings, 0 replies; 2+ messages in thread
From: gregkh @ 2022-09-05 7:13 UTC (permalink / raw)
To: guoweibin; +Cc: linux-usb, linux-kernel
On Mon, Sep 05, 2022 at 09:02:12AM +0800, guoweibin wrote:
> From: guoweibin <guoweibin@inspur.com>
> Date: Mon, 25 Jul 2022 19:27:49 +0800
> Subject: [PATCH] usb: musb: Fix musb_gadget.c rxstate overflow bug
Odd, this shouldn't be in the body of the email if you use 'git
send-email', how did you send it?
>
> 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..
>
> Fix it by add the length check :
> fifocnt = min_t(unsigned, request->length - request->actual, fifocnt);
>
> Signed-off-by: guoweibin <guoweibin@inspur.com>
I need a "full" name, not just an email alias as a name for a
signed-off-by: Please fix that up and resend a v2.
And what commit does this fix?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-05 7:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-05 1:02 [PATCH] usb: musb: Fix musb_gadget.c rxstate overflow bug guoweibin
2022-09-05 7:13 ` gregkh
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®