core: introduce ConditionSecurity=measured-os

So far we always conditioned our TPM magic on the UKI having detected
TPM support in the firmware. This is a bit limiting when we want to
support a software TPM that is not visible to the firmware. Hence let's
split this up, and add a separate control that can be set via the kernel
command line.  However, as before, let's by default inherit the firmare
TPM discovery state into it, to retain the current behaviour unless
overriden.

With this in place, boot with "systemd.tpm2_measured_os=1
systemd.tpm2_software_fallback=1" on the kernel cmdline to get the swtpm
fallback and then a measured OS based on it.
This commit is contained in:
Lennart Poettering
2026-03-26 16:11:34 +01:00
parent ca03d178a0
commit cd911bec6e
25 changed files with 86 additions and 30 deletions
+4 -4
View File
@@ -1030,11 +1030,11 @@ static int measure_volume_key(
return 0;
}
r = efi_measured_uki(LOG_WARNING);
r = efi_measured_os(LOG_WARNING);
if (r < 0)
return r;
if (r == 0) {
log_debug("Kernel stub did not measure kernel image into the expected PCR, skipping userspace volume key measurement, too.");
log_debug("OS measurements not explicitly requested and kernel stub did not measure kernel image into the expected PCR, skipping userspace volume key measurement, too.");
return 0;
}
@@ -1109,11 +1109,11 @@ static int measure_keyslot(
}
#if HAVE_TPM2
r = efi_measured_uki(LOG_WARNING);
r = efi_measured_os(LOG_WARNING);
if (r < 0)
return r;
if (r == 0) {
log_debug("Kernel stub did not measure kernel image into the expected PCR, skipping userspace key slot measurement, too.");
log_debug("OS measurements not explicitly requested and kernel stub did not measure kernel image into the expected PCR, skipping userspace key slot measurement, too.");
return 0;
}