You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e846bba
Browse filesBrowse the repository at this point in the historyBrowse files
tpm2: Don't fail NvPCR initialization if there is no initial write policy available
Currently systemd-tpm2-setup will fail if NvPCR initialization doesn't
succeed, either because the currently booted UKI carries no PCR public
key, or it carries no appropriate signed policy (one with the "initrd"
policy reference). In addition to this, systemd-pcrextend will
subsequently fail because it also fails to initialize the NvPCR it is
requested to extend.
This makes systemd-tpm2-setup return EX_CONFIG in these scenarios, with
this marked as a successful exit status in the service unit file. In
addition to this, systemd-pcrextend is updated to only attempt NvPCR
initialization from the initrd (the only place it will succceed), and
when called with --graceful, to not exit with an error code if the
target NvPCR is uninitialized, and can't be initialized because of a
missing PCR public key or appropriate signed policy. When called via
Varlink, it will return the existing "NoSuchNvPCR" error.
Note that I also removed some NvPCR initialization specific exit status
codes from systemd-tpm2-setup.service.in, as these can only be returned
via systemd-tpm2-setup-early.service.
This should address the issues in
#43848.
@@ -9331,8 +9341,13 @@ int tpm2_nvpcr_extend_bytes(
9331
9341
return r;
9332
9342
9333
9343
/* The NvPCR isn't initialized yet, i.e. systemd-tpm2-setup hasn't run.
9334
-
* Initialize it now and extend again. */
9344
+
* Initialize it now and extend again. This can only run in the initrd. */
9345
+
if (!in_initrd())
9346
+
return log_debug_errno(r, "NvPCR is not initialized and lazy initialization is only available in the initrd, refusing.");
9347
+
9335
9348
r = tpm2_nvpcr_initialize(c, session, name);
9349
+
if (r == -ENOKEY) /* Can't be initialized in this boot, report it as not initialized. */
9350
+
return -ENETDOWN;
9336
9351
if (r < 0)
9337
9352
return log_debug_errno(r, "Failed to initialize NvPCR '%s': %m", name);
9338
9353
@@ -9424,6 +9439,9 @@ int tpm2_nvpcr_initialize(
9424
9439
return 0;
9425
9440
}
9426
9441
9442
+
if (!in_initrd())
9443
+
return log_debug_errno(SYNTHETIC_ERRNO(ENOKEY), "NvPCR '%s' is not initialized yet and initialization is only available in the initrd, refusing.", name);
/* NvPCR initialization is not authorized in this boot, because the booted UKI carries no
477
+
* PCR public key or no signed PCR policy for NvPCR initialization, or because we're not
478
+
* running in the initrd. This is not an error, the NvPCR simply won't be available in
479
+
* this boot. */
480
+
c->nvpcr_unauthorized= true;
481
+
c->n_skipped++;
482
+
returnlog_struct_errno(LOG_NOTICE, r,
483
+
LOG_MESSAGE("NvPCR initialization is not authorized in this boot (no PCR public key, no signed PCR policy for NvPCR initialization, or not running in the initrd), unable to allocate NvPCR '%s' and any others: %m", name),
0 commit comments