From: "Matias Bjørling" <mb@lightnvm.io>
To: "Javier González" <jg@lightnvm.io>, "Rakesh Pandit" <rakesh@tuxera.com>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH V2] lightnvm: protect target type list with correct locks
Date: Thu, 21 Sep 2017 13:14:03 +0200 [thread overview]
Message-ID: <dbbfb813-714b-c0cf-9ecd-454ccbee24ad@lightnvm.io> (raw)
In-Reply-To: <3891AF6A-D87D-4727-BF9C-E6689C232BC9@lightnvm.io>
On 09/18/2017 09:53 AM, Javier González wrote:
>> On 16 Sep 2017, at 20.39, Rakesh Pandit <rakesh@tuxera.com> wrote:
>>
>> nvm_tgt_types list was protected by wrong lock for NVM_INFO ioctl call
>> and can race with addition or removal of target types. Also
>> unregistering target type was not protected correctly.
>>
>> Fixes: 5cd907853 ("lightnvm: remove nested lock conflict with mm")
>> Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
>> ---
>>
>> V2: also add correct lock while unregistering and fix "Fixes" tag at
>> end. Note I found these while investigating another issue and
>> skimming the core code but worth fixing.
>>
>> drivers/lightnvm/core.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
>> index 9f9a137..1b8338d 100644
>> --- a/drivers/lightnvm/core.c
>> +++ b/drivers/lightnvm/core.c
>> @@ -589,9 +589,9 @@ void nvm_unregister_tgt_type(struct nvm_tgt_type *tt)
>> if (!tt)
>> return;
>>
>> - down_write(&nvm_lock);
>> + down_write(&nvm_tgtt_lock);
>> list_del(&tt->list);
>> - up_write(&nvm_lock);
>> + up_write(&nvm_tgtt_lock);
>> }
>> EXPORT_SYMBOL(nvm_unregister_tgt_type);
>>
>> @@ -1190,7 +1190,7 @@ static long nvm_ioctl_info(struct file *file, void __user *arg)
>> info->version[1] = NVM_VERSION_MINOR;
>> info->version[2] = NVM_VERSION_PATCH;
>>
>> - down_write(&nvm_lock);
>> + down_write(&nvm_tgtt_lock);
>> list_for_each_entry(tt, &nvm_tgt_types, list) {
>> struct nvm_ioctl_info_tgt *tgt = &info->tgts[tgt_iter];
>>
>> @@ -1203,7 +1203,7 @@ static long nvm_ioctl_info(struct file *file, void __user *arg)
>> }
>>
>> info->tgtsize = tgt_iter;
>> - up_write(&nvm_lock);
>> + up_write(&nvm_tgtt_lock);
>>
>> if (copy_to_user(arg, info, sizeof(struct nvm_ioctl_info))) {
>> kfree(info);
>> --
>> 2.7.4
>
> LGTM.
>
> Reviewed-by: Javier González <javier@cnexlabs.com>
>
Thanks Rakesh.
prev parent reply other threads:[~2017-09-21 11:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-16 18:39 [PATCH V2] lightnvm: protect target type list with correct locks Rakesh Pandit
2017-09-18 7:53 ` Javier González
2017-09-21 11:14 ` Matias Bjørling [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=dbbfb813-714b-c0cf-9ecd-454ccbee24ad@lightnvm.io \
--to=mb@lightnvm.io \
--cc=jg@lightnvm.io \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rakesh@tuxera.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