qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: API definition for LUKS key management


From: Maxim Levitsky
Subject: Re: API definition for LUKS key management
Date: Thu, 14 Nov 2019 12:54:16 +0200

On Tue, 2019-11-12 at 11:02 +0000, Daniel P. Berrangé wrote:
> On Tue, Nov 12, 2019 at 10:12:45AM +0100, Kevin Wolf wrote:
> > Am 11.11.2019 um 19:34 hat Daniel P. Berrangé geschrieben:
> > > On Mon, Nov 11, 2019 at 05:58:20PM +0200, Maxim Levitsky wrote:
> > > > One of the concerns that was raised during the review was that amend 
> > > > interface for luks that I propose is
> > > > different from the amend inteface used currently for qcow2.
> > > > 
> > > > qcow2 amend interface specifies all the format options, thus overwrites 
> > > > the existing options.
> > > > Thus it seems natural to make the luks amend interface work the same 
> > > > way, that it receive an array
> > > > of 8 slots, and for each slot specify if it is active, and if true what 
> > > > password to put in it.
> > > > This does allow to add and erase the keyslots, but it doesn't allow:
> > > > 
> > > >    * add a password without knowing all other passwords that exist in 
> > > > existing keyslots
> > > >      this can be mitigated by specifying which keyslots to modify for 
> > > > example by omitting the
> > > >      keyslots that shouldn't be touched from the array (passing null 
> > > > placeholder instead)
> > > >      but then it already doesn't follow the 'specify all the options 
> > > > each time' principle.
> > > 
> > > I think this is highly undesirable, as we must not assume that the
> > > mgmt app has access to all the passwords currently set.
> > 
> > And I think this shows the problem that we realy have with the crypto
> > driver and amend: For every other driver, if you must, you can query the
> > current settings and just write them back.
> > 
> > The difference here is that crypto doesn't allow to directly query or
> > specify the content of some options (the keyslots), but provides only a
> > way to derives that content from a secret, and obviously there is no way
> > back from the stored data to the secret (that's what it's for).
> > 
> > I think we have two options here:
> > 
> > 1. Add a special "don't touch this" value for keyslots. Normally, just
> >    leaving out the value would be suitable syntax for this. Here,
> >    however, we have a list of keyslots, so we can't leave anything out.
> > 
> >    We could use something like an alternate between str (new secret ID),
> >    null (erase keyslot) and empty dict (leave it alone) - the latter
> >    feels a bit hackish, but maybe it's not too bad. If the list is
> >    shorter than 8 entries, the rest is assumed to mean "leave it alone",
> >    too.
> 
> I'd be very wary of having a "null" vs "empty dict" distinction to
> mean "erase" vs "don't touch".
> 
> It feels like that is designed to maximise the chances of someone
> shooting themselves in the foot by accidentally using "null" instead
> of an "empty dict".
> 
> The reason for the use of "active=yes" / "active=no" is because that
> was reasonable explicit about wanting to erase a keyslot, and it does
> does actually map to the key slot on disk which has an "active" field
> taking two magic values.
> 
> > 2. Allow to query and set the raw key, which doesn't require a password
> 
> I don't think I understand what you mean here. If you don't have a
> password the only change you can make is to erase key slots.
Well in the theory the keyslot has the hash of the password, the salt, the hash 
function
iteration count and the active field. 

In theory you can let the user read these values directly and write them back 
as is without knowing the password.
This is very ugly IMHO but will fit the classical amend definition.


> 
> > > >    * erase all keyslots matching a password - this is really hard to do 
> > > > using this approach,
> > > >      unless we give user some kind of api to try each keyslot with 
> > > > given password,
> > > >      which is kind of ugly and might be racy as well.
> > > > So what do you think?
> > > 
> > > The point of using "amend" is that we already have some of the boilerplate
> > > supporting framework around that, so it saves effort for both QEMU and
> > > our users. If the semantics of "amend" don't fit nicely though, then the
> > > benefit of re-using "amend" is cancelled out and we should go back to
> > > considering a separate "key-manage" command.
> > 
> > This wouldn't solve the fundamental problem that the crypto block
> > driver, as it currently is, isn't able to provide a blockdev-amend
> > callback. It's worse for qcow2 because qcow2 already implements amend.
> > 
> > I think we need to find a solution for the amend API.
I also think so. Amend interface can be *ahem* amended to be more generic :-)
Currently it is designed for just one use case.

> 
> 
> BTW, looking forward to the future, if we ever implement LUKS version 2
> support there are a bunch more things can be tweaked at runtime. Most
> notable is that it is possible to change the master key, and change the
> encryption algorithm choices. Both of these then need to trigger a bulk
> re-encrypt of the entire disk contents, which takes a long time.
This is good to know, and would mean that I was right to make blockdev-amend
a block job.

This also means that when user wants to tweak some setting, he might not
want to pass all the keyslots again.

BTW, I guess that to change the master key, user ought to know all passwords,
since each keyslot is basically an encrypted master key. I didn't read the LUKS 
v2
spec though.


> 
> I doubt we'll do this in the near term, but we should consider how this
> might fit into whatever scheme we pick for updates.
We might have to since LUKS v2 becomes default in more and more distros,
so users will eventually expect it be used by us as well.


Best regards,
        Maxim Levitsky




reply via email to

[Prev in Thread] Current Thread [Next in Thread]