Patch "md/raid10: fix overflow of md/safe_mode_delay" has been added to the 5.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

    md/raid10: fix overflow of md/safe_mode_delay

to the 5.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:
     md-raid10-fix-overflow-of-md-safe_mode_delay.patch
and it can be found in the queue-5.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 047ef324b352b0a73fa40f3a132be57b8dc224b8
Author: Li Nan <linan122@xxxxxxxxxx>
Date:   Mon May 22 15:25:33 2023 +0800

    md/raid10: fix overflow of md/safe_mode_delay
    
    [ Upstream commit 6beb489b2eed25978523f379a605073f99240c50 ]
    
    There is no input check when echo md/safe_mode_delay in safe_delay_store().
    And msec might also overflow when HZ < 1000 in safe_delay_show(), Fix it by
    checking overflow in safe_delay_store() and use unsigned long conversion in
    safe_delay_show().
    
    Fixes: 72e02075a33f ("md: factor out parsing of fixed-point numbers")
    Signed-off-by: Li Nan <linan122@xxxxxxxxxx>
    Signed-off-by: Song Liu <song@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230522072535.1523740-2-linan666@xxxxxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 64558991ce0a0..bae264aae3cd0 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -3766,8 +3766,9 @@ int strict_strtoul_scaled(const char *cp, unsigned long *res, int scale)
 static ssize_t
 safe_delay_show(struct mddev *mddev, char *page)
 {
-	int msec = (mddev->safemode_delay*1000)/HZ;
-	return sprintf(page, "%d.%03d\n", msec/1000, msec%1000);
+	unsigned int msec = ((unsigned long)mddev->safemode_delay*1000)/HZ;
+
+	return sprintf(page, "%u.%03u\n", msec/1000, msec%1000);
 }
 static ssize_t
 safe_delay_store(struct mddev *mddev, const char *cbuf, size_t len)
@@ -3779,7 +3780,7 @@ safe_delay_store(struct mddev *mddev, const char *cbuf, size_t len)
 		return -EINVAL;
 	}
 
-	if (strict_strtoul_scaled(cbuf, &msec, 3) < 0)
+	if (strict_strtoul_scaled(cbuf, &msec, 3) < 0 || msec > UINT_MAX / HZ)
 		return -EINVAL;
 	if (msec == 0)
 		mddev->safemode_delay = 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