lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <65b0c372-b308-46dd-c2f2-a5ddb50adb10@linux.alibaba.com>
Date:   Tue, 28 Nov 2023 14:22:27 +0800
From:   yaoma <yaoma@...ux.alibaba.com>
To:     Keith Busch <kbusch@...nel.org>
Cc:     axboe@...nel.dk, hch@....de, sagi@...mberg.me,
        linux-nvme@...ts.infradead.org, linux-kernel@...r.kernel.org,
        kanie@...ux.alibaba.com
Subject: Re: [PATCH] nvme: fix deadlock between reset and scan

Hi Keith Busch

Thanks for your reply.

The idea to avoid such a deadlock between nvme_reset and nvme_scan is to 
ensure that no namespace can be added to ctrl->namespaces after 
nvme_start_freeze has already been called. We can achieve this goal by 
assessing the ctrl->state after we have already acquired the 
ctrl->namespaces_rwsem lock, to decide whether to add the namespace to 
the list or not.
1. After we determine that ctrl->state is LIVE, it may be immediately 
changed to another state. However, since we have already acquired the 
lock, other tasks cannot access ctrl->namespace, so we can still safely 
add the namespace to the list. After acquiring the lock, 
nvme_start_freeze will freeze all ns->q in the list, including any newly 
added namespaces.
2. Before the completion of nvme_reset, ctrl->state will not be changed 
to LIVE, so we will not add any more namespaces to the list. All ns->q 
in the list is frozen, so nvme_wait_freeze can exit normally.


On 2023/11/28 02:07, Keith Busch wrote:
> On Thu, Nov 23, 2023 at 07:00:13PM +0800, Bitao Hu wrote:
>> @@ -3631,6 +3631,11 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)
>>   		goto out_unlink_ns;
>>   
>>   	down_write(&ctrl->namespaces_rwsem);
>> +	/* preventing adding ns during resetting */
>> +	if (unlikely(ctrl->state != NVME_CTRL_LIVE)) {
> 
> We can't rely on ctrl->state for preventing deadlocks. Reading unlocked
> ctrl->state is often used, but should be considered advisory-only since
> the state could change immediatly after reading it.
> 
>> +		up_write(&ctrl->namespaces_rwsem);
>> +		goto out_unlink_ns;
>> +	}
>>   	nvme_ns_add_to_ctrl_list(ns);
>>   	up_write(&ctrl->namespaces_rwsem);
>>   	nvme_get_ctrl(ctrl);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ