]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tpm2: log about invalid PCRs on each unsealing
authorLennart Poettering <lennart@poettering.net>
Mon, 13 Sep 2021 10:43:53 +0000 (12:43 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 13 Sep 2021 13:02:53 +0000 (15:02 +0200)
Let's log every time we use uninitialized PCRs when unsealing a secret
via TPM2. This indicates a firmware issue usually, and is something we
shouldn't just show when enrolling but also show every time we unseal,
so that the fact that the selected PCR policy is pretty much pointless
is repeatedly shown.

src/shared/tpm2-util.c

index f5f46d14eedc35b72c6c838b9d7b35bb1a233fe4..9d5a0ed86523d337919303bfcd48a8e5b1cd7df0 100644 (file)
@@ -617,9 +617,15 @@ static int tpm2_make_pcr_session(
 
         log_debug("Starting authentication session.");
 
-        if (pcr_bank != UINT16_MAX)
+        if (pcr_bank != UINT16_MAX) {
+                r = tpm2_pcr_mask_good(c, pcr_bank, pcr_mask);
+                if (r < 0)
+                        return r;
+                if (r == 0)
+                        log_notice("Selected TPM2 PCRs are not initialized on this system, most likely due to a firmware issue. PCR policy is effectively not enforced. Proceeding anyway.");
+
                 tpm2_pcr_mask_to_selecion(pcr_mask, pcr_bank, &pcr_selection);
-        else {
+        else {
                 TPMI_ALG_HASH h;
 
                 /* No bank configured, pick automatically. Some TPM2 devices only can do SHA1. If we detect