Skip to content

Commit 8c81c24

Browse files
tstrukJarkko Sakkinen
authored andcommitted
tpm: fix use after free in tpm2_load_context()
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: 4d57856 ("tpm2: add session handle context saving and restoring to the space code") Cc: stable@vger.kernel.org Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off--by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
1 parent 59f5a6b commit 8c81c24

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎drivers/char/tpm/tpm2-space.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ static int tpm2_load_context(struct tpm_chip *chip, u8 *buf,
102102
* TPM_RC_REFERENCE_H0 means the session has been
103103
* flushed outside the space
104104
*/
105-
rc = -ENOENT;
105+
*handle = 0;
106106
tpm_buf_destroy(&tbuf);
107+
return -ENOENT;
107108
} else if (rc > 0) {
108109
dev_warn(&chip->dev, "%s: failed with a TPM error 0x%04X\n",
109110
__func__, rc);

0 commit comments

Comments
 (0)