qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Maxim Levitsky <mlevitsk@redhat.com>
To: "Max Reitz" <mreitz@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-block@nongnu.org, John Snow <jsnow@redhat.com>,
	qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Subject: Re: [PATCH v6 07/14] block/crypto: implement the encryption key management
Date: Sun, 17 May 2020 20:56:49 +0300	[thread overview]
Message-ID: <26b95a4e2617435c15d14d5ad09777ce46d3ef28.camel@redhat.com> (raw)
In-Reply-To: <b54a5cdc-f649-acba-4821-2c3f357c6d94@redhat.com>

On Thu, 2020-05-14 at 16:32 +0200, Max Reitz wrote:
> On 14.05.20 16:14, Daniel P. Berrangé wrote:
> > On Thu, May 14, 2020 at 04:09:59PM +0200, Max Reitz wrote:
> > > On 10.05.20 15:40, Maxim Levitsky wrote:
> > > > This implements the encryption key management using the generic code in
> > > > qcrypto layer and exposes it to the user via qemu-img
> > > > 
> > > > This code adds another 'write_func' because the initialization
> > > > write_func works directly on the underlying file, and amend
> > > > works on instance of luks device.
> > > > 
> > > > This commit also adds a 'hack/workaround' I and Kevin Wolf (thanks)
> > > > made to make the driver both support write sharing (to avoid breaking the users),
> > > > and be safe against concurrent  metadata update (the keyslots)
> > > > 
> > > > Eventually the write sharing for luks driver will be deprecated
> > > > and removed together with this hack.
> > > > 
> > > > The hack is that we ask (as a format driver) for BLK_PERM_CONSISTENT_READ
> > > > and then when we want to update the keys, we unshare that permission.
> > > > So if someone else has the image open, even readonly, encryption
> > > > key update will fail gracefully.
> > > > 
> > > > Also thanks to Daniel Berrange for the idea of
> > > > unsharing read, rather that write permission which allows
> > > > to avoid cases when the other user had opened the image read-only.
> > > > 
> > > > Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> > > > Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> > > > ---
> > > >  block/crypto.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++--
> > > >  block/crypto.h |  34 +++++++++++++
> > > >  2 files changed, 158 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/block/crypto.c b/block/crypto.c
> > > > index 2e16b62bdc..b14cb0ff06 100644
> > > > --- a/block/crypto.c
> > > > +++ b/block/crypto.c
> > > 
> > > [...]
> > > 
> > > > +static void
> > > > +block_crypto_child_perms(BlockDriverState *bs, BdrvChild *c,
> > > > +                         const BdrvChildRole *role,
> > > > +                         BlockReopenQueue *reopen_queue,
> > > > +                         uint64_t perm, uint64_t shared,
> > > > +                         uint64_t *nperm, uint64_t *nshared)
> > > > +{
> > > > +
> > > > +    BlockCrypto *crypto = bs->opaque;
> > > > +
> > > > +    bdrv_filter_default_perms(bs, c, role, reopen_queue,
> > > > +            perm, shared, nperm, nshared);
> > > > +    /*
> > > > +     * Ask for consistent read permission so that if
> > > > +     * someone else tries to open this image with this permission
> > > > +     * neither will be able to edit encryption keys, since
> > > > +     * we will unshare that permission while trying to
> > > > +     * update the encryption keys
> > > > +     */
> > > > +    if (!(bs->open_flags & BDRV_O_NO_IO)) {
> > > > +        *nperm |= BLK_PERM_CONSISTENT_READ;
> > > > +    }
> > > 
> > > I’m not sure this is important, because this really means we won’t do
> > > I/O.  Its only relevant use in this case is for qemu-img info.  Do we
> > > really care if someone edits the key slots while qemu-img info is
> > > processing?
> > 
> > FWIW, OpenStack runs  qemu-img info in a periodic background job, so
> > it can be concurrent with anything else they are running.
> 
> That might actually be a problem then, because this may cause sporadic
> failure when trying to change (amend) keyslots; while qemu-img info
> holds the CONSISTENT_READ permission, the amend process can’t unshare
> it.  That might lead to hard-to-track-down bugs.
> 
> > Having said
> > that due to previous QEMU bugs, they unconditonally pass the arg to
> > qemu-img to explicitly disable locking
> 
> Well, then it doesn’t matter in this case.  But still something to
> consider, probably.
> 
> Max
> 
So I understand correctly that I should leave the patch as is?

Thanks for the review!

Best regards,
	Maxim Levitsky



  reply	other threads:[~2020-05-17 17:58 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-10 13:40 [PATCH v6 00/14] LUKS: encryption slot management using amend interface Maxim Levitsky
2020-05-10 13:40 ` [PATCH v6 01/14] qcrypto/core: add generic infrastructure for crypto options amendment Maxim Levitsky
2020-05-10 13:40 ` [PATCH v6 02/14] qcrypto/luks: implement encryption key management Maxim Levitsky
2020-05-14 11:56   ` Max Reitz
2020-05-17  8:13     ` Maxim Levitsky
2020-05-10 13:40 ` [PATCH v6 03/14] block/amend: add 'force' option Maxim Levitsky
2020-05-14 12:18   ` Max Reitz
2020-05-17  8:15     ` Maxim Levitsky
2020-05-10 13:40 ` [PATCH v6 04/14] block/amend: separate amend and create options for qemu-img Maxim Levitsky
2020-05-14 12:28   ` Max Reitz
2020-05-14 16:10     ` Eric Blake
2020-05-15  6:22       ` Max Reitz
2020-05-15 17:24         ` Eric Blake
2020-05-17  8:47           ` Maxim Levitsky
2020-05-17  8:54     ` Maxim Levitsky
2020-05-10 13:40 ` [PATCH v6 05/14] block/amend: refactor qcow2 amend options Maxim Levitsky
2020-05-14 13:36   ` Max Reitz
2020-05-17 17:52     ` Maxim Levitsky
2020-05-10 13:40 ` [PATCH v6 06/14] block/crypto: rename two functions Maxim Levitsky
2020-05-10 13:40 ` [PATCH v6 07/14] block/crypto: implement the encryption key management Maxim Levitsky
2020-05-14 14:09   ` Max Reitz
2020-05-14 14:14     ` Daniel P. Berrangé
2020-05-14 14:32       ` Max Reitz
2020-05-17 17:56         ` Maxim Levitsky [this message]
2020-05-10 13:40 ` [PATCH v6 08/14] block/qcow2: extend qemu-img amend interface with crypto options Maxim Levitsky
2020-05-14 14:30   ` Max Reitz
2020-05-17 18:03     ` Maxim Levitsky
2020-05-10 13:40 ` [PATCH v6 09/14] iotests: filter few more luks specific create options Maxim Levitsky
2020-05-14 14:49   ` Max Reitz
2020-05-17 18:50     ` Maxim Levitsky
2020-05-10 13:40 ` [PATCH v6 10/14] iotests: qemu-img tests for luks key management Maxim Levitsky
2020-05-10 13:40 ` [PATCH v6 11/14] block/core: add generic infrastructure for x-blockdev-amend qmp command Maxim Levitsky
2020-05-14 15:47   ` Max Reitz
2020-05-18 10:48     ` Maxim Levitsky
2020-05-10 13:40 ` [PATCH v6 12/14] block/crypto: implement blockdev-amend Maxim Levitsky
2020-05-14 16:05   ` Max Reitz
2020-05-10 13:40 ` [PATCH v6 13/14] block/qcow2: " Maxim Levitsky
2020-05-14 16:05   ` Max Reitz
2020-05-10 13:40 ` [PATCH v6 14/14] iotests: add tests for blockdev-amend Maxim Levitsky
2020-05-10 14:37 ` [PATCH v6 00/14] LUKS: encryption slot management using amend interface no-reply
2020-05-10 15:14 ` no-reply

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=26b95a4e2617435c15d14d5ad09777ce46d3ef28.camel@redhat.com \
    --to=mlevitsk@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).