]> git.ipfire.org Git - thirdparty/systemd.git/commit
cryptsetup: retry TPM2 unseal operation if it fails with TPM2_RC_PCR_CHANGED
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Wed, 7 Dec 2022 15:52:27 +0000 (16:52 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 8 Dec 2022 09:37:28 +0000 (10:37 +0100)
commit0254e4d66af7aa893b31b2326335ded5dde48b51
treedd8cab4cf1cc976fe9bb20b434ae94a7907ea12a
parent15f330cf8745e68abc429765dafdd8d04ebf7154
cryptsetup: retry TPM2 unseal operation if it fails with TPM2_RC_PCR_CHANGED

Quoting "Trusted Platform Module Library - Part 3: Commands (Rev. 01.59)":

"pcrUpdateCounter – this parameter is updated by TPM2_PolicyPCR(). This value
may only be set once during a policy. Each time TPM2_PolicyPCR() executes, it
checks to see if policySession->pcrUpdateCounter has its default state,
indicating that this is the first TPM2_PolicyPCR(). If it has its default value,
then policySession->pcrUpdateCounter is set to the current value of
pcrUpdateCounter. If policySession->pcrUpdateCounter does not have its default
value and its value is not the same as pcrUpdateCounter, the TPM shall return
TPM_RC_PCR_CHANGED.

If this parameter and pcrUpdateCounter are not the same, it indicates that PCR
have changed since checked by the previous TPM2_PolicyPCR(). Since they have
changed, the previous PCR validation is no longer valid."

The TPM will return TPM_RC_PCR_CHANGED if any PCR value changes (no matter
which) between validating the PCRs binded to the enrollment and unsealing the
HMAC key, so this patch adds a retry mechanism in this case.

Fixes #24906
src/shared/tpm2-util.c