From: Li Nan <linan666@huaweicloud.com>
To: Yu Kuai <yukuai1@huaweicloud.com>,
linan666@huaweicloud.com, song@kernel.org,
bingjingc@synology.com, allenpeng@synology.com,
alexwu@synology.com, shli@fb.com, neilb@suse.de
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com,
"yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH v2 1/4] md/raid10: fix null-ptr-deref of mreplace in raid10_sync_request
Date: Sat, 27 May 2023 09:29:52 +0800 [thread overview]
Message-ID: <532a0a45-368b-2fee-6054-682c64bb12ce@huaweicloud.com> (raw)
In-Reply-To: <261a87ef-341e-67ff-f804-9e6f354452dc@huaweicloud.com>
在 2023/5/27 9:21, Yu Kuai 写道:
> Hi,
>
> 在 2023/05/26 15:45, linan666@huaweicloud.com 写道:
>> From: Li Nan <linan122@huawei.com>
>>
>> need_replace will be set to 1 if no-Faulty mreplace exists, and mreplace
>> will be deref later. However, the latter check of mreplace might set
>> mreplace to NULL, null-ptr-deref occurs if need_replace is 1 at this
>> time.
>>
>> Fix it by merging two checks into one. And replace 'need_replace' with
>> 'mreplace' because their values are always the same.
>>
>> Fixes: ee37d7314a32 ("md/raid10: Fix raid10 replace hang when new
>> added disk faulty")
>> Signed-off-by: Li Nan <linan122@huawei.com>
>
> Other than some nits below, this patch looks good to me, feel free too
> add:
>
> Reviewed-by: Yu Kuai <yukuai3@huawei.com>
>> ---
>> drivers/md/raid10.c | 13 +++++--------
>> 1 file changed, 5 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
>> index 4fcfcb350d2b..e21502c03b45 100644
>> --- a/drivers/md/raid10.c
>> +++ b/drivers/md/raid10.c
>> @@ -3438,7 +3438,6 @@ static sector_t raid10_sync_request(struct mddev
>> *mddev, sector_t sector_nr,
>> int must_sync;
>> int any_working;
>> int need_recover = 0;
>> - int need_replace = 0;
>> struct raid10_info *mirror = &conf->mirrors[i];
>> struct md_rdev *mrdev, *mreplace;
>> @@ -3451,10 +3450,10 @@ static sector_t raid10_sync_request(struct
>> mddev *mddev, sector_t sector_nr,
>> !test_bit(In_sync, &mrdev->flags))
>> need_recover = 1;
>> if (mreplace != NULL &&
>> - !test_bit(Faulty, &mreplace->flags))
>> - need_replace = 1;
>> + test_bit(Faulty, &mreplace->flags))
> This can be keeped in one line.
>
OK, I will change it.
Thanks for your review.
--
Thanks,
Nan
next prev parent reply other threads:[~2023-05-27 1:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-26 7:45 [PATCH v2 0/4] raid10 bugfix linan666
2023-05-26 7:45 ` [PATCH v2 1/4] md/raid10: fix null-ptr-deref of mreplace in raid10_sync_request linan666
2023-05-26 21:38 ` Song Liu
2023-05-27 1:17 ` Yu Kuai
2023-05-27 1:28 ` Li Nan
2023-05-27 1:21 ` Yu Kuai
2023-05-27 1:29 ` Li Nan [this message]
2023-05-26 7:45 ` [PATCH v2 2/4] md/raid10: improve code of mrdev " linan666
2023-05-27 1:41 ` Yu Kuai
2023-05-26 7:45 ` [PATCH v2 3/4] md/raid10: fix incorrect done of recovery linan666
2023-05-26 7:45 ` [PATCH v2 4/4] md/raid10: fix io loss while replacement replace rdev linan666
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=532a0a45-368b-2fee-6054-682c64bb12ce@huaweicloud.com \
--to=linan666@huaweicloud.com \
--cc=alexwu@synology.com \
--cc=allenpeng@synology.com \
--cc=bingjingc@synology.com \
--cc=houtao1@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
--cc=shli@fb.com \
--cc=song@kernel.org \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai1@huaweicloud.com \
--cc=yukuai3@huawei.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®