All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] efi_loader: loosen buffer parameter check in efi_file_read_int
@ 2021-04-28  8:15 Peng Fan
  2021-04-28 12:22 ` Peter Robinson
  2021-04-28 12:49 ` Heinrich Schuchardt
  0 siblings, 2 replies; 4+ messages in thread
From: Peng Fan @ 2021-04-28  8:15 UTC (permalink / raw)
  To: u-boot

From: Peng Fan <peng.fan@nxp.com>

This is same issue as https://bugzilla.redhat.com/show_bug.cgi?id=1733817,
but that fix was wrongly partial reverted.

To Fedora shim loader, when buffer is NULL, a use-case is to call
efi_file_read with *buffer_size=0 and buffer=NULL to obtain the needed
size before doing the actual read.

Otherwise, we always met "Could not read \EFI\: Invalid Parameter"

Fixes: db12f518edb0("efi_loader: implement non-blocking file services")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Stefan S?rensen <stefan.sorensen@spectralink.com>
---
 lib/efi_loader/efi_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c
index 204105e25a..6b3f5962be 100644
--- a/lib/efi_loader/efi_file.c
+++ b/lib/efi_loader/efi_file.c
@@ -554,7 +554,7 @@ static efi_status_t efi_file_read_int(struct efi_file_handle *this,
 	efi_status_t ret = EFI_SUCCESS;
 	u64 bs;
 
-	if (!this || !buffer_size || !buffer)
+	if (!this || !buffer_size)
 		return EFI_INVALID_PARAMETER;
 
 	bs = *buffer_size;
-- 
2.30.0

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

* [PATCH] efi_loader: loosen buffer parameter check in efi_file_read_int
  2021-04-28  8:15 [PATCH] efi_loader: loosen buffer parameter check in efi_file_read_int Peng Fan
@ 2021-04-28 12:22 ` Peter Robinson
  2021-04-28 12:49 ` Heinrich Schuchardt
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Robinson @ 2021-04-28 12:22 UTC (permalink / raw)
  To: u-boot

On Wed, Apr 28, 2021 at 8:43 AM Peng Fan (OSS) <peng.fan@oss.nxp.com> wrote:
>
> From: Peng Fan <peng.fan@nxp.com>
>
> This is same issue as https://bugzilla.redhat.com/show_bug.cgi?id=1733817,
> but that fix was wrongly partial reverted.
>
> To Fedora shim loader, when buffer is NULL, a use-case is to call
> efi_file_read with *buffer_size=0 and buffer=NULL to obtain the needed
> size before doing the actual read.
>
> Otherwise, we always met "Could not read \EFI\: Invalid Parameter"
>
> Fixes: db12f518edb0("efi_loader: implement non-blocking file services")
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Cc: Stefan S?rensen <stefan.sorensen@spectralink.com>

Tested-by: Peter Robinson <pbrobinson@gmail.com>

Tested on a patched 2021.04 with Fedora 34. Thanks!

> ---
>  lib/efi_loader/efi_file.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c
> index 204105e25a..6b3f5962be 100644
> --- a/lib/efi_loader/efi_file.c
> +++ b/lib/efi_loader/efi_file.c
> @@ -554,7 +554,7 @@ static efi_status_t efi_file_read_int(struct efi_file_handle *this,
>         efi_status_t ret = EFI_SUCCESS;
>         u64 bs;
>
> -       if (!this || !buffer_size || !buffer)
> +       if (!this || !buffer_size)
>                 return EFI_INVALID_PARAMETER;
>
>         bs = *buffer_size;
> --
> 2.30.0
>

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

* [PATCH] efi_loader: loosen buffer parameter check in efi_file_read_int
  2021-04-28  8:15 [PATCH] efi_loader: loosen buffer parameter check in efi_file_read_int Peng Fan
  2021-04-28 12:22 ` Peter Robinson
@ 2021-04-28 12:49 ` Heinrich Schuchardt
  2021-04-28 13:02   ` Heinrich Schuchardt
  1 sibling, 1 reply; 4+ messages in thread
From: Heinrich Schuchardt @ 2021-04-28 12:49 UTC (permalink / raw)
  To: u-boot

On 28.04.21 10:15, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> This is same issue as https://bugzilla.redhat.com/show_bug.cgi?id=1733817,
> but that fix was wrongly partial reverted.
>
> To Fedora shim loader, when buffer is NULL, a use-case is to call
> efi_file_read with *buffer_size=0 and buffer=NULL to obtain the needed
> size before doing the actual read.
>
> Otherwise, we always met "Could not read \EFI\: Invalid Parameter"

The EFI specification does not require this behavior. EDK II does not
implement it either. See for instance SemihostFileRead(),
FvSimpleFileSystemRead().

To determine the file size you have to use GetInfo(). Please, fix the
client code.

Best regards

Heinrich

>
> Fixes: db12f518edb0("efi_loader: implement non-blocking file services")
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Cc: Stefan S?rensen <stefan.sorensen@spectralink.com>
> ---
>  lib/efi_loader/efi_file.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c
> index 204105e25a..6b3f5962be 100644
> --- a/lib/efi_loader/efi_file.c
> +++ b/lib/efi_loader/efi_file.c
> @@ -554,7 +554,7 @@ static efi_status_t efi_file_read_int(struct efi_file_handle *this,
>  	efi_status_t ret = EFI_SUCCESS;
>  	u64 bs;
>
> -	if (!this || !buffer_size || !buffer)
> +	if (!this || !buffer_size)
>  		return EFI_INVALID_PARAMETER;
>
>  	bs = *buffer_size;
>

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

* [PATCH] efi_loader: loosen buffer parameter check in efi_file_read_int
  2021-04-28 12:49 ` Heinrich Schuchardt
@ 2021-04-28 13:02   ` Heinrich Schuchardt
  0 siblings, 0 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2021-04-28 13:02 UTC (permalink / raw)
  To: u-boot

On 28.04.21 14:49, Heinrich Schuchardt wrote:
> On 28.04.21 10:15, Peng Fan (OSS) wrote:
>> From: Peng Fan <peng.fan@nxp.com>
>>
>> This is same issue as https://bugzilla.redhat.com/show_bug.cgi?id=1733817,
>> but that fix was wrongly partial reverted.
>>
>> To Fedora shim loader, when buffer is NULL, a use-case is to call
>> efi_file_read with *buffer_size=0 and buffer=NULL to obtain the needed

An EFI binary cannot directly call efi_file_read(). It calls
EFI_FILE_PROTOCOL.Read().

>> size before doing the actual read.
>>
>> Otherwise, we always met "Could not read \EFI\: Invalid Parameter"

Please, describe the problem in UEFI terms.

>
> The EFI specification does not require this behavior. EDK II does not
> implement it either. See for instance SemihostFileRead(),
> FvSimpleFileSystemRead().
>
> To determine the file size you have to use GetInfo(). Please, fix the
> client code.
>
> Best regards
>
> Heinrich

Please, make it clear in the commit message, please, that this patch is
about reading a *directory entry* and not about reading a file.

Best regards

Heinrich

>
>>
>> Fixes: db12f518edb0("efi_loader: implement non-blocking file services")
>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
>> Cc: Stefan S?rensen <stefan.sorensen@spectralink.com>
>> ---
>>  lib/efi_loader/efi_file.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c
>> index 204105e25a..6b3f5962be 100644
>> --- a/lib/efi_loader/efi_file.c
>> +++ b/lib/efi_loader/efi_file.c
>> @@ -554,7 +554,7 @@ static efi_status_t efi_file_read_int(struct efi_file_handle *this,
>>  	efi_status_t ret = EFI_SUCCESS;
>>  	u64 bs;
>>
>> -	if (!this || !buffer_size || !buffer)
>> +	if (!this || !buffer_size)
>>  		return EFI_INVALID_PARAMETER;
>>
>>  	bs = *buffer_size;
>>
>

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

end of thread, other threads:[~2021-04-28 13:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-28  8:15 [PATCH] efi_loader: loosen buffer parameter check in efi_file_read_int Peng Fan
2021-04-28 12:22 ` Peter Robinson
2021-04-28 12:49 ` Heinrich Schuchardt
2021-04-28 13:02   ` Heinrich Schuchardt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.