]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cryptenroll: do not pass an empty pcrlock policy
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 25 May 2024 19:42:16 +0000 (04:42 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 25 May 2024 19:42:19 +0000 (04:42 +0900)
Otherwise, tpm2_uneal() -> tpm2_build_sealing_policy() ->
tpm2_deserialize() will trigger assertion.

Prompted by #33017.

src/cryptenroll/cryptenroll-tpm2.c

index 4e5d02a97e769ecceee528592ec354952fab7133..10bd8d77237779d301cdfac8e6ebb24e841c9c53 100644 (file)
@@ -342,6 +342,8 @@ int enroll_tpm2(struct crypt_device *cd,
                 r = tpm2_pcrlock_policy_load(pcrlock_path, &pcrlock_policy);
                 if (r < 0)
                         return r;
+                if (r == 0)
+                        return log_error_errno(SYNTHETIC_ERRNO(ENOENT), "Couldn't find pcrlock policy %s.", pcrlock_path);
 
                 any_pcr_value_specified = true;
                 flags |= TPM2_FLAGS_USE_PCRLOCK;