diff mbox series

md-raid10: fix KASAN warning

Message ID alpine.LRH.2.02.2207241426320.26078@file01.intranet.prod.int.rdu2.redhat.com (mailing list archive)
State New, archived
Delegated to: Song Liu
Headers show
Series md-raid10: fix KASAN warning | expand

Commit Message

Mikulas Patocka July 24, 2022, 6:29 p.m. UTC
There's a KASAN warning in raid10_remove_disk when running the lvm
test lvconvert-raid-reshape.sh. We fix this warning by verifying that the
value "number" is valid.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org

---
 drivers/md/raid10.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Song Liu July 26, 2022, 5:22 a.m. UTC | #1
On Sun, Jul 24, 2022 at 11:29 AM Mikulas Patocka <mpatocka@redhat.com> wrote:
>
> There's a KASAN warning in raid10_remove_disk when running the lvm
> test lvconvert-raid-reshape.sh. We fix this warning by verifying that the
> value "number" is valid.
>
> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> Cc: stable@vger.kernel.org

Could you please add the KASAN message to the commit log?

Thanks,
Song

>
> ---
>  drivers/md/raid10.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> Index: linux-2.6/drivers/md/raid10.c
> ===================================================================
> --- linux-2.6.orig/drivers/md/raid10.c  2022-07-13 19:05:50.000000000 +0200
> +++ linux-2.6/drivers/md/raid10.c       2022-07-13 19:07:05.000000000 +0200
> @@ -2167,9 +2167,12 @@ static int raid10_remove_disk(struct mdd
>         int err = 0;
>         int number = rdev->raid_disk;
>         struct md_rdev **rdevp;
> -       struct raid10_info *p = conf->mirrors + number;
> +       struct raid10_info *p;
>
>         print_conf(conf);
> +       if (unlikely(number >= mddev->raid_disks))
> +               return 0;
> +       p = conf->mirrors + number;
>         if (rdev == p->rdev)
>                 rdevp = &p->rdev;
>         else if (rdev == p->replacement)
>
diff mbox series

Patch

Index: linux-2.6/drivers/md/raid10.c
===================================================================
--- linux-2.6.orig/drivers/md/raid10.c	2022-07-13 19:05:50.000000000 +0200
+++ linux-2.6/drivers/md/raid10.c	2022-07-13 19:07:05.000000000 +0200
@@ -2167,9 +2167,12 @@  static int raid10_remove_disk(struct mdd
 	int err = 0;
 	int number = rdev->raid_disk;
 	struct md_rdev **rdevp;
-	struct raid10_info *p = conf->mirrors + number;
+	struct raid10_info *p;
 
 	print_conf(conf);
+	if (unlikely(number >= mddev->raid_disks))
+		return 0;
+	p = conf->mirrors + number;
 	if (rdev == p->rdev)
 		rdevp = &p->rdev;
 	else if (rdev == p->replacement)