diff mbox

[U-Boot,2/2] efi_loader: check CreateEvent() parameters

Message ID 20170312082607.58540-2-jsg@jsg.id.au
State Accepted
Delegated to: Alexander Graf
Headers show

Commit Message

Jonathan Gray March 12, 2017, 8:26 a.m. UTC
Add some of the invalid parameter checks described in the UEFI
specification for CreateEvent().  This does not include checking
the validity of the type and tpl parameters.

Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
---
 lib/efi_loader/efi_boottime.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Heinrich Schuchardt July 1, 2017, 6:44 a.m. UTC | #1
On 03/12/2017 09:26 AM, Jonathan Gray wrote:
> Add some of the invalid parameter checks described in the UEFI
> specification for CreateEvent().  This does not include checking
> the validity of the type and tpl parameters.
> 
> Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
> ---
>  lib/efi_loader/efi_boottime.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
> index eb5946a959..7172b690a5 100644
> --- a/lib/efi_loader/efi_boottime.c
> +++ b/lib/efi_loader/efi_boottime.c
> @@ -189,6 +189,16 @@ static efi_status_t EFIAPI efi_create_event(
>  		return EFI_EXIT(EFI_OUT_OF_RESOURCES);
>  	}
>  
> +	if (event == NULL)
> +		return EFI_EXIT(EFI_INVALID_PARAMETER);
> +
> +	if ((type & EVT_NOTIFY_SIGNAL) && (type & EVT_NOTIFY_WAIT))
> +		return EFI_EXIT(EFI_INVALID_PARAMETER);
> +
> +	if ((type & (EVT_NOTIFY_SIGNAL|EVT_NOTIFY_WAIT)) &&
> +	     notify_function == NULL)
> +		return EFI_EXIT(EFI_INVALID_PARAMETER);
> +
>  	efi_event.type = type;
>  	efi_event.notify_tpl = notify_tpl;
>  	efi_event.notify_function = notify_function;
>

In case of EVT_NOTIFY_WAIT we should also check if the event is already
in the signaled state. But this flag is not implemented yet.

Acked-By: Heinrich Schuchardt <xypron.glpk@gmx.de>
Heinrich Schuchardt July 1, 2017, 7:49 a.m. UTC | #2
Dear Tom,

could you, please, consider pulling

[U-Boot,1/2] efi_loader: run CreateEvent() notify function based on flags
https://patchwork.ozlabs.org/patch/737793/

[U-Boot,2/2] efi_loader: check CreateEvent() parameters
https://patchwork.ozlabs.org/patch/737794/

I have reviewed the patches and tested loading grub via EFI on an Odroid
C2 based on git HEAD (8d6040c725bfa40fba1bd6b5f356ee713c1ac7d1).

Best regards

Heinrich Schuchardt


On 07/01/2017 08:44 AM, Heinrich Schuchardt wrote:
> On 03/12/2017 09:26 AM, Jonathan Gray wrote:
>> Add some of the invalid parameter checks described in the UEFI
>> specification for CreateEvent().  This does not include checking
>> the validity of the type and tpl parameters.
>>
>> Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
>> ---
>>  lib/efi_loader/efi_boottime.c | 10 ++++++++++
>>  1 file changed, 10 insertions(+)
>>
>> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
>> index eb5946a959..7172b690a5 100644
>> --- a/lib/efi_loader/efi_boottime.c
>> +++ b/lib/efi_loader/efi_boottime.c
>> @@ -189,6 +189,16 @@ static efi_status_t EFIAPI efi_create_event(
>>  		return EFI_EXIT(EFI_OUT_OF_RESOURCES);
>>  	}
>>  
>> +	if (event == NULL)
>> +		return EFI_EXIT(EFI_INVALID_PARAMETER);
>> +
>> +	if ((type & EVT_NOTIFY_SIGNAL) && (type & EVT_NOTIFY_WAIT))
>> +		return EFI_EXIT(EFI_INVALID_PARAMETER);
>> +
>> +	if ((type & (EVT_NOTIFY_SIGNAL|EVT_NOTIFY_WAIT)) &&
>> +	     notify_function == NULL)
>> +		return EFI_EXIT(EFI_INVALID_PARAMETER);
>> +
>>  	efi_event.type = type;
>>  	efi_event.notify_tpl = notify_tpl;
>>  	efi_event.notify_function = notify_function;
>>
> 
> In case of EVT_NOTIFY_WAIT we should also check if the event is already
> in the signaled state. But this flag is not implemented yet.
> 
> Acked-By: Heinrich Schuchardt <xypron.glpk@gmx.de>
>
Alexander Graf July 3, 2017, 11:55 a.m. UTC | #3
Hi Heinrich,

Thanks a lot for the reminder email. I'll get them integrated asap.

Alex

On 07/01/2017 09:49 AM, Heinrich Schuchardt wrote:
> Dear Tom,
>
> could you, please, consider pulling
>
> [U-Boot,1/2] efi_loader: run CreateEvent() notify function based on flags
> https://patchwork.ozlabs.org/patch/737793/
>
> [U-Boot,2/2] efi_loader: check CreateEvent() parameters
> https://patchwork.ozlabs.org/patch/737794/
>
> I have reviewed the patches and tested loading grub via EFI on an Odroid
> C2 based on git HEAD (8d6040c725bfa40fba1bd6b5f356ee713c1ac7d1).
>
> Best regards
>
> Heinrich Schuchardt
>
>
> On 07/01/2017 08:44 AM, Heinrich Schuchardt wrote:
>> On 03/12/2017 09:26 AM, Jonathan Gray wrote:
>>> Add some of the invalid parameter checks described in the UEFI
>>> specification for CreateEvent().  This does not include checking
>>> the validity of the type and tpl parameters.
>>>
>>> Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
>>> ---
>>>   lib/efi_loader/efi_boottime.c | 10 ++++++++++
>>>   1 file changed, 10 insertions(+)
>>>
>>> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
>>> index eb5946a959..7172b690a5 100644
>>> --- a/lib/efi_loader/efi_boottime.c
>>> +++ b/lib/efi_loader/efi_boottime.c
>>> @@ -189,6 +189,16 @@ static efi_status_t EFIAPI efi_create_event(
>>>   		return EFI_EXIT(EFI_OUT_OF_RESOURCES);
>>>   	}
>>>   
>>> +	if (event == NULL)
>>> +		return EFI_EXIT(EFI_INVALID_PARAMETER);
>>> +
>>> +	if ((type & EVT_NOTIFY_SIGNAL) && (type & EVT_NOTIFY_WAIT))
>>> +		return EFI_EXIT(EFI_INVALID_PARAMETER);
>>> +
>>> +	if ((type & (EVT_NOTIFY_SIGNAL|EVT_NOTIFY_WAIT)) &&
>>> +	     notify_function == NULL)
>>> +		return EFI_EXIT(EFI_INVALID_PARAMETER);
>>> +
>>>   	efi_event.type = type;
>>>   	efi_event.notify_tpl = notify_tpl;
>>>   	efi_event.notify_function = notify_function;
>>>
>> In case of EVT_NOTIFY_WAIT we should also check if the event is already
>> in the signaled state. But this flag is not implemented yet.
>>
>> Acked-By: Heinrich Schuchardt <xypron.glpk@gmx.de>
>>
Alexander Graf July 3, 2017, 1:58 p.m. UTC | #4
> Add some of the invalid parameter checks described in the UEFI
> specification for CreateEvent().  This does not include checking
> the validity of the type and tpl parameters.
> 
> Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
> Acked-By: Heinrich Schuchardt <xypron.glpk@gmx.de>

Thanks, applied to efi-next

Alex
diff mbox

Patch

diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index eb5946a959..7172b690a5 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -189,6 +189,16 @@  static efi_status_t EFIAPI efi_create_event(
 		return EFI_EXIT(EFI_OUT_OF_RESOURCES);
 	}
 
+	if (event == NULL)
+		return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+	if ((type & EVT_NOTIFY_SIGNAL) && (type & EVT_NOTIFY_WAIT))
+		return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+	if ((type & (EVT_NOTIFY_SIGNAL|EVT_NOTIFY_WAIT)) &&
+	     notify_function == NULL)
+		return EFI_EXIT(EFI_INVALID_PARAMETER);
+
 	efi_event.type = type;
 	efi_event.notify_tpl = notify_tpl;
 	efi_event.notify_function = notify_function;