Patch "liquidio: Fix unintented sign extension of a left shift of a u16" 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

    liquidio: Fix unintented sign extension of a left shift of a u16

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:
     liquidio-fix-unintented-sign-extension-of-a-left-shi.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 b8f84b4e639783a2fadda04920fd2d430c509160
Author: Colin Ian King <colin.king@xxxxxxxxxxxxx>
Date:   Wed Apr 7 11:12:48 2021 +0100

    liquidio: Fix unintented sign extension of a left shift of a u16
    
    [ Upstream commit 298b58f00c0f86868ea717426beb5c1198772f81 ]
    
    The macro CN23XX_PEM_BAR1_INDEX_REG is being used to shift oct->pcie_port
    (a u16) left 24 places. There are two subtle issues here, first the
    shift gets promoted to an signed int and then sign extended to a u64.
    If oct->pcie_port is 0x80 or more then the upper bits get sign extended
    to 1. Secondly shfiting a u16 24 bits will lead to an overflow so it
    needs to be cast to a u64 for all the bits to not overflow.
    
    It is entirely possible that the u16 port value is never large enough
    for this to fail, but it is useful to fix unintended overflows such
    as this.
    
    Fix this by casting the port parameter to the macro to a u64 before
    the shift.
    
    Addresses-Coverity: ("Unintended sign extension")
    Fixes: 5bc67f587ba7 ("liquidio: CN23XX register definitions")
    Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_regs.h b/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_regs.h
index e6d4ad99cc38..3f1c189646f4 100644
--- a/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_regs.h
+++ b/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_regs.h
@@ -521,7 +521,7 @@
 #define    CN23XX_BAR1_INDEX_OFFSET                3
 
 #define    CN23XX_PEM_BAR1_INDEX_REG(port, idx)		\
-		(CN23XX_PEM_BAR1_INDEX_START + ((port) << CN23XX_PEM_OFFSET) + \
+		(CN23XX_PEM_BAR1_INDEX_START + (((u64)port) << CN23XX_PEM_OFFSET) + \
 		 ((idx) << CN23XX_BAR1_INDEX_OFFSET))
 
 /*############################ DPI #########################*/



[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