Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1451308 > unrolled thread

Re: [PATCH] x86/efi: initialize status to ensure garbage is not returned on small size

Started byMatt Fleming <matt@codeblueprint.co.uk>
First post2016-07-27 16:40 +0200
Last post2016-08-01 14:00 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] x86/efi: initialize status to ensure garbage is not  returned on small size Matt Fleming <matt@codeblueprint.co.uk> - 2016-07-27 16:40 +0200
    Re: [PATCH] x86/efi: initialize status to ensure garbage is not  returned on small size Colin Ian King <colin.king@canonical.com> - 2016-07-27 17:00 +0200
      Re: [PATCH] x86/efi: initialize status to ensure garbage is not  returned on small size Matt Fleming <matt@codeblueprint.co.uk> - 2016-08-01 14:00 +0200

#1451308 — Re: [PATCH] x86/efi: initialize status to ensure garbage is not returned on small size

FromMatt Fleming <matt@codeblueprint.co.uk>
Date2016-07-27 16:40 +0200
SubjectRe: [PATCH] x86/efi: initialize status to ensure garbage is not returned on small size
Message-ID<rZya5-Bn-3@gated-at.bofh.it>
On Wed, 20 Jul, at 11:11:06AM, Colin Ian King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Although very unlikey, if size is too small or zero, then we end up with
> status not being set and returning garbage. Instead, initializing status to
> EFI_INVALID_PARAMETER to indicate that size is invalid in the calls to
> setup_uga32 and setup_uga64.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  arch/x86/boot/compressed/eboot.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
> index ff574da..ec6d2ef 100644
> --- a/arch/x86/boot/compressed/eboot.c
> +++ b/arch/x86/boot/compressed/eboot.c
> @@ -578,7 +578,7 @@ setup_uga32(void **uga_handle, unsigned long size, u32 *width, u32 *height)
>  	efi_guid_t uga_proto = EFI_UGA_PROTOCOL_GUID;
>  	unsigned long nr_ugas;
>  	u32 *handles = (u32 *)uga_handle;;
> -	efi_status_t status;
> +	efi_status_t status = EFI_INVALID_PARAMETER;
>  	int i;
>  
>  	first_uga = NULL;
> @@ -623,7 +623,7 @@ setup_uga64(void **uga_handle, unsigned long size, u32 *width, u32 *height)
>  	efi_guid_t uga_proto = EFI_UGA_PROTOCOL_GUID;
>  	unsigned long nr_ugas;
>  	u64 *handles = (u64 *)uga_handle;;
> -	efi_status_t status;
> +	efi_status_t status = EFI_INVALID_PARAMETER;
>  	int i;
>  
>  	first_uga = NULL;

Can this ever happen in practice? This would imply that
locate_protocol() found EFI_UGA_PROTOCOL_GUID but that the size
returned is utterly bogus?

If so, I have no problem applying the patch but want to make sure
we're not tricking ourselves into thinking we're being protected from
something when we're not.

[toc] | [next] | [standalone]


#1451322

FromColin Ian King <colin.king@canonical.com>
Date2016-07-27 17:00 +0200
Message-ID<rZytr-Js-9@gated-at.bofh.it>
In reply to#1451308
On 27/07/16 15:38, Matt Fleming wrote:
> On Wed, 20 Jul, at 11:11:06AM, Colin Ian King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Although very unlikey, if size is too small or zero, then we end up with
>> status not being set and returning garbage. Instead, initializing status to
>> EFI_INVALID_PARAMETER to indicate that size is invalid in the calls to
>> setup_uga32 and setup_uga64.
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>  arch/x86/boot/compressed/eboot.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
>> index ff574da..ec6d2ef 100644
>> --- a/arch/x86/boot/compressed/eboot.c
>> +++ b/arch/x86/boot/compressed/eboot.c
>> @@ -578,7 +578,7 @@ setup_uga32(void **uga_handle, unsigned long size, u32 *width, u32 *height)
>>  	efi_guid_t uga_proto = EFI_UGA_PROTOCOL_GUID;
>>  	unsigned long nr_ugas;
>>  	u32 *handles = (u32 *)uga_handle;;
>> -	efi_status_t status;
>> +	efi_status_t status = EFI_INVALID_PARAMETER;
>>  	int i;
>>  
>>  	first_uga = NULL;
>> @@ -623,7 +623,7 @@ setup_uga64(void **uga_handle, unsigned long size, u32 *width, u32 *height)
>>  	efi_guid_t uga_proto = EFI_UGA_PROTOCOL_GUID;
>>  	unsigned long nr_ugas;
>>  	u64 *handles = (u64 *)uga_handle;;
>> -	efi_status_t status;
>> +	efi_status_t status = EFI_INVALID_PARAMETER;
>>  	int i;
>>  
>>  	first_uga = NULL;
> 
> Can this ever happen in practice? This would imply that
> locate_protocol() found EFI_UGA_PROTOCOL_GUID but that the size
> returned is utterly bogus?

I just wanted to guard against the call
efi_call_early(locate_handle, EFI_LOCATE_BY_PROTOCOL, &uga_proto, NULL,
&size, uga_handle) returning a bogus size of less than a u32/u64
(depending on the setup_uga32/setup_uga64), which I was not 100% sure if
this could happen or not, so I always assume efi_call_early calls can go
wrong when you least expect them.

> 
> If so, I have no problem applying the patch but want to make sure
> we're not tricking ourselves into thinking we're being protected from
> something when we're not.
> 

I'd rather put extra guarding in rather than getting some potential
garbage return from the stack, but I am playing it rather conservatively
here.

Colin

[toc] | [prev] | [next] | [standalone]


#1453160

FromMatt Fleming <matt@codeblueprint.co.uk>
Date2016-08-01 14:00 +0200
Message-ID<s1k2Z-5PD-5@gated-at.bofh.it>
In reply to#1451322
On Wed, 27 Jul, at 03:50:16PM, Colin Ian King wrote:
> 
> I'd rather put extra guarding in rather than getting some potential
> garbage return from the stack, but I am playing it rather conservatively
> here.

I think that's sensible, I just wanted to confirm your rationale.

Thanks, applied.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web