Re: [PATCH] md/raid10: initialize r10_bio->read_slot before use.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 5, 2020 at 10:08 AM Kevin Vigor <kvigor@xxxxxxxxx> wrote:
>
> In __make_request() a new r10bio is allocated and passed to
> raid10_read_request(). The read_slot member of the bio is not
> initialized, and the raid10_read_request() uses it to index an
> array. This leads to occasional panics.
>
> Fix by initializing the field to invalid value and checking for
> valid value in raid10_read_request().
>
> Signed-off-by: Kevin Vigor <kvigor@xxxxxxxxx>

Thanks for the fix!

I am having problem apply this patch, could you please rebase against

   git://git.kernel.org/pub/scm/linux/kernel/git/song/md.git  md-next

> ---
>  drivers/md/raid10.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 8a1354a08a1a..64b1306b0c4a 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -1143,7 +1143,7 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio,
>         struct md_rdev *err_rdev = NULL;
>         gfp_t gfp = GFP_NOIO;
>
> -       if (r10_bio->devs[slot].rdev) {
> +       if (slot >= 0 && r10_bio->devs[slot].rdev) {

If we set default read_slot = 0, we should not need this change, right?

>                 /*
>                  * This is an error retry, but we cannot
>                  * safely dereference the rdev in the r10_bio,
> @@ -1508,6 +1508,7 @@ static void __make_request(struct mddev *mddev, struct bio *bio, int sectors)
>         r10_bio->mddev = mddev;
>         r10_bio->sector = bio->bi_iter.bi_sector;
>         r10_bio->state = 0;
> +       r10_bio->read_slot = -1;
>         memset(r10_bio->devs, 0, sizeof(r10_bio->devs[0]) * conf->copies);
>
>         if (bio_data_dir(bio) == READ)
> --
> 2.26.2
>



[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux