All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sagi Grimberg <sagi@grimberg.me>
To: Israel Rukshin <israelr@mellanox.com>,
	Linux-nvme <linux-nvme@lists.infradead.org>,
	Christoph Hellwig <hch@lst.de>
Cc: Max Gurtovoy <maxg@mellanox.com>
Subject: Re: [PATCH 1/4] nvme-rdma: Fix warning at nvme_rdma_setup_ctrl
Date: Mon, 16 Mar 2020 09:43:46 -0700	[thread overview]
Message-ID: <ce753ba5-1e7e-a25d-f584-db73397cab06@grimberg.me> (raw)
In-Reply-To: <10b7614e-7e3f-095b-5c79-942a9d0593ba@mellanox.com>


>>>>> diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
>>>>> index d6022fa..57f9031 100644
>>>>> --- a/drivers/nvme/host/rdma.c
>>>>> +++ b/drivers/nvme/host/rdma.c
>>>>> @@ -1084,8 +1084,12 @@ static int nvme_rdma_setup_ctrl(struct 
>>>>> nvme_rdma_ctrl *ctrl, bool new)
>>>>>         changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE);
>>>>>       if (!changed) {
>>>>> -        /* state change failure is ok if we're in DELETING state */
>>>>> -        WARN_ON_ONCE(ctrl->ctrl.state != NVME_CTRL_DELETING);
>>>>> +        /*
>>>>> +         * state change failure is ok if we're in DELETING state,
>>>>> +         * unless we're during creation of a new controller to
>>>>> +         * avoid use after free (ctrl refcount is not taken yet).
>>>>> +         */
>>>>> +        WARN_ON_ONCE(ctrl->ctrl.state != NVME_CTRL_DELETING || new);
>>>>
>>>> What state are we in if not DELETING in this case?
>>>
>>> We are in DELETING state.
>>>
>>> With this change any state failure triggers a warning (including 
>>> DELETING) if new is true.
>>>
>>> In my test I was in DELETING state and with new == true
>>>
>>> Trying to change state from DELETING to LIVE is not allowed at the 
>>> state machine.
>>
>> Why do we need a warning on that?
> 
> First, the comment "state change failure is ok if we're in DELETING 
> state" is wrong.

The WARN_ON_ONCE is designed to indicate that we failed to transition
the state but we don't understand why. Is that the case here?

> State change failure should not happen when creating a new controller, 
> because it may lead to controller use after free.

So we need to fix that, but the warning should be printed only when
we get an unexpected behavior from the flow perspective.

> Second, the warning already exists so I am only fixing it.

I don't understand what this is fixing.

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  reply	other threads:[~2020-03-16 16:43 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-11 15:00 [PATCH 0/4] nvme: Fixes for deleting a ctrl before it was created Israel Rukshin
2020-03-11 15:00 ` [PATCH 1/4] nvme-rdma: Fix warning at nvme_rdma_setup_ctrl Israel Rukshin
2020-03-12  6:37   ` Sagi Grimberg
2020-03-12  9:03     ` Israel Rukshin
2020-03-12 23:08       ` Sagi Grimberg
2020-03-15  8:56         ` Israel Rukshin
2020-03-16 16:43           ` Sagi Grimberg [this message]
2020-03-16 18:43             ` Max Gurtovoy
2020-03-17 12:52   ` Christoph Hellwig
2020-03-11 15:00 ` [PATCH 2/4] nvme-tcp: Fix warning at nvme_tcp_setup_ctrl Israel Rukshin
2020-03-11 15:00 ` [PATCH 3/4] nvme: Remove unused return code from nvme_delete_ctrl_sync Israel Rukshin
2020-03-12  6:37   ` Sagi Grimberg
2020-03-17 12:53   ` Christoph Hellwig
2020-03-11 15:00 ` [PATCH 4/4] nvme: Fix controller use after free at create_ctrl callback Israel Rukshin
2020-03-12  6:45   ` Sagi Grimberg
2020-03-12 12:53     ` Israel Rukshin
2020-03-16 16:47       ` Sagi Grimberg
2020-03-17 11:49         ` Israel Rukshin
2020-03-17 12:56           ` Christoph Hellwig
2020-03-17 13:13             ` Israel Rukshin

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=ce753ba5-1e7e-a25d-f584-db73397cab06@grimberg.me \
    --to=sagi@grimberg.me \
    --cc=hch@lst.de \
    --cc=israelr@mellanox.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=maxg@mellanox.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.