diff mbox series

[v2,2/3] tcgbios: Fix the vendorInfoSize to be of type uint8_t

Message ID 20200330121029.866011-3-stefanb@linux.vnet.ibm.com
State New
Headers show
Series Some tcgbios related fixes and updates | expand

Commit Message

Stefan Berger March 30, 2020, 12:10 p.m. UTC
From: Stefan Berger <stefanb@linux.ibm.com>

The vendorInfoSize is a uint8_t rather than a uint32_t.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
---
 lib/libtpm/tcgbios.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Alexey Kardashevskiy May 8, 2020, 12:55 a.m. UTC | #1
On 30/03/2020 23:10, Stefan Berger wrote:
> From: Stefan Berger <stefanb@linux.ibm.com>
> 
> The vendorInfoSize is a uint8_t rather than a uint32_t.


What is the implication of this bug? Do we need to backport it to stable
qemu 5.0.x?


> 
> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
> ---
>  lib/libtpm/tcgbios.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/libtpm/tcgbios.c b/lib/libtpm/tcgbios.c
> index 81f351c..c0e1b45 100644
> --- a/lib/libtpm/tcgbios.c
> +++ b/lib/libtpm/tcgbios.c
> @@ -647,7 +647,7 @@ static int tpm20_write_EfiSpecIdEventStruct(void)
>  	struct tpms_pcr_selection *sel;
>  	void *nsel, *end;
>  	int event_size;
> -	uint32_t *vendorInfoSize;
> +	uint8_t *vendorInfoSize;
>  	struct tpm_log_entry le = {
>  		.hdr.eventtype = cpu_to_log32(EV_NO_ACTION),
>  	};
> @@ -682,7 +682,7 @@ static int tpm20_write_EfiSpecIdEventStruct(void)
>  
>  		event_size = offset_of(struct TCG_EfiSpecIdEventStruct,
>  				       digestSizes[count+1]);
> -		if (event_size > sizeof(event) - sizeof(uint32_t)) {
> +		if (event_size > sizeof(event) - sizeof(uint8_t)) {
>  			dprintf("EfiSpecIdEventStruct pad too small\n");
>  			return -1;
>  		}
>
Stefan Berger May 8, 2020, 7:36 p.m. UTC | #2
On 5/7/20 8:55 PM, Alexey Kardashevskiy wrote:
>
> On 30/03/2020 23:10, Stefan Berger wrote:
>> From: Stefan Berger <stefanb@linux.ibm.com>
>>
>> The vendorInfoSize is a uint8_t rather than a uint32_t.
>
> What is the implication of this bug? Do we need to backport it to stable
> qemu 5.0.x?


No, we set the vendorInfoSize to '0' and it's the last field in the 
structure, so it doesn't matter. The structure it is embedded in has its 
own size indicator that is 3 bytes too large but from what I have seen 
with clients tools so far, they don't care.

    Stefan


>
>
>> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
>> ---
>>   lib/libtpm/tcgbios.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/lib/libtpm/tcgbios.c b/lib/libtpm/tcgbios.c
>> index 81f351c..c0e1b45 100644
>> --- a/lib/libtpm/tcgbios.c
>> +++ b/lib/libtpm/tcgbios.c
>> @@ -647,7 +647,7 @@ static int tpm20_write_EfiSpecIdEventStruct(void)
>>   	struct tpms_pcr_selection *sel;
>>   	void *nsel, *end;
>>   	int event_size;
>> -	uint32_t *vendorInfoSize;
>> +	uint8_t *vendorInfoSize;
>>   	struct tpm_log_entry le = {
>>   		.hdr.eventtype = cpu_to_log32(EV_NO_ACTION),
>>   	};
>> @@ -682,7 +682,7 @@ static int tpm20_write_EfiSpecIdEventStruct(void)
>>   
>>   		event_size = offset_of(struct TCG_EfiSpecIdEventStruct,
>>   				       digestSizes[count+1]);
>> -		if (event_size > sizeof(event) - sizeof(uint32_t)) {
>> +		if (event_size > sizeof(event) - sizeof(uint8_t)) {
>>   			dprintf("EfiSpecIdEventStruct pad too small\n");
>>   			return -1;
>>   		}
>>
diff mbox series

Patch

diff --git a/lib/libtpm/tcgbios.c b/lib/libtpm/tcgbios.c
index 81f351c..c0e1b45 100644
--- a/lib/libtpm/tcgbios.c
+++ b/lib/libtpm/tcgbios.c
@@ -647,7 +647,7 @@  static int tpm20_write_EfiSpecIdEventStruct(void)
 	struct tpms_pcr_selection *sel;
 	void *nsel, *end;
 	int event_size;
-	uint32_t *vendorInfoSize;
+	uint8_t *vendorInfoSize;
 	struct tpm_log_entry le = {
 		.hdr.eventtype = cpu_to_log32(EV_NO_ACTION),
 	};
@@ -682,7 +682,7 @@  static int tpm20_write_EfiSpecIdEventStruct(void)
 
 		event_size = offset_of(struct TCG_EfiSpecIdEventStruct,
 				       digestSizes[count+1]);
-		if (event_size > sizeof(event) - sizeof(uint32_t)) {
+		if (event_size > sizeof(event) - sizeof(uint8_t)) {
 			dprintf("EfiSpecIdEventStruct pad too small\n");
 			return -1;
 		}