libvirtd cannot launch VMs with SGX enabled
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
libvirt (Ubuntu) |
Fix Released
|
High
|
Christian Ehrhardt | ||
Jammy |
Fix Released
|
Medium
|
Michał Małoszewski |
Bug Description
[Impact]
* Users of libvirt reported an issue on Jammy while launching a VM where the SGX is enabled.
* This crash is caused by the code that was using 'QOM_CPU_PATH' macro and was not accepting the QOM path as an argument and moreover, the code that is querying the CPU flags via 'qom-get' did not have a valid QOM path to the vCPU, plus the fact that 'qemuProcessGet
[Test Plan]
You need to have a machine that supports SGX.
lxc launch ubuntu:22.04 test1
lxc shell test1
Install libvirt, libguestfs-tools, virt-manager.
Modify /etc/libvirt/
cgroup_device_acl = [
"/dev/null", "/dev/full", "/dev/zero",
"/dev/random", "/dev/urandom",
"/dev/ptmx", "/dev/kvm",
"/dev/
"/dev/
]
user = "root"
security_driver = “none”
Start libvirtd:
$sudo systemctl start libvirtd
$ sudo mv CentOS-
$ sudo virt-customize -a /var/lib/
Edit cs8-vm-sgx.xml with the new qcow2 image name and launch the VM:
$ sudo virsh define cs8-vm-sgx1.xml
$ sudo virsh start cs8-vm-sgx1
Then open the running VM in virt-manager, log into CS8 VM and verify VM supports SGX.
Example of failed output:
The user is not able to launch a VM supporting SGX.
Example of successful output:
The user is able to launch a VM supporting SGX.
[Where problems could occur]
* The patch itself modifies mainly the monitor, domain and process files of qemu, so regressions should be limited to the behavior of managing qemu processes (start, stop, monitor) and affect functions and structures related to creating, managing and interacting with virtual machine domains using QEMU.
* Finally, since the patch modifies C code, issues typical of C code (segfaults, memory leaks, …) would be possible.
-------
$ lsb_release -rd
Description: Ubuntu 22.04 LTS
Release: 22.04
Package: libvirt-
Note that Ubuntu kernel and qemu-system-x86_64 support SGX.
However, when attempting to launch a VM with SGX enabled, the following error is reported:
libvirt.
This issue was fixed in libvirt 8.1. Please see the attached file for relevant patches.
Considering Ubuntu 22.04 is LTS distribution, please back port the libvirt 8.1 SGX functionality to liibvirt 8.0.0 (or upgrade the whole libvirt).
Being able to launch VMs with SGX support is a very important security feature.
=====
Steps to reproduce
1. Create a simple VM image:
$ sudo cp https:/
$ virt-customize -a /var/lib/
2. Launch the VM (cs8-vm-sgx.xml is attached):
$ sudo virsh define cs8-vm-sgx.xml
Domain 'cs8-vm-sgx' defined from cs8-vm-sgx.xml
$ sudo virsh start cs8-vm-sgx
Related branches
- git-ubuntu bot: Approve
- Lena Voytek (community): Approve
- Christian Ehrhardt : Pending requested
- Canonical Server Reporter: Pending requested
-
Diff: 800 lines (+739/-0)9 files modifieddebian/changelog (+16/-0)
debian/patches/backport/qemu-domain-store-qompath-in-qemudomainvcpuprivate.patch (+63/-0)
debian/patches/backport/qemu-monitor-do-not-hardcode-qom-path-of-first-cpu.patch (+422/-0)
debian/patches/backport/qemu-monitor-json-get-cpux86-data-unexport.patch (+43/-0)
debian/patches/backport/qemu-process-do-not-use-hardcoded-qom-path-for-cpu-for-probing-flags.patch (+58/-0)
debian/patches/backport/qemu-process-move-call-to-qemuprocessrefreshcpu-after-cpu-probe.patch (+36/-0)
debian/patches/backport/qemu-process-move-cpu-flag-querying-after-code-probing-cpus.patch (+44/-0)
debian/patches/backport/qemu-process-update-and-verify-cpu-refactor-cleanup.patch (+50/-0)
debian/patches/series (+7/-0)
CVE References
tags: | added: libvirt-22.10 |
Changed in libvirt (Ubuntu): | |
status: | Triaged → In Progress |
assignee: | nobody → Christian Ehrhardt (paelzer) |
tags: | added: server-todo |
Changed in libvirt (Ubuntu Jammy): | |
assignee: | nobody → Michał Małoszewski (michal-maloszewski99) |
description: | updated |
Hi,
thanks for the report Juro!
I'm working on libvirt 8.6 once it is released in a few more days.
Once that has entered Kinetic we can start working on an SRU for Jammy.
The list of identified patches is: eshCPU after cpu probe rivate teAndVerifyCPU: Refactor cleanup GetCPUx86Data: Unexport
a7743c6026 qemu: process: Don't use hardcoded QOM path for cpu for probing flags
068aaa9795 qemu: process: Move call to qemuProcessRefr
2f498b5980 qemu: process: Move cpu flag querying after code probing cpus
f0a4951616 qemu: domain: Store 'qomPath' in qemuDomainVcpuP
715846b6ea qemu: monitor: Don't hardcode QOM path of first CPU
476e864186 qemuProcessUpda
3ac3b3e8fb qemuMonitorJSON
There are no follow up fixes to those since then we need to consider.