Skip to content

Commit

Permalink
tpm: add check for minimum buffer size in tpm_transmit()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jarkko Sakkinen committed Sep 15, 2016
1 parent 0014777 commit ebfd753
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/char/tpm/tpm-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit ebfd753

Please sign in to comment.