qemu_firmware: Enable loader.secure when requires-smm

Currently, a firmware configuration such as

  <os firmware='efi'>
    <firmware>
      <feature enabled='yes' name='enrolled-keys'/>
    </firmware>
  </os>

will correctly pick a firmware that implements the Secure Boot
feature and initialize the NVRAM file so that it contains the
keys necessary to enforce the signing requirements. However, the
lack of a

  <loader secure='yes'/>

element makes it possible for pflash writes to happen outside
of SMM mode. This means that the authenticated UEFI variables
where the keys are stored could potentially be overwritten by
malicious code running in the guest, thus making it possible to
circumvent Secure Boot.

To prevent that from happening, automatically turn on the
loader.secure feature whenever a firmware that implements Secure
Boot is chosen by the firmware autoselection logic. This is
identical to the way we already automatically enable SMM in such
a scenario.

Note that, while this is technically a guest-visible change, it
will not affect migration of existings VMs and will not prevent
legitimate guest code from running.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Andrea Bolognani 2022-06-09 17:59:33 +02:00
parent 73c5ae55c7
commit 262672dbbf
5 changed files with 6 additions and 0 deletions

View File

@ -1240,6 +1240,8 @@ qemuFirmwareEnableFeatures(virQEMUDriver *driver,
case VIR_TRISTATE_SWITCH_LAST: case VIR_TRISTATE_SWITCH_LAST:
break; break;
} }
VIR_DEBUG("Enabling secure loader");
def->os.loader->secure = VIR_TRISTATE_BOOL_YES;
break; break;
case QEMU_FIRMWARE_FEATURE_NONE: case QEMU_FIRMWARE_FEATURE_NONE:

View File

@ -17,6 +17,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-fedora/.config \
-machine pc-q35-4.0,usb=off,smm=on,dump-guest-core=off,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format,memory-backend=pc.ram \ -machine pc-q35-4.0,usb=off,smm=on,dump-guest-core=off,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format,memory-backend=pc.ram \
-accel kvm \ -accel kvm \
-cpu qemu64 \ -cpu qemu64 \
-global driver=cfi.pflash01,property=secure,value=on \
-m 8 \ -m 8 \
-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":8388608}' \ -object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":8388608}' \
-overcommit mem-lock=off \ -overcommit mem-lock=off \

View File

@ -17,6 +17,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-fedora/.config \
-machine pc-q35-4.0,usb=off,smm=on,dump-guest-core=off,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format,memory-backend=pc.ram \ -machine pc-q35-4.0,usb=off,smm=on,dump-guest-core=off,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format,memory-backend=pc.ram \
-accel kvm \ -accel kvm \
-cpu qemu64 \ -cpu qemu64 \
-global driver=cfi.pflash01,property=secure,value=on \
-m 8 \ -m 8 \
-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":8388608}' \ -object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":8388608}' \
-overcommit mem-lock=off \ -overcommit mem-lock=off \

View File

@ -17,6 +17,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-fedora/.config \
-machine pc-q35-4.0,usb=off,smm=on,dump-guest-core=off,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format,memory-backend=pc.ram \ -machine pc-q35-4.0,usb=off,smm=on,dump-guest-core=off,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format,memory-backend=pc.ram \
-accel kvm \ -accel kvm \
-cpu qemu64 \ -cpu qemu64 \
-global driver=cfi.pflash01,property=secure,value=on \
-m 8 \ -m 8 \
-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":8388608}' \ -object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":8388608}' \
-overcommit mem-lock=off \ -overcommit mem-lock=off \

View File

@ -17,6 +17,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-fedora/.config \
-machine pc-q35-4.0,usb=off,smm=on,dump-guest-core=off,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format,memory-backend=pc.ram \ -machine pc-q35-4.0,usb=off,smm=on,dump-guest-core=off,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format,memory-backend=pc.ram \
-accel kvm \ -accel kvm \
-cpu qemu64 \ -cpu qemu64 \
-global driver=cfi.pflash01,property=secure,value=on \
-m 8 \ -m 8 \
-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":8388608}' \ -object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":8388608}' \
-overcommit mem-lock=off \ -overcommit mem-lock=off \