mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-07-18 03:29:57 +02:00
tpm: Rollback tpm2_load_null()
Do not continue on tpm2_create_primary() failure in tpm2_load_null().
Cc: stable@vger.kernel.org # v6.10+
Fixes: eb24c9788c
("tpm: disable the TPM if NULL name changes")
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
This commit is contained in:
parent
d658d59471
commit
cc7d859434
|
@ -915,33 +915,37 @@ static int tpm2_parse_start_auth_session(struct tpm2_auth *auth,
|
||||||
|
|
||||||
static int tpm2_load_null(struct tpm_chip *chip, u32 *null_key)
|
static int tpm2_load_null(struct tpm_chip *chip, u32 *null_key)
|
||||||
{
|
{
|
||||||
int rc;
|
|
||||||
unsigned int offset = 0; /* dummy offset for null seed context */
|
unsigned int offset = 0; /* dummy offset for null seed context */
|
||||||
u8 name[SHA256_DIGEST_SIZE + 2];
|
u8 name[SHA256_DIGEST_SIZE + 2];
|
||||||
|
u32 tmp_null_key;
|
||||||
|
int rc;
|
||||||
|
|
||||||
rc = tpm2_load_context(chip, chip->null_key_context, &offset,
|
rc = tpm2_load_context(chip, chip->null_key_context, &offset,
|
||||||
null_key);
|
&tmp_null_key);
|
||||||
if (rc != -EINVAL)
|
if (rc != -EINVAL) {
|
||||||
return rc;
|
if (!rc)
|
||||||
|
*null_key = tmp_null_key;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
/* an integrity failure may mean the TPM has been reset */
|
/* Try to re-create null key, given the integrity failure: */
|
||||||
dev_err(&chip->dev, "NULL key integrity failure!\n");
|
rc = tpm2_create_primary(chip, TPM2_RH_NULL, &tmp_null_key, name);
|
||||||
/* check the null name against what we know */
|
if (rc)
|
||||||
tpm2_create_primary(chip, TPM2_RH_NULL, NULL, name);
|
goto err;
|
||||||
if (memcmp(name, chip->null_key_name, sizeof(name)) == 0)
|
|
||||||
/* name unchanged, assume transient integrity failure */
|
/* Return null key if the name has not been changed: */
|
||||||
return rc;
|
if (!memcmp(name, chip->null_key_name, sizeof(name))) {
|
||||||
/*
|
*null_key = tmp_null_key;
|
||||||
* Fatal TPM failure: the NULL seed has actually changed, so
|
return 0;
|
||||||
* the TPM must have been illegally reset. All in-kernel TPM
|
}
|
||||||
* operations will fail because the NULL primary can't be
|
|
||||||
* loaded to salt the sessions, but disable the TPM anyway so
|
/* Deduce from the name change TPM interference: */
|
||||||
* userspace programmes can't be compromised by it.
|
dev_err(&chip->dev, "null key integrity check failed\n");
|
||||||
*/
|
tpm2_flush_context(chip, tmp_null_key);
|
||||||
dev_err(&chip->dev, "NULL name has changed, disabling TPM due to interference\n");
|
|
||||||
chip->flags |= TPM_CHIP_FLAG_DISABLE;
|
chip->flags |= TPM_CHIP_FLAG_DISABLE;
|
||||||
|
|
||||||
return rc;
|
err:
|
||||||
|
return rc ? -ENODEV : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user