Patch "usb: musb: Fix musb_gadget.c rxstate overflow bug" has been added to the 4.9-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    usb: musb: Fix musb_gadget.c rxstate overflow bug

to the 4.9-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     usb-musb-fix-musb_gadget.c-rxstate-overflow-bug.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 89ce6f83350f1e25e68e44734ffeacd6056a38ab
Author: Robin Guo <guoweibin@xxxxxxxxxx>
Date:   Tue Sep 6 10:21:19 2022 +0800

    usb: musb: Fix musb_gadget.c rxstate overflow bug
    
    [ Upstream commit eea4c860c3b366369eff0489d94ee4f0571d467d ]
    
    The usb function device call musb_gadget_queue() adds the passed
    request to musb_ep::req_list,If the (request->length > musb_ep->packet_sz)
    and (is_buffer_mapped(req) return false),the rxstate() will copy all data
    in fifo 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: Robin Guo <guoweibin@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20220906102119.1b071d07a8391ff115e6d1ef@xxxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 8eb3a291ca9d..02ec84ce5ab9 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -785,6 +785,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;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux