tpm: Require a response to have minimum size of a valid response header

Defend against a broken TPM 1.2 or TPM 2.0 that doesn't send at least
a full response header in the response but less than 10 bytes.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2019-11-06 16:35:59 -05:00 committed by Kevin O'Connor
parent 3bdd2b7765
commit 0672bd3b6a
1 changed files with 2 additions and 1 deletions

View File

@ -620,7 +620,8 @@ tpmhw_transmit(u8 locty, struct tpm_req_header *req,
return -1;
irc = td->readresp(respbuffer, respbufferlen);
if (irc != 0)
if (irc != 0 ||
*respbufferlen < sizeof(struct tpm_rsp_header))
return -1;
td->ready();