aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tpm/tpm-interface.c
diff options
context:
space:
mode:
authorJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>2018-09-03 04:01:26 +0300
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>2018-10-05 13:47:33 +0300
commit84b59f6487d82d3ab4247a099aba66d4d17e8b08 (patch)
treea028dd73b36a47922eb1867bd6ca95bf0da6a784 /drivers/char/tpm/tpm-interface.c
parentkeys: Fix the use of the C++ keyword "private" in uapi/linux/keyctl.h (diff)
downloadlinux-dev-84b59f6487d82d3ab4247a099aba66d4d17e8b08.tar.xz
linux-dev-84b59f6487d82d3ab4247a099aba66d4d17e8b08.zip
tpm: fix response size validation in tpm_get_random()
When checking whether the response is large enough to be able to contain the received random bytes in tpm_get_random() and tpm2_get_random(), they fail to take account the header size, which should be added to the minimum size. This commit fixes this issue. Cc: stable@vger.kernel.org Fixes: c659af78eb7b ("tpm: Check size of response before accessing data") Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Diffstat (limited to 'drivers/char/tpm/tpm-interface.c')
-rw-r--r--drivers/char/tpm/tpm-interface.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 1a803b0cf980..318a7078b2ba 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -1321,7 +1321,8 @@ int tpm_get_random(struct tpm_chip *chip, u8 *out, size_t max)
}
rlength = be32_to_cpu(tpm_cmd.header.out.length);
- if (rlength < offsetof(struct tpm_getrandom_out, rng_data) +
+ if (rlength < TPM_HEADER_SIZE +
+ offsetof(struct tpm_getrandom_out, rng_data) +
recd) {
total = -EFAULT;
break;