Commit 1bf1a5e2 authored by Tadeusz Struk's avatar Tadeusz Struk Committed by Greg Kroah-Hartman

tpm: fix use after free in tpm2_load_context()

commit 8c81c247 upstream.

If load context command returns with TPM2_RC_HANDLE or TPM2_RC_REFERENCE_H0
then we have use after free in line 114 and double free in 117.

Fixes: 4d57856a ("tpm2: add session handle context saving and restoring to the space code")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarTadeusz Struk <tadeusz.struk@intel.com>
Reviewed-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off--by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1ed68714
...@@ -102,8 +102,9 @@ static int tpm2_load_context(struct tpm_chip *chip, u8 *buf, ...@@ -102,8 +102,9 @@ static int tpm2_load_context(struct tpm_chip *chip, u8 *buf,
* TPM_RC_REFERENCE_H0 means the session has been * TPM_RC_REFERENCE_H0 means the session has been
* flushed outside the space * flushed outside the space
*/ */
rc = -ENOENT; *handle = 0;
tpm_buf_destroy(&tbuf); tpm_buf_destroy(&tbuf);
return -ENOENT;
} else if (rc > 0) { } else if (rc > 0) {
dev_warn(&chip->dev, "%s: failed with a TPM error 0x%04X\n", dev_warn(&chip->dev, "%s: failed with a TPM error 0x%04X\n",
__func__, rc); __func__, rc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment