]> git.baikalelectronics.ru Git - kernel.git/commitdiff
dm raid: fix KASAN warning in raid5_add_disks
authorMikulas Patocka <mpatocka@redhat.com>
Wed, 29 Jun 2022 17:40:57 +0000 (13:40 -0400)
committerMike Snitzer <snitzer@kernel.org>
Wed, 29 Jun 2022 23:48:04 +0000 (19:48 -0400)
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>
drivers/md/raid5.c

index ba289411f26f7dc9fbefe0a57a033be73b869043..20e53b167f81f5d4dd03507edb9eb93bf3ed7411 100644 (file)
@@ -8065,6 +8065,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;