Skip to content

Commit dda5384

Browse files
safforddrjarkkojs
authored andcommitted
KEYS: trusted: tpm2: Fix migratable logic
When creating (sealing) a new trusted key, migratable trusted keys have the FIXED_TPM and FIXED_PARENT attributes set, and non-migratable keys don't. This is backwards, and also causes creation to fail when creating a migratable key under a migratable parent. (The TPM thinks you are trying to seal a non-migratable blob under a migratable parent.) The following simple patch fixes the logic, and has been tested for all four combinations of migratable and non-migratable trusted keys and parent storage keys. With this logic, you will get a proper failure if you try to create a non-migratable trusted key under a migratable parent storage key, and all other combinations work correctly. Cc: stable@vger.kernel.org # v5.13+ Fixes: e5fb5d2 ("security: keys: trusted: Make sealed key properly interoperable") Signed-off-by: David Safford <david.safford@gmail.com> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
1 parent 9886142 commit dda5384

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

security/keys/trusted-keys/trusted_tpm2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ int tpm2_seal_trusted(struct tpm_chip *chip,
283283
/* key properties */
284284
flags = 0;
285285
flags |= options->policydigest_len ? 0 : TPM2_OA_USER_WITH_AUTH;
286-
flags |= payload->migratable ? (TPM2_OA_FIXED_TPM |
287-
TPM2_OA_FIXED_PARENT) : 0;
286+
flags |= payload->migratable ? 0 : (TPM2_OA_FIXED_TPM |
287+
TPM2_OA_FIXED_PARENT);
288288
tpm_buf_append_u32(&buf, flags);
289289

290290
/* policy */

0 commit comments

Comments
 (0)