Patch "scsi: aic7xxx: Fix unintentional sign extension issue on left shift of u8" has been added to the 4.4-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

    scsi: aic7xxx: Fix unintentional sign extension issue on left shift of u8

to the 4.4-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:
     scsi-aic7xxx-fix-unintentional-sign-extension-issue-.patch
and it can be found in the queue-4.4 subdirectory.

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



commit 5e5f094e42504e93b2e615363f6d51c07d03ad65
Author: Colin Ian King <colin.king@xxxxxxxxxxxxx>
Date:   Mon Jun 21 16:17:27 2021 +0100

    scsi: aic7xxx: Fix unintentional sign extension issue on left shift of u8
    
    [ Upstream commit 332a9dd1d86f1e7203fc7f0fd7e82f0b304200fe ]
    
    The shifting of the u8 integer returned fom ahc_inb(ahc, port+3) by 24 bits
    to the left will be promoted to a 32 bit signed int and then sign-extended
    to a u64. In the event that the top bit of the u8 is set then all then all
    the upper 32 bits of the u64 end up as also being set because of the
    sign-extension. Fix this by casting the u8 values to a u64 before the 24
    bit left shift.
    
    [ This dates back to 2002, I found the offending commit from the git
    history git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git,
    commit f58eb66c0b0a ("Update aic7xxx driver to 6.2.10...") ]
    
    Link: https://lore.kernel.org/r/20210621151727.20667-1-colin.king@xxxxxxxxxxxxx
    Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>
    Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
    Addresses-Coverity: ("Unintended sign extension")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
index def3208dd290..9b5832b46dec 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_core.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
@@ -500,7 +500,7 @@ ahc_inq(struct ahc_softc *ahc, u_int port)
 	return ((ahc_inb(ahc, port))
 	      | (ahc_inb(ahc, port+1) << 8)
 	      | (ahc_inb(ahc, port+2) << 16)
-	      | (ahc_inb(ahc, port+3) << 24)
+	      | (((uint64_t)ahc_inb(ahc, port+3)) << 24)
 	      | (((uint64_t)ahc_inb(ahc, port+4)) << 32)
 	      | (((uint64_t)ahc_inb(ahc, port+5)) << 40)
 	      | (((uint64_t)ahc_inb(ahc, port+6)) << 48)



[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