NFS LUKSv1 volume creation from an image incorrectly reformats volume as plain LUKSv1 instead of an encrypted QCOW2 volume
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Cinder |
In Progress
|
High
|
Sofia Enriquez |
Bug Description
I've been playing around with LUKSv1 encrypted NFS volumes today after I was asked if Ia255a25da081e7
At present when creating an encrypted LUKSv1 NFS volume we create a LUKSv1 encrypted QCOW2 file:
Jul 23 09:48:19 localhost.
This is fine however when creating the volume from an image we then go on to attach the os-brick provided cryptsetup encryptors that attempt to open the device as if it were a plain LUKSv1 encrypted device:
Jul 23 09:48:21 localhost.
Jul 23 09:48:21 localhost.
As the file is actually QCOW2 this fails and the encryptors then reformat the file as a plain LUKSv1 file:
Jul 23 09:48:21 localhost.
[..]
Jul 23 09:48:25 localhost.
Jul 23 09:48:25 localhost.
At this point the volume is no longer QCOW2 as we've basically done the following:
# qemu-img create -f qcow2 -o encrypt.
Formatting 'test.img', fmt=qcow2 size=104857600 encrypt.format=luks encrypt.
# qemu-img info test.img
image: test.img
file format: qcow2
virtual size: 100 MiB (104857600 bytes)
disk size: 480 KiB
encrypted: yes
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
encrypt:
ivgen alg: plain64
hash alg: sha256
cipher alg: aes-256
uuid: d0363765-
format: luks
cipher mode: xts
slots:
[0]:
key offset: 4096
[1]:
key offset: 262144
[2]:
key offset: 520192
[3]:
key offset: 778240
[4]:
key offset: 1036288
[5]:
key offset: 1294336
[6]:
key offset: 1552384
[7]:
key offset: 1810432
payload offset: 2068480
master key iters: 474321
corrupt: false
# cryptsetup --batch-mode luksFormat --type luks1 --key-file=- --cipher aes-xts-plain64 --key-size 256 test.img
Enter passphrase for test.img:
# qemu-img info test.img
image: test.img
file format: luks
virtual size: 256 KiB (262144 bytes)
disk size: 2.03 MiB
encrypted: yes
Format specific information:
ivgen alg: plain64
hash alg: sha256
cipher alg: aes-128
uuid: d325d8e2-
cipher mode: xts
slots:
[0]:
active: true
iters: 4009850
key offset: 4096
[1]:
active: false
key offset: 135168
[2]:
active: false
key offset: 266240
[3]:
active: false
key offset: 397312
[4]:
active: false
key offset: 528384
[5]:
active: false
key offset: 659456
[6]:
active: false
key offset: 790528
[7]:
active: false
key offset: 921600
payload offset: 2097152
master key iters: 250137
Note that the file now reports a format of RAW and an incorrect virtual size. This breaks volume attachment to running instances *and* volume creation from images, both of which appear untested in Tempest at the moment for LUKSv1 volumes.
tags: | added: nfs |
Changed in cinder: | |
status: | New → Confirmed |
Changed in cinder: | |
importance: | Undecided → Medium |
Changed in cinder: | |
importance: | Medium → High |
tags: | added: drivers encryption generic-nfs |
FWIW we don't need to attach the encryptors for QCOW2 LUKSv1 files, QEMU should be able to convert the provided image into QCOW2 LUKSv1 given the correct secrets etc. I'll work up a change now.