tpm2-util: retry NvPCR initialization when PCR values keep changing

tpm2_nvpcr_initialize() already retries the initializing write when
tpm2_extend_nvpcr_nv_index() reports that PCR values changed under its
feet, which the comment there attributes to IMA measurements performed
by the kernel.  The policy session that write needs is opened in the
same loop, and a PCR extended while that policy is submitted makes
tpm2_policy_pcr() return -EUCLEAN, which was propagated as a hard
failure instead.

That is the same transient condition observed one step earlier, so let
the loop absorb it too.

Signed-off-by: Alberto Planas <aplanas@suse.com>
This commit is contained in:
Alberto Planas
2026-09-22 21:31:48 +02:00
committed by Luca Boccassi
parent 299989fe0b
commit f08bfdbf3d
+7
View File
@@ -9296,6 +9296,13 @@ int tpm2_nvpcr_initialize(
signature_json,
&authorize_policy,
&policy_session);
if (r == -EUCLEAN) {
/* A PCR was extended while we submitted the policy, so this session is unusable.
* Same situation as below, just observed while building the policy rather than
* while writing. */
if (i > 0)
continue;
}
if (r < 0)
return r;