]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: domain: Forbid storage with old QCOW2 encryption
authorPeter Krempa <pkrempa@redhat.com>
Tue, 22 May 2018 12:53:06 +0000 (14:53 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 5 Jun 2018 06:14:00 +0000 (08:14 +0200)
The encryption was buggy and qemu actually dropped it upstream. Forbid
it for all versions since it would cause other problems too.

Problems with the old encryption include weak crypto, corruption of
images with blockjobs and a lot of usability problems.

This requires changing of the encryption type for the encrypted disk
tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
docs/formatdomain.html.in
docs/formatstorageencryption.html.in
src/qemu/qemu_domain.c
tests/qemuxml2argvdata/encrypted-disk-usage.args
tests/qemuxml2argvdata/encrypted-disk-usage.xml
tests/qemuxml2argvdata/encrypted-disk.args
tests/qemuxml2argvdata/encrypted-disk.xml
tests/qemuxml2argvtest.c
tests/qemuxml2xmloutdata/encrypted-disk.xml
tests/qemuxml2xmltest.c

index 22ef81052d6b333aa4e20a65e6f2057f532a7bcc..713d7aa88a21b7c42d8cd5b8c4b6ab25a145afbd 100644 (file)
             See the
             <a href="formatstorageencryption.html">Storage Encryption</a>
             page for more information.
+            <p/>
+            Note that the 'qcow' format of encryption is broken and thus is no
+            longer supported for use with disk images.
+            (<span class="since">Since libvirt 4.5.0</span>)
           </dd>
           <dt><code>reservations</code></dt>
           <dd><span class="since">Since libvirt 4.4.0</span>, the
index 23efbf932e6568424e78d3027d85a87bee75834f..434bdb609ebeb2d7e2ca9e8d0effe76dd0d22bca 100644 (file)
@@ -53,9 +53,8 @@
       The <code>qcow</code> format specifies that the built-in encryption
       support in <code>qcow</code>- or <code>qcow2</code>-formatted volume
       images should be used.  A single
-      <code>&lt;secret type='passphrase'&gt;</code> element is expected.  If
-      the <code>secret</code> element is not present during volume creation,
-      a secret is automatically generated and attached to the volume.
+      <code>&lt;secret type='passphrase'&gt;</code> element is expected.  Note
+      that this encryption is inherently broken and should not be used any more.
     </p>
     <h3><a id="StorageEncryptionLuks">"luks" format</a></h3>
     <p>
index 2792fa7569a6228f4772d9322ecd3afd200666fd..96793a504663eb93b744ed00fea7d73a9487ed75 100644 (file)
@@ -4483,6 +4483,16 @@ qemuDomainValidateStorageSource(virStorageSourcePtr src,
         return -1;
     }
 
+    if ((src->format == VIR_STORAGE_FILE_QCOW ||
+         src->format == VIR_STORAGE_FILE_QCOW2) &&
+        src->encryption &&
+        (src->encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT ||
+         src->encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_QCOW)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("old qcow/qcow2 encryption is not supported"));
+            return -1;
+    }
+
     if (src->format == VIR_STORAGE_FILE_QCOW2 &&
         src->encryption &&
         src->encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS &&
index 8c7ce3d6530a481ab46dd8ebc058f4da52f373e9..32307cea713a86515de0ad2af49e894d727da17e 100644 (file)
@@ -7,6 +7,8 @@ QEMU_AUDIO_DRV=none \
 /usr/bin/qemu-system-i686 \
 -name encryptdisk \
 -S \
+-object secret,id=masterKey0,format=raw,\
+file=/tmp/lib/domain--1-encryptdisk/master-key.aes \
 -machine pc,accel=tcg,usb=off,dump-guest-core=off \
 -m 1024 \
 -smp 1,sockets=1,cores=1,threads=1 \
@@ -22,7 +24,11 @@ path=/tmp/lib/domain--1-encryptdisk/monitor.sock,server,nowait \
 -no-acpi \
 -boot c \
 -usb \
--drive file=/storage/guest_disks/encryptdisk,format=qcow2,if=none,\
+-object secret,id=virtio-disk0-luks-secret0,\
+data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\
+keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
+-drive file=/storage/guest_disks/encryptdisk,encrypt.format=luks,\
+encrypt.key-secret=virtio-disk0-luks-secret0,format=qcow2,if=none,\
 id=drive-virtio-disk0 \
 -device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,\
 id=virtio-disk0 \
index ad8f17e3dfaa2c5dd541a76e8fc312f7c6d0b32e..205283b59d458448f50a3fd667d15121c0d324ae 100644 (file)
@@ -18,7 +18,7 @@
       <driver name='qemu' type='qcow2'/>
       <source file='/storage/guest_disks/encryptdisk'/>
       <target dev='vda' bus='virtio'/>
-      <encryption format='qcow'>
+      <encryption format='luks'>
         <secret type='passphrase' usage='/storage/guest_disks/encryptdisk'/>
       </encryption>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
index 8c7ce3d6530a481ab46dd8ebc058f4da52f373e9..32307cea713a86515de0ad2af49e894d727da17e 100644 (file)
@@ -7,6 +7,8 @@ QEMU_AUDIO_DRV=none \
 /usr/bin/qemu-system-i686 \
 -name encryptdisk \
 -S \
+-object secret,id=masterKey0,format=raw,\
+file=/tmp/lib/domain--1-encryptdisk/master-key.aes \
 -machine pc,accel=tcg,usb=off,dump-guest-core=off \
 -m 1024 \
 -smp 1,sockets=1,cores=1,threads=1 \
@@ -22,7 +24,11 @@ path=/tmp/lib/domain--1-encryptdisk/monitor.sock,server,nowait \
 -no-acpi \
 -boot c \
 -usb \
--drive file=/storage/guest_disks/encryptdisk,format=qcow2,if=none,\
+-object secret,id=virtio-disk0-luks-secret0,\
+data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\
+keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
+-drive file=/storage/guest_disks/encryptdisk,encrypt.format=luks,\
+encrypt.key-secret=virtio-disk0-luks-secret0,format=qcow2,if=none,\
 id=drive-virtio-disk0 \
 -device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,\
 id=virtio-disk0 \
index 391461b2000865842034942a0d832841275af57c..275724bdafc962beb546ef07f850c212bf3a0fb4 100644 (file)
@@ -18,7 +18,7 @@
       <driver name='qemu' type='qcow2'/>
       <source file='/storage/guest_disks/encryptdisk'/>
       <target dev='vda' bus='virtio'/>
-      <encryption format='qcow'>
+      <encryption format='luks'>
         <secret type='passphrase' uuid='0a81f5b2-8403-7b23-c8d6-21ccc2f80d6f'/>
       </encryption>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
index 2d41f78f8bca404e7a5d2f27ba4e5ebf7057e1d4..64d112be364eec367ceba4999ec375301483162b 100644 (file)
@@ -1651,8 +1651,8 @@ mymain(void)
     DO_TEST("cpu-tsc-frequency", QEMU_CAPS_KVM);
     qemuTestSetHostCPU(driver.caps, NULL);
 
-    DO_TEST("encrypted-disk", NONE);
-    DO_TEST("encrypted-disk-usage", NONE);
+    DO_TEST("encrypted-disk", QEMU_CAPS_QCOW2_LUKS, QEMU_CAPS_OBJECT_SECRET);
+    DO_TEST("encrypted-disk-usage", QEMU_CAPS_QCOW2_LUKS, QEMU_CAPS_OBJECT_SECRET);
 # ifdef WITH_GNUTLS
     DO_TEST("luks-disks", QEMU_CAPS_OBJECT_SECRET);
     DO_TEST("luks-disks-source", QEMU_CAPS_OBJECT_SECRET);
index 45b9fcca55398e9891ae2ae949b6910b7cf03a40..3c9d2fbafc57169afeabc1ced54656d1b56f36d0 100644 (file)
@@ -18,7 +18,7 @@
       <driver name='qemu' type='qcow2'/>
       <source file='/storage/guest_disks/encryptdisk'/>
       <target dev='vda' bus='virtio'/>
-      <encryption format='qcow'>
+      <encryption format='luks'>
         <secret type='passphrase' uuid='0a81f5b2-8403-7b23-c8d6-21ccc2f80d6f'/>
       </encryption>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
index 66b823890684b9a0081a80216b7846ff8e4a7fa8..56b666256f5e8d9ad02a03e773f3a26d30f710c7 100644 (file)
@@ -482,8 +482,8 @@ mymain(void)
     DO_TEST("pci-rom-disabled-invalid", NONE);
     DO_TEST("pci-serial-dev-chardev", NONE);
 
-    DO_TEST("encrypted-disk", NONE);
-    DO_TEST("encrypted-disk-usage", NONE);
+    DO_TEST("encrypted-disk", QEMU_CAPS_QCOW2_LUKS);
+    DO_TEST("encrypted-disk-usage", QEMU_CAPS_QCOW2_LUKS);
     DO_TEST("luks-disks", NONE);
     DO_TEST("luks-disks-source", NONE);
     DO_TEST("memtune", NONE);