tpmdd-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH] tpm: fix buffer overflow in /dev/tpm0
@ 2016-09-11 12:19 Jarkko Sakkinen
  2016-09-11 12:51 ` Jarkko Sakkinen
       [not found] ` <1473596340-11376-1-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  0 siblings, 2 replies; 5+ messages in thread
From: Jarkko Sakkinen @ 2016-09-11 12:19 UTC (permalink / raw)
  To: Peter Huewe
  Cc: Jarkko Sakkinen, Marcel Selhorst, Jason Gunthorpe,
	moderated list:TPM DEVICE DRIVER, open list

tpm_write() does not check whether the buffer has at least enough space
for the header before passing it to tpm_transmit() so an overflow can
happen.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
 drivers/char/tpm/tpm-interface.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index fd863ff..6a67f7f 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -337,6 +337,9 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const u8 *buf, size_t bufsiz,
 	u32 count, ordinal;
 	unsigned long stop;
 
+	if (bufsiz < TPM_HEADER_SIZE)
+		return -EINVAL;
+
 	if (bufsiz > TPM_BUFSIZE)
 		bufsiz = TPM_BUFSIZE;
 
-- 
2.7.4

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

end of thread, other threads:[~2016-09-12  7:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-11 12:19 [PATCH] tpm: fix buffer overflow in /dev/tpm0 Jarkko Sakkinen
2016-09-11 12:51 ` Jarkko Sakkinen
     [not found]   ` <20160911125142.GA20191-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-09-11 18:57     ` Jarkko Sakkinen
     [not found] ` <1473596340-11376-1-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2016-09-12  4:05   ` Jason Gunthorpe
     [not found]     ` <20160912040546.GA14625-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-09-12  7:50       ` 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).