From: NeilBrown <neilb@suse.com>
To: Yufen Yu <yuyufen@huawei.com>, axboe@kernel.dk, songliubraving@fb.com
Cc: xni@redhat.com, linux-raid@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2] md: add mddev->pers to avoid potential NULL pointer dereference
Date: Wed, 03 Apr 2019 08:11:45 +1100 [thread overview]
Message-ID: <87lg0s159q.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <20190402062214.136669-1-yuyufen@huawei.com>
[-- Attachment #1: Type: text/plain, Size: 1330 bytes --]
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
> ---
> 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next prev parent reply other threads:[~2019-04-02 21:11 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 [this message]
2019-04-02 22:41 ` 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=87lg0s159q.fsf@notabene.neil.brown.name \
--to=neilb@suse.com \
--cc=axboe@kernel.dk \
--cc=linux-raid@vger.kernel.org \
--cc=songliubraving@fb.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