linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] efi/tpm: fix sanity check of unsigned tbl_size being less than zero
@ 2019-10-08 10:01 Colin King
  2019-10-08 11:05 ` [tip: efi/urgent] efi/tpm: Fix " tip-bot2 for Colin Ian King
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Colin King @ 2019-10-08 10:01 UTC (permalink / raw)
  To: Ard Biesheuvel, Jerry Snitselaar, Ingo Molnar, linux-efi
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently the check for tbl_size being less than zero is always false
because tbl_size is unsigned. Fix this by making it a signed int.

Addresses-Coverity: ("Unsigned compared against 0")
Fixes: e658c82be556 ("efi/tpm: Only set 'efi_tpm_final_log_size' after successful event log parsing")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/firmware/efi/tpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/tpm.c b/drivers/firmware/efi/tpm.c
index 703469c1ab8e..ebd7977653a8 100644
--- a/drivers/firmware/efi/tpm.c
+++ b/drivers/firmware/efi/tpm.c
@@ -40,7 +40,7 @@ int __init efi_tpm_eventlog_init(void)
 {
 	struct linux_efi_tpm_eventlog *log_tbl;
 	struct efi_tcg2_final_events_table *final_tbl;
-	unsigned int tbl_size;
+	int tbl_size;
 	int ret = 0;
 
 	if (efi.tpm_log == EFI_INVALID_TABLE_ADDR) {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [tip: efi/urgent] efi/tpm: Fix sanity check of unsigned tbl_size being less than zero
  2019-10-08 10:01 [PATCH][next] efi/tpm: fix sanity check of unsigned tbl_size being less than zero Colin King
@ 2019-10-08 11:05 ` tip-bot2 for Colin Ian King
  2019-10-08 11:46 ` [PATCH][next] efi/tpm: fix " Dan Carpenter
  2019-10-08 15:47 ` Jerry Snitselaar
  2 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Colin Ian King @ 2019-10-08 11:05 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Colin Ian King, Ard Biesheuvel, Jerry Snitselaar, Linus Torvalds,
	Peter Zijlstra, Thomas Gleixner, kernel-janitors, linux-efi,
	Ingo Molnar, Borislav Petkov, linux-kernel

The following commit has been merged into the efi/urgent branch of tip:

Commit-ID:     be59d57f98065af0b8472f66a0a969207b168680
Gitweb:        https://git.kernel.org/tip/be59d57f98065af0b8472f66a0a969207b168680
Author:        Colin Ian King <colin.king@canonical.com>
AuthorDate:    Tue, 08 Oct 2019 11:01:53 +01:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Tue, 08 Oct 2019 13:01:09 +02:00

efi/tpm: Fix sanity check of unsigned tbl_size being less than zero

Currently the check for tbl_size being less than zero is always false
because tbl_size is unsigned. Fix this by making it a signed int.

Addresses-Coverity: ("Unsigned compared against 0")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jerry Snitselaar <jsnitsel@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: kernel-janitors@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Fixes: e658c82be556 ("efi/tpm: Only set 'efi_tpm_final_log_size' after successful event log parsing")
Link: https://lkml.kernel.org/r/20191008100153.8499-1-colin.king@canonical.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 drivers/firmware/efi/tpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/tpm.c b/drivers/firmware/efi/tpm.c
index 703469c..ebd7977 100644
--- a/drivers/firmware/efi/tpm.c
+++ b/drivers/firmware/efi/tpm.c
@@ -40,7 +40,7 @@ int __init efi_tpm_eventlog_init(void)
 {
 	struct linux_efi_tpm_eventlog *log_tbl;
 	struct efi_tcg2_final_events_table *final_tbl;
-	unsigned int tbl_size;
+	int tbl_size;
 	int ret = 0;
 
 	if (efi.tpm_log == EFI_INVALID_TABLE_ADDR) {

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH][next] efi/tpm: fix sanity check of unsigned tbl_size being less than zero
  2019-10-08 10:01 [PATCH][next] efi/tpm: fix sanity check of unsigned tbl_size being less than zero Colin King
  2019-10-08 11:05 ` [tip: efi/urgent] efi/tpm: Fix " tip-bot2 for Colin Ian King
@ 2019-10-08 11:46 ` Dan Carpenter
  2019-10-08 16:15   ` Jerry Snitselaar
  2019-10-08 15:47 ` Jerry Snitselaar
  2 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2019-10-08 11:46 UTC (permalink / raw)
  To: Colin King, Jerry Snitselaar
  Cc: Ard Biesheuvel, Ingo Molnar, linux-efi, kernel-janitors, linux-kernel

On Tue, Oct 08, 2019 at 11:01:53AM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently the check for tbl_size being less than zero is always false
> because tbl_size is unsigned. Fix this by making it a signed int.
> 
> Addresses-Coverity: ("Unsigned compared against 0")
> Fixes: e658c82be556 ("efi/tpm: Only set 'efi_tpm_final_log_size' after successful event log parsing")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/firmware/efi/tpm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/efi/tpm.c b/drivers/firmware/efi/tpm.c
> index 703469c1ab8e..ebd7977653a8 100644
> --- a/drivers/firmware/efi/tpm.c
> +++ b/drivers/firmware/efi/tpm.c
> @@ -40,7 +40,7 @@ int __init efi_tpm_eventlog_init(void)
>  {
>  	struct linux_efi_tpm_eventlog *log_tbl;
>  	struct efi_tcg2_final_events_table *final_tbl;
> -	unsigned int tbl_size;
> +	int tbl_size;
>  	int ret = 0;


Do we need to do a "ret = tbl_size;"?  Currently we return success.
It's a pitty that tpm2_calc_event_log_size() returns a -1 instead of
-EINVAL.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][next] efi/tpm: fix sanity check of unsigned tbl_size being less than zero
  2019-10-08 10:01 [PATCH][next] efi/tpm: fix sanity check of unsigned tbl_size being less than zero Colin King
  2019-10-08 11:05 ` [tip: efi/urgent] efi/tpm: Fix " tip-bot2 for Colin Ian King
  2019-10-08 11:46 ` [PATCH][next] efi/tpm: fix " Dan Carpenter
@ 2019-10-08 15:47 ` Jerry Snitselaar
  2 siblings, 0 replies; 6+ messages in thread
From: Jerry Snitselaar @ 2019-10-08 15:47 UTC (permalink / raw)
  To: Colin King
  Cc: Ard Biesheuvel, Ingo Molnar, linux-efi, kernel-janitors, linux-kernel

On Tue Oct 08 19, Colin King wrote:
>From: Colin Ian King <colin.king@canonical.com>
>
>Currently the check for tbl_size being less than zero is always false
>because tbl_size is unsigned. Fix this by making it a signed int.
>
>Addresses-Coverity: ("Unsigned compared against 0")
>Fixes: e658c82be556 ("efi/tpm: Only set 'efi_tpm_final_log_size' after successful event log parsing")
>Signed-off-by: Colin Ian King <colin.king@canonical.com>
>---
> drivers/firmware/efi/tpm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/firmware/efi/tpm.c b/drivers/firmware/efi/tpm.c
>index 703469c1ab8e..ebd7977653a8 100644
>--- a/drivers/firmware/efi/tpm.c
>+++ b/drivers/firmware/efi/tpm.c
>@@ -40,7 +40,7 @@ int __init efi_tpm_eventlog_init(void)
> {
> 	struct linux_efi_tpm_eventlog *log_tbl;
> 	struct efi_tcg2_final_events_table *final_tbl;
>-	unsigned int tbl_size;
>+	int tbl_size;
> 	int ret = 0;
>
> 	if (efi.tpm_log == EFI_INVALID_TABLE_ADDR) {
>-- 
>2.20.1
>

Thanks for catching that. Somehow I dropped it from v2 to v3.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][next] efi/tpm: fix sanity check of unsigned tbl_size being less than zero
  2019-10-08 11:46 ` [PATCH][next] efi/tpm: fix " Dan Carpenter
@ 2019-10-08 16:15   ` Jerry Snitselaar
  2019-10-08 16:24     ` Colin Ian King
  0 siblings, 1 reply; 6+ messages in thread
From: Jerry Snitselaar @ 2019-10-08 16:15 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Colin King, Ard Biesheuvel, Ingo Molnar, linux-efi,
	kernel-janitors, linux-kernel

On Tue Oct 08 19, Dan Carpenter wrote:
>On Tue, Oct 08, 2019 at 11:01:53AM +0100, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Currently the check for tbl_size being less than zero is always false
>> because tbl_size is unsigned. Fix this by making it a signed int.
>>
>> Addresses-Coverity: ("Unsigned compared against 0")
>> Fixes: e658c82be556 ("efi/tpm: Only set 'efi_tpm_final_log_size' after successful event log parsing")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>  drivers/firmware/efi/tpm.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/firmware/efi/tpm.c b/drivers/firmware/efi/tpm.c
>> index 703469c1ab8e..ebd7977653a8 100644
>> --- a/drivers/firmware/efi/tpm.c
>> +++ b/drivers/firmware/efi/tpm.c
>> @@ -40,7 +40,7 @@ int __init efi_tpm_eventlog_init(void)
>>  {
>>  	struct linux_efi_tpm_eventlog *log_tbl;
>>  	struct efi_tcg2_final_events_table *final_tbl;
>> -	unsigned int tbl_size;
>> +	int tbl_size;
>>  	int ret = 0;
>
>
>Do we need to do a "ret = tbl_size;"?  Currently we return success.
>It's a pitty that tpm2_calc_event_log_size() returns a -1 instead of
>-EINVAL.
>
>regards,
>dan carpenter
>

perhaps "ret = -EINVAL;"? Currently nothing checks the return value of efi_tpm_eventlog_init though.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][next] efi/tpm: fix sanity check of unsigned tbl_size being less than zero
  2019-10-08 16:15   ` Jerry Snitselaar
@ 2019-10-08 16:24     ` Colin Ian King
  0 siblings, 0 replies; 6+ messages in thread
From: Colin Ian King @ 2019-10-08 16:24 UTC (permalink / raw)
  To: Dan Carpenter, Ard Biesheuvel, Ingo Molnar, linux-efi,
	kernel-janitors, linux-kernel

On 08/10/2019 17:15, Jerry Snitselaar wrote:
> On Tue Oct 08 19, Dan Carpenter wrote:
>> On Tue, Oct 08, 2019 at 11:01:53AM +0100, Colin King wrote:
>>> From: Colin Ian King <colin.king@canonical.com>
>>>
>>> Currently the check for tbl_size being less than zero is always false
>>> because tbl_size is unsigned. Fix this by making it a signed int.
>>>
>>> Addresses-Coverity: ("Unsigned compared against 0")
>>> Fixes: e658c82be556 ("efi/tpm: Only set 'efi_tpm_final_log_size'
>>> after successful event log parsing")
>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>>> ---
>>>  drivers/firmware/efi/tpm.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/firmware/efi/tpm.c b/drivers/firmware/efi/tpm.c
>>> index 703469c1ab8e..ebd7977653a8 100644
>>> --- a/drivers/firmware/efi/tpm.c
>>> +++ b/drivers/firmware/efi/tpm.c
>>> @@ -40,7 +40,7 @@ int __init efi_tpm_eventlog_init(void)
>>>  {
>>>      struct linux_efi_tpm_eventlog *log_tbl;
>>>      struct efi_tcg2_final_events_table *final_tbl;
>>> -    unsigned int tbl_size;
>>> +    int tbl_size;
>>>      int ret = 0;
>>
>>
>> Do we need to do a "ret = tbl_size;"?  Currently we return success.
>> It's a pitty that tpm2_calc_event_log_size() returns a -1 instead of
>> -EINVAL.
>>
>> regards,
>> dan carpenter
>>
> 
> perhaps "ret = -EINVAL;"? Currently nothing checks the return value of
> efi_tpm_eventlog_init though.

I doubt I'll fix that for my current fix as a V2.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-10-08 16:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-08 10:01 [PATCH][next] efi/tpm: fix sanity check of unsigned tbl_size being less than zero Colin King
2019-10-08 11:05 ` [tip: efi/urgent] efi/tpm: Fix " tip-bot2 for Colin Ian King
2019-10-08 11:46 ` [PATCH][next] efi/tpm: fix " Dan Carpenter
2019-10-08 16:15   ` Jerry Snitselaar
2019-10-08 16:24     ` Colin Ian King
2019-10-08 15:47 ` Jerry Snitselaar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).