Linux RAID subsystem development
 help / color / mirror / Atom feed
From: Song Liu <songliubraving@fb.com>
To: NeilBrown <neilb@suse.com>
Cc: Yufen Yu <yuyufen@huawei.com>,
	"axboe@kernel.dk" <axboe@kernel.dk>,
	"xni@redhat.com" <xni@redhat.com>,
	"linux-raid@vger.kernel.org" <linux-raid@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH v2] md: add mddev->pers to avoid potential NULL pointer dereference
Date: Tue, 2 Apr 2019 22:41:00 +0000	[thread overview]
Message-ID: <6D99E4B5-ADCC-4BF2-A447-4EE52FE775FE@fb.com> (raw)
In-Reply-To: <87lg0s159q.fsf@notabene.neil.brown.name>



> On Apr 2, 2019, at 2:11 PM, NeilBrown <neilb@suse.com> wrote:
> 
> On Tue, Apr 02 2019, Yufen Yu wrote:
> 
>> When doing re-add, we need to ensure rdev->mddev->pers is not NULL,
>> which can avoid potential NULL pointer derefence in fallowing
>> add_bound_rdev().
>> 
>> Fixes: a6da4ef85cef ("md: re-add a failed disk")
>> Cc: Xiao Ni <xni@redhat.com>
>> Cc: NeilBrown <neilb@suse.com>
>> Cc: <stable@vger.kernel.org>
>> Signed-off-by: Yufen Yu <yuyufen@huawei.com>
> 
> Reviewed-by: NeilBrown <neilb@suse.com>
> 
> Thanks,
> NeilBrown

Thanks Yufen and Neil. 

I applied it to the md-next branch:

https://github.com/liu-song-6/linux/tree/md-next

Song

> 
>> ---
>> drivers/md/md.c | 6 ++++--
>> 1 file changed, 4 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/md/md.c b/drivers/md/md.c
>> index 875b29ba5926..66b6bdf9f364 100644
>> --- a/drivers/md/md.c
>> +++ b/drivers/md/md.c
>> @@ -2859,8 +2859,10 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)
>> 			err = 0;
>> 		}
>> 	} else if (cmd_match(buf, "re-add")) {
>> -		if (test_bit(Faulty, &rdev->flags) && (rdev->raid_disk == -1) &&
>> -			rdev->saved_raid_disk >= 0) {
>> +		if (!rdev->mddev->pers)
>> +			err = -EINVAL;
>> +		else if (test_bit(Faulty, &rdev->flags) && (rdev->raid_disk == -1) &&
>> +				rdev->saved_raid_disk >= 0) {
>> 			/* clear_bit is performed _after_ all the devices
>> 			 * have their local Faulty bit cleared. If any writes
>> 			 * happen in the meantime in the local node, they
>> -- 
>> 2.16.2.dirty

      reply	other threads:[~2019-04-02 22:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-02  6:22 [PATCH v2] md: add mddev->pers to avoid potential NULL pointer dereference Yufen Yu
2019-04-02 21:11 ` NeilBrown
2019-04-02 22:41   ` Song Liu [this message]

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=6D99E4B5-ADCC-4BF2-A447-4EE52FE775FE@fb.com \
    --to=songliubraving@fb.com \
    --cc=axboe@kernel.dk \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.com \
    --cc=stable@vger.kernel.org \
    --cc=xni@redhat.com \
    --cc=yuyufen@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