Skip to content

RFC: luks/encrypted qcow2 key management

Maxim Levitsky qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest13 patches 73 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13block-crypto: misc refactoringblock/crypto.c+8 -76 replies
2/13qcrypto-luks: misc refactoringcrypto/block-luks.c+105 -10810 replies
3/13qcrypto-luks: refactoring: extract load/store/check/parse header functionscrypto/block-luks.c+440 -3168 replies
4/13qcrypto-luks: refactoring: simplify the math used for keyslot locationscrypto/block-luks.c+38 -262 replies
5/13qcrypto-luks: clear the masterkey and password before freeing them alwayscrypto/block-luks.c+44 -89 replies
6/13qcrypto-luks: implement more rigorous header checkingcrypto/block-luks.c+42 -06 replies
7/13block: add manage-encryption command (qmp and blockdev)block/block-backend.c block/io.c blockdev.c +5 more+165 -07 replies
8/13qcrypto: add the plumbing for encryption managementcrypto/block.c crypto/blockpriv.h include/crypto/block.h+65 -03 replies
9/13qcrypto-luks: implement the encryption key managementcrypto/block-luks.c+373 -12 replies
10/13block/crypto: implement the encryption key managementblock/crypto.c+93 -32 replies
11/13block/qcow2: implement the encryption key managmentblock/qcow2.c+27 -00 replies
12/13qemu-img: implement key managementblock/crypto.c block/crypto.h qemu-img-cmds.hx +1 more+172 -05 replies
13/13iotests : add tests for encryption key managementtests/qemu-iotests/257 tests/qemu-iotests/257.out tests/qemu-iotests/258 +5 more+628 -20 replies

Reviews trailers per patch

1 of 13 patches has a Reviewed-by or Acked-by.

PatchDaniel P. Berrangé
1/13R-b
2/13
3/13
4/13
5/13
6/13
7/13
8/13
9/13
10/13
11/13
12/13
13/13

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [Qemu-devel] [PATCH 00/13] RFC: luks/encrypted qcow2 key management

Hi!

This patch series implements key management for luks based encryption It supports both raw luks images and qcow2 encrypted images.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1731898

There are still several issues that need to be figured out,
on which the feedback is very welcome, but other than that the code mostly works.

The main issues are:

1. Instead of the proposed blockdev-update-encryption/blockdev-erase-encryption interface, it is probably better to implement 'blockdev-amend-options' in qmp, and use this both for offline and online key update (with some translation layer to convert the qemu-img 'options' to qmp structures)

This interface already exists for offline qcow2 format options update/

This is an issue that was raised today on IRC with Kevin Wolf. Really thanks for the idea!

We agreed that this new qmp interface should take the same options as blockdev-create does, however since we want to be able to edit the encryption slots separately, this implies that we sort of need to allow this on creation time as well.

Also the BlockdevCreateOptions is a union, which is specialized by the driver name which is great for creation, but for update, the driver name is already known, and thus the user should not be forced to pass it again.
However qmp doesn't seem to support union type guessing based on actual fields given (this might not be desired either), which complicates this somewhat.

2. 'crypto' driver (the raw luks block device/file) has special behavior for

share-rw=on. write sharing usually is only allowed for raw files, files that qemu doesn't itself touch, but only guest does. For such files a well behaved guests can share the storage.

On the other hand most of the format drivers need to store the metadata, and we don't have any format driver which implements some kind of sync vs other users of the same file, thus this is not allowed.

However since for luks which is technically a format driver, the metadata is readonly, such write sharing was allowed till now, and due to backward compatibility should still be allowed in the future.

This causes an issue with online updating of the keys, and the solution that was suggested by Keven that I implemented was to request the exclusive write access only during the key update.

Testing. This was lightly tested with manual testing and with few iotests that I prepared. I haven't yet tested fully the write sharing behavior, nor did I run the whole iotests suite to see if this code causes some regressions. Since I will need probably to rewrite some chunks of it to change to 'amend' interface, I decided to post it now, to see if you have other ideas/comments to add.

Best regards,
Maxim Levitsky

Maxim Levitsky (13):
block-crypto: misc refactoring
qcrypto-luks: misc refactoring
qcrypto-luks: refactoring: extract load/store/check/parse header
functions
qcrypto-luks: refactoring: simplify the math used for keyslot
locations
qcrypto-luks: clear the masterkey and password before freeing them
always
qcrypto-luks: implement more rigorous header checking
block: add manage-encryption command (qmp and blockdev)
qcrypto: add the plumbing for encryption management
qcrypto-luks: implement the encryption key management block/crypto: implement the encryption key management block/qcow2: implement the encryption key managment
qemu-img: implement key management
iotests : add tests for encryption key management

 block/block-backend.c            |    9 +
 block/crypto.c                   |  127 ++-
 block/crypto.h                   |    3 +
 block/io.c                       |   24 +
 block/qcow2.c                    |   27 +
 blockdev.c                       |   40 +
 crypto/block-luks.c              | 1673 ++++++++++++++++++++----------
 crypto/block.c                   |   29 +
 crypto/blockpriv.h               |    9 +
 include/block/block.h            |   12 +
 include/block/block_int.h        |   11 +
 include/crypto/block.h           |   27 +
 include/sysemu/block-backend.h   |    7 +
 qapi/block-core.json             |   36 +
 qapi/crypto.json                 |   26 +
 qemu-img-cmds.hx                 |   13 +
 qemu-img.c                       |  140 +++
 tests/qemu-iotests/257           |  197 ++++
 tests/qemu-iotests/257.out       |   96 ++
 tests/qemu-iotests/258           |   95 ++
 tests/qemu-iotests/258.out       |   30 +
 tests/qemu-iotests/259           |  199 ++++
 tests/qemu-iotests/259.out       |    5 +
 tests/qemu-iotests/common.filter |    5 +-
 tests/qemu-iotests/group         |    3 +
 25 files changed, 2286 insertions(+), 557 deletions(-)
 create mode 100755 tests/qemu-iotests/257
 create mode 100644 tests/qemu-iotests/257.out
 create mode 100755 tests/qemu-iotests/258
 create mode 100644 tests/qemu-iotests/258.out
 create mode 100644 tests/qemu-iotests/259
 create mode 100644 tests/qemu-iotests/259.out
Signature · 1 line
2.17.2