Patch "usb: host: xhci: mvebu: Iterate over array indexes instead of using pointer math" has been added to the 5.10-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: host: xhci: mvebu: Iterate over array indexes instead of using pointer math

to the 5.10-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-host-xhci-mvebu-iterate-over-array-indexes-inste.patch
and it can be found in the queue-5.10 subdirectory.

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



commit 512edf5bc1876be46d92a4ecf455784cee478409
Author: Kees Cook <keescook@xxxxxxxxxxxx>
Date:   Sat Feb 4 10:36:52 2023 -0800

    usb: host: xhci: mvebu: Iterate over array indexes instead of using pointer math
    
    [ Upstream commit 0fbd2cda92cdb00f72080665554a586f88bca821 ]
    
    Walking the dram->cs array was seen as accesses beyond the first array
    item by the compiler. Instead, use the array index directly. This allows
    for run-time bounds checking under CONFIG_UBSAN_BOUNDS as well. Seen
    with GCC 13 with -fstrict-flex-arrays:
    
    In function 'xhci_mvebu_mbus_config',
        inlined from 'xhci_mvebu_mbus_init_quirk' at ../drivers/usb/host/xhci-mvebu.c:66:2:
    ../drivers/usb/host/xhci-mvebu.c:37:28: warning: array subscript 0 is outside array bounds of 'const struct mbus_dram_window[0]' [-Warray-bounds=]
       37 |                 writel(((cs->size - 1) & 0xffff0000) | (cs->mbus_attr << 8) |
          |                          ~~^~~~~~
    
    Cc: Mathias Nyman <mathias.nyman@xxxxxxxxx>
    Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230204183651.never.663-kees@xxxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/usb/host/xhci-mvebu.c b/drivers/usb/host/xhci-mvebu.c
index 8ca1a235d1645..eabccf25796b2 100644
--- a/drivers/usb/host/xhci-mvebu.c
+++ b/drivers/usb/host/xhci-mvebu.c
@@ -33,7 +33,7 @@ static void xhci_mvebu_mbus_config(void __iomem *base,
 
 	/* Program each DRAM CS in a seperate window */
 	for (win = 0; win < dram->num_cs; win++) {
-		const struct mbus_dram_window *cs = dram->cs + win;
+		const struct mbus_dram_window *cs = &dram->cs[win];
 
 		writel(((cs->size - 1) & 0xffff0000) | (cs->mbus_attr << 8) |
 		       (dram->mbus_dram_target_id << 4) | 1,



[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