All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/5] qcow2/qcow: protect against uninitialized encryption key
Date: Tue, 12 May 2015 12:06:17 -0600	[thread overview]
Message-ID: <55524119.4040903@redhat.com> (raw)
In-Reply-To: <1431446962-9860-2-git-send-email-berrange@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1785 bytes --]

On 05/12/2015 10:09 AM, Daniel P. Berrange wrote:
> When a qcow[2] file is opened, if the header reports an
> encryption method, this is used to set the 'crypt_method_header'
> field on the BDRVQcow[2]State struct, and the 'encrypted' flag
> in the BDRVState struct.
> 
> When doing I/O operations, the 'crypt_method' field on the
> BDRVQcow[2]State struct is checked to determine if encryption
> needs to be applied.
> 
> The crypt_method_header value is copied into crypt_method when
> the bdrv_set_key() method is called.
> 
> The QEMU code which opens a block device is expected to always
> do a check
> 
>    if (bdrv_is_encrypted(bs)) {
>        bdrv_set_key(bs, ....key...);
>    }
> 
> If code forgets todo this, then 'crypt_method' is never set

s/todo/to do/

> and so when I/O is performed, QEMU writes plain text data
> into a sector which is expected to contain cipher text, or
> when reading, will return cipher text instead of plain
> text.
> 
> Change the qcow[2] code to consult bs->encrypted when deciding
> whether encryption is required, and assert(s->crypt_method)
> to protect against cases where the caller forgets to set the
> encryption key.
> 
> Also put an assert in the set_key methods to protect against
> the case where the caller sets an encryption key on a block
> device that does not have encryption
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  block/qcow.c          | 10 +++++++---
>  block/qcow2-cluster.c |  3 ++-
>  block/qcow2.c         | 18 ++++++++++++------
>  3 files changed, 21 insertions(+), 10 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2015-05-12 18:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-12 16:09 [Qemu-devel] [PATCH 0/5] Misc fixes and testing of qcow[2] encryption Daniel P. Berrange
2015-05-12 16:09 ` [Qemu-devel] [PATCH 1/5] qcow2/qcow: protect against uninitialized encryption key Daniel P. Berrange
2015-05-12 18:06   ` Eric Blake [this message]
2015-05-12 16:09 ` [Qemu-devel] [PATCH 2/5] util: move read_password method out of qemu-img into osdep/oslib Daniel P. Berrange
2015-05-12 18:22   ` Eric Blake
2015-05-12 16:09 ` [Qemu-devel] [PATCH 3/5] util: allow \n to terminate password input Daniel P. Berrange
2015-05-12 18:23   ` Eric Blake
2015-05-12 16:09 ` [Qemu-devel] [PATCH 4/5] qemu-io: prompt for encryption keys when required Daniel P. Berrange
2015-05-12 18:32   ` Eric Blake
2015-05-13  8:09     ` Daniel P. Berrange
2015-05-13 10:50       ` Markus Armbruster
2015-05-12 16:09 ` [Qemu-devel] [PATCH 5/5] tests: add test case for encrypted qcow2 read/write Daniel P. Berrange
2015-05-12 18:35   ` Eric Blake
2015-05-12 19:06     ` [Qemu-devel] [Qemu-block] " John Snow
2015-05-12 19:52       ` Eric Blake
2015-05-12 19:54         ` John Snow
2015-05-18 15:38 ` [Qemu-devel] [PATCH 0/5] Misc fixes and testing of qcow[2] encryption Kevin Wolf

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=55524119.4040903@redhat.com \
    --to=eblake@redhat.com \
    --cc=berrange@redhat.com \
    --cc=kwolf@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.