Re: [PATCH] drivers:md:fix a potential use-after-free bug

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

 



On Thu, Aug 12, 2021 at 8:46 PM lwt105 <3061522931@xxxxxx> wrote:
>
> In line 2867, "raid5_release_stripe(sh);" drops the reference to sh and
> may cause sh to be released. However, sh is subsequently used in lines
> 2869 "if (sh->batch_head && sh != sh->batch_head)". This may result in an
> use-after-free bug.
>
> It can be fixed by moving "raid5_release_stripe(sh);" to the bottom of
> the function.
>
> Signed-off-by: lwt105 <3061522931@xxxxxx>

The fix looks reasonable. I guess lwt105 is not a real name. Please update
the diff with your real name.

Thanks,
Song
> ---
>  drivers/md/raid5.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index b8436e4930ed..16ed44646419 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -2864,10 +2864,10 @@ static void raid5_end_write_request(struct bio *bi)
>         if (!test_and_clear_bit(R5_DOUBLE_LOCKED, &sh->dev[i].flags))
>                 clear_bit(R5_LOCKED, &sh->dev[i].flags);
>         set_bit(STRIPE_HANDLE, &sh->state);
> -       raid5_release_stripe(sh);
>
>         if (sh->batch_head && sh != sh->batch_head)
>                 raid5_release_stripe(sh->batch_head);
> +       raid5_release_stripe(sh);
>  }
>
>  static void raid5_error(struct mddev *mddev, struct md_rdev *rdev)
> --
> 2.25.1
>



[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