diff mbox series

efi_loader: Add absolute path to EFI_VAR_FILE_NAME

Message ID 20240320113051.1.If084ef69b9da34900391d0f0acc13475b250ce9f@changeid
State Rejected, archived
Delegated to: Heinrich Schuchardt
Headers show
Series efi_loader: Add absolute path to EFI_VAR_FILE_NAME | expand

Commit Message

Patrice CHOTARD March 20, 2024, 10:31 a.m. UTC
If the ESP partition is formatted in ext4, we got the following error :

STM32MP>  setenv -e -nv -bs -rt -v OsIndications =0x0000000000000004
GUID: 8be4df61-93ca-11d2-aa0d-00e098032b8c (EFI_GLOBAL_VARIABLE_GUID)
Attributes: 0x7
Value:
    00000000: 04 00 00 00 00 00 00 00                          ........
File System is consistent
Please supply Absolute path
** Error ext4fs_write() **
** Unable to write file ubootefi.var **
Failed to persist EFI variables

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
---

 include/efi_variable.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ilias Apalodimas March 20, 2024, 11:53 a.m. UTC | #1
Hi Patrice,

On Wed, 20 Mar 2024 at 12:31, Patrice Chotard
<patrice.chotard@foss.st.com> wrote:
>
> If the ESP partition is formatted in ext4, we got the following error :
>
> STM32MP>  setenv -e -nv -bs -rt -v OsIndications =0x0000000000000004
> GUID: 8be4df61-93ca-11d2-aa0d-00e098032b8c (EFI_GLOBAL_VARIABLE_GUID)
> Attributes: 0x7
> Value:
>     00000000: 04 00 00 00 00 00 00 00                          ........
> File System is consistent
> Please supply Absolute path

This error message comes from ext4_common.c and it's ext4 specific. Do
you have any idea why this exists?
What happens to other filesystems? IOW does this change the behavior
of the existing code if it tries to write a file in FAT?

Thanks
/Ilias

> ** Error ext4fs_write() **
> ** Unable to write file ubootefi.var **
> Failed to persist EFI variables
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> ---
>
>  include/efi_variable.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/efi_variable.h b/include/efi_variable.h
> index 805e6c5f1e0..8d507460b20 100644
> --- a/include/efi_variable.h
> +++ b/include/efi_variable.h
> @@ -92,7 +92,7 @@ efi_status_t efi_query_variable_info_int(u32 attributes,
>                                          u64 *remaining_variable_storage_size,
>                                          u64 *maximum_variable_size);
>
> -#define EFI_VAR_FILE_NAME "ubootefi.var"
> +#define EFI_VAR_FILE_NAME "/ubootefi.var"
>
>  #define EFI_VAR_BUF_SIZE CONFIG_EFI_VAR_BUF_SIZE
>
> --
> 2.25.1
>
Heinrich Schuchardt March 20, 2024, 1:05 p.m. UTC | #2
On 20.03.24 12:53, Ilias Apalodimas wrote:
> Hi Patrice,
>
> On Wed, 20 Mar 2024 at 12:31, Patrice Chotard
> <patrice.chotard@foss.st.com> wrote:
>>
>> If the ESP partition is formatted in ext4, we got the following error :
>>
>> STM32MP>  setenv -e -nv -bs -rt -v OsIndications =0x0000000000000004
>> GUID: 8be4df61-93ca-11d2-aa0d-00e098032b8c (EFI_GLOBAL_VARIABLE_GUID)
>> Attributes: 0x7
>> Value:
>>      00000000: 04 00 00 00 00 00 00 00                          ........
>> File System is consistent
>> Please supply Absolute path
>
> This error message comes from ext4_common.c and it's ext4 specific. Do
> you have any idea why this exists?
> What happens to other filesystems? IOW does this change the behavior
> of the existing code if it tries to write a file in FAT?

When reading a file with the ext4 driver leading '/' are ignored by
removing them in ext4fs_find_file1(). It is really inconsistent that
when writing a leading '/' is required.

We can simply remove the check in ext4fs_get_parent_inode_num(). I found
no issues when saving to an ext4 file system with the check removed.

I will send a patch.

Best regards

Heinrich

>
> Thanks
> /Ilias
>
>> ** Error ext4fs_write() **
>> ** Unable to write file ubootefi.var **
>> Failed to persist EFI variables
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>> ---
>>
>>   include/efi_variable.h | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/include/efi_variable.h b/include/efi_variable.h
>> index 805e6c5f1e0..8d507460b20 100644
>> --- a/include/efi_variable.h
>> +++ b/include/efi_variable.h
>> @@ -92,7 +92,7 @@ efi_status_t efi_query_variable_info_int(u32 attributes,
>>                                           u64 *remaining_variable_storage_size,
>>                                           u64 *maximum_variable_size);
>>
>> -#define EFI_VAR_FILE_NAME "ubootefi.var"
>> +#define EFI_VAR_FILE_NAME "/ubootefi.var"
>>
>>   #define EFI_VAR_BUF_SIZE CONFIG_EFI_VAR_BUF_SIZE
>>
>> --
>> 2.25.1
>>
Patrice CHOTARD March 20, 2024, 4:32 p.m. UTC | #3
On 3/20/24 12:53, Ilias Apalodimas wrote:
> Hi Patrice,
> 
> On Wed, 20 Mar 2024 at 12:31, Patrice Chotard
> <patrice.chotard@foss.st.com> wrote:
>>
>> If the ESP partition is formatted in ext4, we got the following error :
>>
>> STM32MP>  setenv -e -nv -bs -rt -v OsIndications =0x0000000000000004
>> GUID: 8be4df61-93ca-11d2-aa0d-00e098032b8c (EFI_GLOBAL_VARIABLE_GUID)
>> Attributes: 0x7
>> Value:
>>     00000000: 04 00 00 00 00 00 00 00                          ........
>> File System is consistent
>> Please supply Absolute path
> 
> This error message comes from ext4_common.c and it's ext4 specific. Do
> you have any idea why this exists?
> What happens to other filesystems? IOW does this change the behavior
> of the existing code if it tries to write a file in FAT?

I made a try in FAT with this patch, and there is no issue.

Thanks
Patrice

> 
> Thanks
> /Ilias
> 
>> ** Error ext4fs_write() **
>> ** Unable to write file ubootefi.var **
>> Failed to persist EFI variables
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>> ---
>>
>>  include/efi_variable.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/include/efi_variable.h b/include/efi_variable.h
>> index 805e6c5f1e0..8d507460b20 100644
>> --- a/include/efi_variable.h
>> +++ b/include/efi_variable.h
>> @@ -92,7 +92,7 @@ efi_status_t efi_query_variable_info_int(u32 attributes,
>>                                          u64 *remaining_variable_storage_size,
>>                                          u64 *maximum_variable_size);
>>
>> -#define EFI_VAR_FILE_NAME "ubootefi.var"
>> +#define EFI_VAR_FILE_NAME "/ubootefi.var"
>>
>>  #define EFI_VAR_BUF_SIZE CONFIG_EFI_VAR_BUF_SIZE
>>
>> --
>> 2.25.1
>>
Patrice CHOTARD March 20, 2024, 4:32 p.m. UTC | #4
On 3/20/24 14:05, Heinrich Schuchardt wrote:
> On 20.03.24 12:53, Ilias Apalodimas wrote:
>> Hi Patrice,
>>
>> On Wed, 20 Mar 2024 at 12:31, Patrice Chotard
>> <patrice.chotard@foss.st.com> wrote:
>>>
>>> If the ESP partition is formatted in ext4, we got the following error :
>>>
>>> STM32MP>  setenv -e -nv -bs -rt -v OsIndications =0x0000000000000004
>>> GUID: 8be4df61-93ca-11d2-aa0d-00e098032b8c (EFI_GLOBAL_VARIABLE_GUID)
>>> Attributes: 0x7
>>> Value:
>>>      00000000: 04 00 00 00 00 00 00 00                          ........
>>> File System is consistent
>>> Please supply Absolute path
>>
>> This error message comes from ext4_common.c and it's ext4 specific. Do
>> you have any idea why this exists?
>> What happens to other filesystems? IOW does this change the behavior
>> of the existing code if it tries to write a file in FAT?
> 
> When reading a file with the ext4 driver leading '/' are ignored by
> removing them in ext4fs_find_file1(). It is really inconsistent that
> when writing a leading '/' is required.
> 
> We can simply remove the check in ext4fs_get_parent_inode_num(). I found
> no issues when saving to an ext4 file system with the check removed.
> 
> I will send a patch.

Ok thanks ;-)

> 
> Best regards
> 
> Heinrich
> 
>>
>> Thanks
>> /Ilias
>>
>>> ** Error ext4fs_write() **
>>> ** Unable to write file ubootefi.var **
>>> Failed to persist EFI variables
>>>
>>> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>>> ---
>>>
>>>   include/efi_variable.h | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/include/efi_variable.h b/include/efi_variable.h
>>> index 805e6c5f1e0..8d507460b20 100644
>>> --- a/include/efi_variable.h
>>> +++ b/include/efi_variable.h
>>> @@ -92,7 +92,7 @@ efi_status_t efi_query_variable_info_int(u32 attributes,
>>>                                           u64 *remaining_variable_storage_size,
>>>                                           u64 *maximum_variable_size);
>>>
>>> -#define EFI_VAR_FILE_NAME "ubootefi.var"
>>> +#define EFI_VAR_FILE_NAME "/ubootefi.var"
>>>
>>>   #define EFI_VAR_BUF_SIZE CONFIG_EFI_VAR_BUF_SIZE
>>>
>>> -- 
>>> 2.25.1
>>>
>
diff mbox series

Patch

diff --git a/include/efi_variable.h b/include/efi_variable.h
index 805e6c5f1e0..8d507460b20 100644
--- a/include/efi_variable.h
+++ b/include/efi_variable.h
@@ -92,7 +92,7 @@  efi_status_t efi_query_variable_info_int(u32 attributes,
 					 u64 *remaining_variable_storage_size,
 					 u64 *maximum_variable_size);
 
-#define EFI_VAR_FILE_NAME "ubootefi.var"
+#define EFI_VAR_FILE_NAME "/ubootefi.var"
 
 #define EFI_VAR_BUF_SIZE CONFIG_EFI_VAR_BUF_SIZE