Patch "hwmon: (dimmtemp) Fix bitmap handling" has been added to the 5.18-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

    hwmon: (dimmtemp) Fix bitmap handling

to the 5.18-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:
     hwmon-dimmtemp-fix-bitmap-handling.patch
and it can be found in the queue-5.18 subdirectory.

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



commit fe6f3aee536689996c02aacdb470b89f19c956f1
Author: Guenter Roeck <linux@xxxxxxxxxxxx>
Date:   Tue May 17 13:08:25 2022 -0700

    hwmon: (dimmtemp) Fix bitmap handling
    
    [ Upstream commit 9baabde04de64137e86b39112c6259f3da512bd6 ]
    
    Building arm:allmodconfig may fail with the following error.
    
    In function 'fortify_memcpy_chk',
        inlined from 'bitmap_copy' at include/linux/bitmap.h:261:2,
        inlined from 'bitmap_copy_clear_tail' at include/linux/bitmap.h:270:2,
        inlined from 'bitmap_from_u64' at include/linux/bitmap.h:622:2,
        inlined from 'check_populated_dimms' at
            drivers/hwmon/peci/dimmtemp.c:284:2:
    include/linux/fortify-string.h:344:25: error:
            call to '__write_overflow_field' declared with attribute warning:
            detected write beyond size of field (1st parameter)
    
    The problematic code is
            bitmap_from_u64(priv->dimm_mask, dimm_mask);
    
    dimm_mask is declared as u64, but the bitmap in priv->dimm_mask is only
    24 bit wide. On 32-bit systems, this results in writes over the end of
    the bitmap.
    
    Fix the problem by using u32 instead of u64 for dimm_mask. This is
    currently sufficient, and a compile time check to ensure that the number
    of dimms does not exceed the bit map size is already in place.
    
    Fixes: 73bc1b885dae ("hwmon: peci: Add dimmtemp driver")
    Cc: Iwona Winiarska <iwona.winiarska@xxxxxxxxx>
    Reviewed-by: Iwona Winiarska <iwona.winiarska@xxxxxxxxx>
    Signed-off-by: Guenter Roeck <linux@xxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/hwmon/peci/dimmtemp.c b/drivers/hwmon/peci/dimmtemp.c
index c8222354c005..53e58a9c28ea 100644
--- a/drivers/hwmon/peci/dimmtemp.c
+++ b/drivers/hwmon/peci/dimmtemp.c
@@ -219,7 +219,7 @@ static int check_populated_dimms(struct peci_dimmtemp *priv)
 	int chan_rank_max = priv->gen_info->chan_rank_max;
 	int dimm_idx_max = priv->gen_info->dimm_idx_max;
 	u32 chan_rank_empty = 0;
-	u64 dimm_mask = 0;
+	u32 dimm_mask = 0;
 	int chan_rank, dimm_idx, ret;
 	u32 pcs;
 
@@ -278,9 +278,9 @@ static int check_populated_dimms(struct peci_dimmtemp *priv)
 		return -EAGAIN;
 	}
 
-	dev_dbg(priv->dev, "Scanned populated DIMMs: %#llx\n", dimm_mask);
+	dev_dbg(priv->dev, "Scanned populated DIMMs: %#x\n", dimm_mask);
 
-	bitmap_from_u64(priv->dimm_mask, dimm_mask);
+	bitmap_from_arr32(priv->dimm_mask, &dimm_mask, DIMM_NUMS_MAX);
 
 	return 0;
 }



[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