LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Song Liu <song@kernel.org>
To: lwt105 <3061522931@qq.com>
Cc: linux-raid <linux-raid@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drivers:md:fix a potential use-after-free bug
Date: Fri, 13 Aug 2021 09:16:00 -0700	[thread overview]
Message-ID: <CAPhsuW7cC+d5mhNjJb0AiHDKCUb5WzYPNzZ5UPOSScdtFuNzww@mail.gmail.com> (raw)
In-Reply-To: <tencent_888910D6F881B3D8BD9C3DFED667A5009806@qq.com>

On Thu, Aug 12, 2021 at 8:46 PM lwt105 <3061522931@qq.com> 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@qq.com>

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
>

       reply	other threads:[~2021-08-13 16:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <tencent_888910D6F881B3D8BD9C3DFED667A5009806@qq.com>
2021-08-13 16:16 ` Song Liu [this message]
2021-08-17  7:47   ` Guoqing Jiang
2022-07-28 11:39 Wentao_Liang
2022-07-28  5:55 ` Song Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPhsuW7cC+d5mhNjJb0AiHDKCUb5WzYPNzZ5UPOSScdtFuNzww@mail.gmail.com \
    --to=song@kernel.org \
    --cc=3061522931@qq.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --subject='Re: [PATCH] drivers:md:fix a potential use-after-free bug' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).