Skip to content

Commit

Permalink
dm raid: fix KASAN warning in raid5_remove_disk
Browse files Browse the repository at this point in the history
There's a KASAN warning in raid5_remove_disk when running the LVM
testsuite. We fix this warning by verifying that the "number" variable is
within limits.

Cc: stable@vger.kernel.org
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
  • Loading branch information
Mikulas Patocka authored and Mike Snitzer committed Jun 29, 2022
1 parent 332bd07 commit 1ebc2ce
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/md/raid5.c
Original file line number Diff line number Diff line change
Expand Up @@ -7933,7 +7933,7 @@ static int raid5_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
int err = 0;
int number = rdev->raid_disk;
struct md_rdev __rcu **rdevp;
struct disk_info *p = conf->disks + number;
struct disk_info *p;
struct md_rdev *tmp;

print_raid5_conf(conf);
Expand All @@ -7952,6 +7952,9 @@ static int raid5_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
log_exit(conf);
return 0;
}
if (unlikely(number >= conf->pool_size))
return 0;
p = conf->disks + number;
if (rdev == rcu_access_pointer(p->rdev))
rdevp = &p->rdev;
else if (rdev == rcu_access_pointer(p->replacement))
Expand Down

0 comments on commit 1ebc2ce

Please sign in to comment.