tpmdd-devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] tpm: fix use after free in tpm2_load_context
@ 2018-05-09 18:55 Tadeusz Struk
       [not found] ` <152589213590.23382.13567986597921947843.stgit-mEAvsCHCuLnxhXoCA9A9g62pdiUAq4bhAL8bYrjMMd8@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Tadeusz Struk @ 2018-05-09 18:55 UTC (permalink / raw)
  To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA
  Cc: jgg-uk2M96/98Pc, linux-integrity-u79uwXL29TY76Z2rM5mHXA,
	tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

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-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 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);


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

* Re: [PATCH] tpm: fix use after free in tpm2_load_context
       [not found] ` <152589213590.23382.13567986597921947843.stgit-mEAvsCHCuLnxhXoCA9A9g62pdiUAq4bhAL8bYrjMMd8@public.gmane.org>
@ 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-uk2M96/98Pc, linux-integrity-u79uwXL29TY76Z2rM5mHXA,
	tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

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-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

Thank you, appreciate this!

Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

/Jarkko

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

end of thread, back to index

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
     [not found] ` <152589213590.23382.13567986597921947843.stgit-mEAvsCHCuLnxhXoCA9A9g62pdiUAq4bhAL8bYrjMMd8@public.gmane.org>
2018-05-14 10:54   ` Jarkko Sakkinen

tpmdd-devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/tpmdd-devel/0 tpmdd-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 tpmdd-devel tpmdd-devel/ https://lore.kernel.org/tpmdd-devel \
		tpmdd-devel@lists.sourceforge.net tpmdd-devel@archiver.kernel.org
	public-inbox-index tpmdd-devel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/net.sourceforge.lists.tpmdd-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox