linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tpm: fix use after free in tpm2_load_context
@ 2018-05-09 18:55 Tadeusz Struk
  2018-05-14 10:54 ` Jarkko Sakkinen
  0 siblings, 1 reply; 2+ messages in thread
From: Tadeusz Struk @ 2018-05-09 18:55 UTC (permalink / raw)
  To: jarkko.sakkinen; +Cc: jgg, linux-integrity, tpmdd-devel, tadeusz.struk

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")

Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
---
 drivers/char/tpm/tpm2-space.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm2-space.c b/drivers/char/tpm/tpm2-space.c
index 4e4014eabdb9..6122d3276f72 100644
--- a/drivers/char/tpm/tpm2-space.c
+++ b/drivers/char/tpm/tpm2-space.c
@@ -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);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tpm: fix use after free in tpm2_load_context
  2018-05-09 18:55 [PATCH] tpm: fix use after free in tpm2_load_context Tadeusz Struk
@ 2018-05-14 10:54 ` Jarkko Sakkinen
  0 siblings, 0 replies; 2+ messages in thread
From: Jarkko Sakkinen @ 2018-05-14 10:54 UTC (permalink / raw)
  To: Tadeusz Struk; +Cc: jgg, linux-integrity, tpmdd-devel

On Wed, May 09, 2018 at 11:55:35AM -0700, Tadeusz Struk wrote:
> 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")
> 
> Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>

Thank you, appreciate this!

Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

/Jarkko

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-14 10:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-09 18:55 [PATCH] tpm: fix use after free in tpm2_load_context Tadeusz Struk
2018-05-14 10:54 ` Jarkko Sakkinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).