diff options
author | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> | 2016-09-12 10:43:30 (GMT) |
---|---|---|
committer | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> | 2016-09-15 13:04:21 (GMT) |
commit | ebfd7532e985818a327906e011f3e43c8ddfdd74 (patch) | |
tree | 33c2acaeeba0454ace929e77fd7ab228e7870edc /drivers/char/tpm | |
parent | 0014777f989b54193bec95a0a153fa4a139183c7 (diff) | |
download | linux-ebfd7532e985818a327906e011f3e43c8ddfdd74.tar.xz |
tpm: add check for minimum buffer size in tpm_transmit()
tpm_transmit() does not check that bufsiz is at least TPM_HEADER_SIZE
before accessing data. This commit adds this check and returns -EINVAL
if it fails.
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Diffstat (limited to 'drivers/char/tpm')
-rw-r--r-- | drivers/char/tpm/tpm-interface.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c index 3970f84..8de6187 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; |