]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu_firmware: Enable loader.secure when requires-smm
authorAndrea Bolognani <abologna@redhat.com>
Thu, 9 Jun 2022 15:59:33 +0000 (17:59 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Fri, 1 Jul 2022 13:10:39 +0000 (15:10 +0200)
commit262672dbbfe46c6e9090afdf516c13bfb93f98e5
tree16ce86e8e172eb082ab0f0a03b781f721ae0bd31
parent73c5ae55c7c3a5b26cc16ad85ecd57fc1d410b33
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>
src/qemu/qemu_firmware.c
tests/qemuxml2argvdata/firmware-auto-efi-enrolled-keys.x86_64-latest.args
tests/qemuxml2argvdata/firmware-auto-efi-nvram.x86_64-latest.args
tests/qemuxml2argvdata/firmware-auto-efi-secboot.x86_64-latest.args
tests/qemuxml2argvdata/firmware-auto-efi.x86_64-latest.args