Patch "sky2: Make sure there is at least one frag_addr available" has been added to the 5.15-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

    sky2: Make sure there is at least one frag_addr available

to the 5.15-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:
     sky2-make-sure-there-is-at-least-one-frag_addr-avail.patch
and it can be found in the queue-5.15 subdirectory.

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



commit 8a2eabe9402e695a0d61b4ecc87eb00f49b837b0
Author: Kees Cook <keescook@xxxxxxxxxxxx>
Date:   Fri Sep 22 09:50:39 2023 -0700

    sky2: Make sure there is at least one frag_addr available
    
    [ Upstream commit 6a70e5cbedaf8ad10528ac9ac114f3ec20f422df ]
    
    In the pathological case of building sky2 with 16k PAGE_SIZE, the
    frag_addr[] array would never be used, so the original code was correct
    that size should be 0. But the compiler now gets upset with 0 size arrays
    in places where it hasn't eliminated the code that might access such an
    array (it can't figure out that in this case an rx skb with fragments
    would never be created). To keep the compiler happy, make sure there is
    at least 1 frag_addr in struct rx_ring_info:
    
       In file included from include/linux/skbuff.h:28,
                        from include/net/net_namespace.h:43,
                        from include/linux/netdevice.h:38,
                        from drivers/net/ethernet/marvell/sky2.c:18:
       drivers/net/ethernet/marvell/sky2.c: In function 'sky2_rx_unmap_skb':
       include/linux/dma-mapping.h:416:36: warning: array subscript i is outside array bounds of 'dma_addr_t[0]' {aka 'long long unsigned int[]'} [-Warray-bounds=]
         416 | #define dma_unmap_page(d, a, s, r) dma_unmap_page_attrs(d, a, s, r, 0)
             |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       drivers/net/ethernet/marvell/sky2.c:1257:17: note: in expansion of macro 'dma_unmap_page'
        1257 |                 dma_unmap_page(&pdev->dev, re->frag_addr[i],
             |                 ^~~~~~~~~~~~~~
       In file included from drivers/net/ethernet/marvell/sky2.c:41:
       drivers/net/ethernet/marvell/sky2.h:2198:25: note: while referencing 'frag_addr'
        2198 |         dma_addr_t      frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT];
             |                         ^~~~~~~~~
    
    With CONFIG_PAGE_SIZE_16KB=y, PAGE_SHIFT == 14, so:
    
      #define ETH_JUMBO_MTU   9000
    
    causes "ETH_JUMBO_MTU >> PAGE_SHIFT" to be 0. Use "?: 1" to solve this build warning.
    
    Cc: Mirko Lindner <mlindner@xxxxxxxxxxx>
    Cc: Stephen Hemminger <stephen@xxxxxxxxxxxxxxxxxx>
    Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
    Cc: Eric Dumazet <edumazet@xxxxxxxxxx>
    Cc: Jakub Kicinski <kuba@xxxxxxxxxx>
    Cc: Paolo Abeni <pabeni@xxxxxxxxxx>
    Cc: netdev@xxxxxxxxxxxxxxx
    Reported-by: kernel test robot <lkp@xxxxxxxxx>
    Closes: https://lore.kernel.org/oe-kbuild-all/202309191958.UBw1cjXk-lkp@xxxxxxxxx/
    Reviewed-by: Alexander Lobakin <aleksander.lobakin@xxxxxxxxx>
    Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
    Reviewed-by: Gustavo A. R. Silva <gustavoars@xxxxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/ethernet/marvell/sky2.h b/drivers/net/ethernet/marvell/sky2.h
index ddec1627f1a7b..8d0bacf4e49cc 100644
--- a/drivers/net/ethernet/marvell/sky2.h
+++ b/drivers/net/ethernet/marvell/sky2.h
@@ -2195,7 +2195,7 @@ struct rx_ring_info {
 	struct sk_buff	*skb;
 	dma_addr_t	data_addr;
 	DEFINE_DMA_UNMAP_LEN(data_size);
-	dma_addr_t	frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT];
+	dma_addr_t	frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT ?: 1];
 };
 
 enum flow_control {



[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