Skip to contentSkip to conversation

tpm: tpm_transmit() does not check for minimum buffer size.

PATCH In review Jarkko Sakkinen 2 participants 3 messages Sep 12, 2016 TPM device driver

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tpm: tpm_transmit() does not check for minimum buffer size.

tpm_transmit() does not check that bufsiz is at least TPM_HEADER_SIZE before accessing data. This commit adds the check and returns -ENOMEM.

v2: Updated commit msg

---
 drivers/char/tpm/tpm-interface.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/char/tpm/tpm-interface.c +3 -0
index fd863ff..6a67f7f 100644
@@ -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;
 
Signature · 4 lines
2.7.4


------------------------------------------------------------------------------
#1 lore raw
Quoted 2 lines · Jarkko Sakkinen

tpm_transmit() does not check that bufsiz is at least TPM_HEADER_SIZE before accessing data. This commit adds the check and returns -ENOMEM.

-EINVAL

Quoted 1 line

v2: Updated commit msg

After the diffstat, do not commit that to the tree

Jason

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. http://sdm.link/zohodev2dev

#2 lore raw
Quoted 9 lines · Jason Gunthorpe
Quoted 2 lines · Jarkko Sakkinen

tpm_transmit() does not check that bufsiz is at least TPM_HEADER_SIZE before accessing data. This commit adds the check and returns -ENOMEM.

-EINVAL

Quoted 1 line

v2: Updated commit msg

After the diffstat, do not commit that to the tree

Duh, right. Thanks.

Quoted 1 line

Jason

/Jarkko

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. http://sdm.link/zohodev2dev