All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Leng <lengchao@huawei.com>
To: Sagi Grimberg <sagi@grimberg.me>, Daniel Wagner <dwagner@suse.de>
Cc: <linux-nvme@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
	"Jens Axboe" <axboe@fb.com>, Hannes Reinecke <hare@suse.de>,
	Keith Busch <kbusch@kernel.org>, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v2] nvme-multipath: Early exit if no path is available
Date: Fri, 29 Jan 2021 11:36:08 +0800	[thread overview]
Message-ID: <a3c64c60-13f3-1b99-47bc-05ebfefed343@huawei.com> (raw)
In-Reply-To: <dbc39e56-b2bd-a82e-499a-5032c9716855@grimberg.me>



On 2021/1/29 11:30, Sagi Grimberg wrote:
> 
>>>>> You can't see exactly where it dies but I followed the assembly to
>>>>> nvme_round_robin_path(). Maybe it's not the initial nvme_next_ns(head,
>>>>> old) which returns NULL but nvme_next_ns() is returning NULL eventually
>>>>> (list_next_or_null_rcu()).
>>>> So there is other bug cause nvme_next_ns abormal.
>>>> I review the code about head->list and head->current_path, I find 2 bugs
>>>> may cause the bug:
>>>> First, I already send the patch. see:
>>>> https://lore.kernel.org/linux-nvme/20210128033351.22116-1-lengchao@huawei.com/
>>>> Second, in nvme_ns_remove, list_del_rcu is before
>>>> nvme_mpath_clear_current_path. This may cause "old" is deleted from the
>>>> "head", but still use "old". I'm not sure there's any other
>>>> consideration here, I will check it and try to fix it.
>>>
>>> The reason why we first remove from head->list and only then clear
>>> current_path is because the other way around there is no way
>>> to guarantee that that the ns won't be assigned as current_path
>>> again (because it is in head->list).
>> ok, I see.
>>>
>>> nvme_ns_remove fences continue of deletion of the ns by synchronizing
>>> the srcu such that for sure the current_path clearance is visible.
>> The list will be like this:
>> head->next = ns1;
>> ns1->next = head;
>> old->next = ns1;
>> This may cause infinite loop in nvme_round_robin_path.
>> for (ns = nvme_next_ns(head, old);
>>      ns != old;
>>      ns = nvme_next_ns(head, ns))
>> The ns will always be ns1, and then infinite loop.
> 
> Who is being removed? I'm not following
The "old" is being removed path.
Daniel Wagner report crash like this:
head->next = head;
old->next = head;
So nvme_next_ns(head, old) will return NULL, and then crash.
Although check ns can avoid crash, but can not avoid infinite loop.

Similar reason, The list will be like this:
head->next = ns1;
ns1->next = head;
old->next = ns1;
ns1 is other path.

> .

WARNING: multiple messages have this Message-ID (diff)
From: Chao Leng <lengchao@huawei.com>
To: Sagi Grimberg <sagi@grimberg.me>, Daniel Wagner <dwagner@suse.de>
Cc: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org,
	Jens Axboe <axboe@fb.com>, Hannes Reinecke <hare@suse.de>,
	Keith Busch <kbusch@kernel.org>, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v2] nvme-multipath: Early exit if no path is available
Date: Fri, 29 Jan 2021 11:36:08 +0800	[thread overview]
Message-ID: <a3c64c60-13f3-1b99-47bc-05ebfefed343@huawei.com> (raw)
In-Reply-To: <dbc39e56-b2bd-a82e-499a-5032c9716855@grimberg.me>



On 2021/1/29 11:30, Sagi Grimberg wrote:
> 
>>>>> You can't see exactly where it dies but I followed the assembly to
>>>>> nvme_round_robin_path(). Maybe it's not the initial nvme_next_ns(head,
>>>>> old) which returns NULL but nvme_next_ns() is returning NULL eventually
>>>>> (list_next_or_null_rcu()).
>>>> So there is other bug cause nvme_next_ns abormal.
>>>> I review the code about head->list and head->current_path, I find 2 bugs
>>>> may cause the bug:
>>>> First, I already send the patch. see:
>>>> https://lore.kernel.org/linux-nvme/20210128033351.22116-1-lengchao@huawei.com/
>>>> Second, in nvme_ns_remove, list_del_rcu is before
>>>> nvme_mpath_clear_current_path. This may cause "old" is deleted from the
>>>> "head", but still use "old". I'm not sure there's any other
>>>> consideration here, I will check it and try to fix it.
>>>
>>> The reason why we first remove from head->list and only then clear
>>> current_path is because the other way around there is no way
>>> to guarantee that that the ns won't be assigned as current_path
>>> again (because it is in head->list).
>> ok, I see.
>>>
>>> nvme_ns_remove fences continue of deletion of the ns by synchronizing
>>> the srcu such that for sure the current_path clearance is visible.
>> The list will be like this:
>> head->next = ns1;
>> ns1->next = head;
>> old->next = ns1;
>> This may cause infinite loop in nvme_round_robin_path.
>> for (ns = nvme_next_ns(head, old);
>>      ns != old;
>>      ns = nvme_next_ns(head, ns))
>> The ns will always be ns1, and then infinite loop.
> 
> Who is being removed? I'm not following
The "old" is being removed path.
Daniel Wagner report crash like this:
head->next = head;
old->next = head;
So nvme_next_ns(head, old) will return NULL, and then crash.
Although check ns can avoid crash, but can not avoid infinite loop.

Similar reason, The list will be like this:
head->next = ns1;
ns1->next = head;
old->next = ns1;
ns1 is other path.

> .

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

  reply	other threads:[~2021-01-29  3:37 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27 10:30 [PATCH v2] nvme-multipath: Early exit if no path is available Daniel Wagner
2021-01-27 10:30 ` Daniel Wagner
2021-01-27 10:34 ` Hannes Reinecke
2021-01-27 10:34   ` Hannes Reinecke
2021-01-27 16:49 ` Christoph Hellwig
2021-01-27 16:49   ` Christoph Hellwig
2021-01-28  1:31 ` Chao Leng
2021-01-28  1:31   ` Chao Leng
2021-01-28  7:58   ` Daniel Wagner
2021-01-28  7:58     ` Daniel Wagner
2021-01-28  9:18     ` Chao Leng
2021-01-28  9:18       ` Chao Leng
2021-01-28  9:23       ` Hannes Reinecke
2021-01-28  9:23         ` Hannes Reinecke
2021-01-29  1:18         ` Chao Leng
2021-01-29  1:18           ` Chao Leng
2021-01-28  9:40       ` Daniel Wagner
2021-01-28  9:40         ` Daniel Wagner
2021-01-29  1:23         ` Chao Leng
2021-01-29  1:23           ` Chao Leng
2021-01-29  1:42           ` Sagi Grimberg
2021-01-29  1:42             ` Sagi Grimberg
2021-01-29  3:07             ` Chao Leng
2021-01-29  3:07               ` Chao Leng
2021-01-29  3:30               ` Sagi Grimberg
2021-01-29  3:30                 ` Sagi Grimberg
2021-01-29  3:36                 ` Chao Leng [this message]
2021-01-29  3:36                   ` Chao Leng
2021-01-29  7:06               ` Hannes Reinecke
2021-01-29  7:06                 ` Hannes Reinecke
2021-01-29  7:45                 ` Chao Leng
2021-01-29  8:33                   ` Hannes Reinecke
2021-01-29  8:46                     ` Chao Leng
2021-01-29  9:20                       ` Hannes Reinecke
2021-02-01  2:16                         ` Chao Leng
2021-02-01  2:16                           ` Chao Leng
2021-02-01  7:29                           ` Hannes Reinecke
2021-02-01  7:29                             ` Hannes Reinecke
2021-02-01  8:47                             ` Chao Leng
2021-02-01  8:47                               ` Chao Leng
2021-02-01  8:57                               ` Hannes Reinecke
2021-02-01  8:57                                 ` Hannes Reinecke
2021-02-01  9:40                                 ` Chao Leng
2021-02-01  9:40                                   ` Chao Leng
2021-02-01 10:45                                   ` Hannes Reinecke
2021-02-01 10:45                                     ` Hannes Reinecke
2021-02-02  1:12                                     ` Chao Leng
2021-02-02  1:12                                       ` Chao Leng
2021-01-28  1:36 ` Chao Leng
2021-01-28  1:36   ` Chao Leng

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=a3c64c60-13f3-1b99-47bc-05ebfefed343@huawei.com \
    --to=lengchao@huawei.com \
    --cc=axboe@fb.com \
    --cc=dwagner@suse.de \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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.