summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2022-06-29 13:40:57 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-07-07 17:35:09 +0200
commit3553a69bb52be2deba61d0ca064c41aee842bb35 (patch)
treee1e0264360c0487348d8869de8aac5fba8d93649
parentdf1a5ab0dd0775f2ea101c71f2addbc4c0ea0f85 (diff)
downloadlinux-stable-3553a69bb52be2deba61d0ca064c41aee842bb35.tar.gz
linux-stable-3553a69bb52be2deba61d0ca064c41aee842bb35.tar.bz2
linux-stable-3553a69bb52be2deba61d0ca064c41aee842bb35.zip
dm raid: fix KASAN warning in raid5_add_disks
commit 617b365872a247480e9dcd50a32c8d1806b21861 upstream. There's a KASAN warning in raid5_add_disk when running the LVM testsuite. The warning happens in the test lvconvert-raid-reshape-linear_to_raid6-single-type.sh. We fix the warning by verifying that rdev->saved_raid_disk is within limits. Cc: stable@vger.kernel.org Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Mike Snitzer <snitzer@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/md/raid5.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index c7bda4b0bced..dad426cc0f90 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -7716,6 +7716,7 @@ static int raid5_add_disk(struct mddev *mddev, struct md_rdev *rdev)
*/
if (rdev->saved_raid_disk >= 0 &&
rdev->saved_raid_disk >= first &&
+ rdev->saved_raid_disk <= last &&
conf->disks[rdev->saved_raid_disk].rdev == NULL)
first = rdev->saved_raid_disk;