From: Jethro Beekman <kernel@jbeekman.nl>
To: Keith Busch <keith.busch@intel.com>
Cc: axboe@fb.com, linux-nvme@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/3] nvme: Don't add namespaces for locked drives
Date: Mon, 20 Jun 2016 11:21:09 -0700 [thread overview]
Message-ID: <57683415.1060202@jbeekman.nl> (raw)
In-Reply-To: <20160620152639.GD12936@localhost.localdomain>
On 20-06-16 08:26, Keith Busch wrote:
> On Sun, Jun 19, 2016 at 04:06:31PM -0700, Jethro Beekman wrote:
>> If an NVMe drive is locked with ATA Security, most commands sent to the drive
>> will fail. This includes commands sent by the kernel upon discovery to probe
>> for partitions. The failing happens in such a way that trying to do anything
>> with the drive (e.g. sending an unlock command; unloading the nvme module) is
>> basically impossible with the high default command timeout.
>
> Why is the timeout a factor here? Is it because the error your drive
> returns does not have DNR set and goes through 30 seconds of retries?
I looked into this but couldn't figure out where DNR's were being handled. Upon
closer inspection, I suppose I could add some debug code in nvme_complete_rq.
> If so, I think we should probably have a limited retry count instead of
> unlimited retries within the command timeout.
Would this just be a matter of setting req->retries and checking for it in
nvme_req_needs_retry? How does one keep track of the number of tries so far?
>> This patch adds a check to see if the drive is locked, and if it is, its
>> namespaces are not initialized. It is expected that userspace will send the
>> proper "security send/unlock" command and then reset the controller. Userspace
>> tools are available at [1].
>
> Aren't these security settings per-namespace rather than the entire device?
You're right, I assumed that admin commands can't have namespace ids, but
looking at the spec, that's not the case. Turns out there's a problem with the
driver then: nvme_ioctl never includes the ns for NVME_IOCTL_ADMIN_CMD. I'll fix
this and the above suggestion. Hopefully that also obviates the need for the
nvme_scan_namespaces code path, otherwise we'll have to rethink how to do this.
>> I intend to also submit a future patch that tracks ATA Security commands sent
>> from userspace and remembers the password so it can be submitted to a locked
>> drive upon pm_resume. (still WIP)
>
> This subjects the system to various attacks like cold boot or hotswap,
> but that's what users want!
Yes. Unfortunately I couldn't think of a sane way to have userspace prompt for
the password on resume with a non-functional drive. Current BIOS implementations
generally also just unlock this way. I do intend to use the keyring API.
The effects of a hotswap can be partially mitigated by "salting" the password
with the drive serial number [1]. For maximum effect the kernel would check to
see if the drive SN has changed before resending the password, I'm not sure if
we want this extra complexity in the kernel though.
[1] https://jbeekman.nl/blog/2015/03/lenovo-thinkpad-hdd-password/
> This is ATA security, though, so wouldn't ATA also benefit from this? The
> payload setup/decoding should then go in a generic library for everyone.
>
> Similar was said about the patch adding OPAL security to the NVMe driver:
>
> http://lists.infradead.org/pipermail/linux-nvme/2016-April/004428.html
Yes this would benefit from being generic. I actually looked whether this
already existed in the kernel and was surprised that it didn't. I suppose most
people using this functionality depend on their BIOS to handle everything. I
will contact Rafael to see we can come up with some generic drive security state
tracker.
Jethro
next prev parent reply other threads:[~2016-06-20 19:06 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-19 23:06 [PATCH 0/3] nvme: Don't add namespaces for locked drives Jethro Beekman
2016-06-19 23:06 ` [PATCH 1/3] nvme: When scanning namespaces, make sure the drive is not locked Jethro Beekman
2016-06-24 8:12 ` Christoph Hellwig
2016-06-19 23:06 ` [PATCH 2/3] nvme: Add function for NVMe security receive command Jethro Beekman
2016-06-19 23:06 ` [PATCH 3/3] nvme: Check if drive is locked using ATA Security Jethro Beekman
2016-06-24 8:09 ` Christoph Hellwig
2016-06-20 6:46 ` [PATCH 0/3] nvme: Don't add namespaces for locked drives Sagi Grimberg
2016-06-24 8:09 ` Christoph Hellwig
2016-06-20 15:26 ` Keith Busch
2016-06-20 18:21 ` Jethro Beekman [this message]
2016-06-20 22:54 ` Keith Busch
2016-06-21 3:50 ` Jethro Beekman
2016-06-24 7:43 ` Christoph Hellwig
2016-06-24 8:11 ` Christoph Hellwig
2016-06-24 7:37 ` Christoph Hellwig
2016-06-24 7:45 ` Jethro Beekman
2016-06-24 8:00 ` Christoph Hellwig
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=57683415.1060202@jbeekman.nl \
--to=kernel@jbeekman.nl \
--cc=axboe@fb.com \
--cc=keith.busch@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
/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