]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
tpm: fix use after free in tpm2_load_context()
authorTadeusz Struk <tadeusz.struk@intel.com>
Wed, 9 May 2018 18:55:35 +0000 (11:55 -0700)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Mon, 14 May 2018 10:56:06 +0000 (13:56 +0300)
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: 4d57856a21ed2 ("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>
drivers/char/tpm/tpm2-space.c

index 4e4014eabdb9c34776d1fbd71c3a8747fcca8c6f..6122d3276f7224a05f30dc9fe8094fc69f1bd695 100644 (file)
@@ -102,8 +102,9 @@ static int tpm2_load_context(struct tpm_chip *chip, u8 *buf,
                 * TPM_RC_REFERENCE_H0 means the session has been
                 * flushed outside the space
                 */
-               rc = -ENOENT;
+               *handle = 0;
                tpm_buf_destroy(&tbuf);
+               return -ENOENT;
        } else if (rc > 0) {
                dev_warn(&chip->dev, "%s: failed with a TPM error 0x%04X\n",
                         __func__, rc);