efi_loader: variable: attributes may not be changed if a variable exists
PATCH 1/1 efi_loader: variable: attributes may not be changed if a variable exists
If a variable already exists, efi_set_variable() should not change the variable's attributes. This patch enforces it.
--- lib/efi_loader/efi_variable.c | 9 +++++++++ 1 file changed, 9 insertions(+)
lib/efi_loader/efi_variable.c +9 -0
@@ -450,6 +450,15 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name, ret =EFI_WRITE_PROTECTED ; goto out; } + +/* +* attributes won't be changed +* TODO: take care of APPEND_WRITE once supported +*/ +if (attr != attributes) { + ret =EFI_INVALID_PARAMETER ; + goto out; + } } val =malloc (2 * data_size +strlen ("{ro,run,boot}(blob)" ) +1 );
Signature · 1 line
2.21.0
PATCH 1/1 efi_loader: variable: attributes may not be changed if a variable exists
Quoted 2 lines · AKASHI Takahiro
If a variable already exists,
efi_set_variable()should not change the variable's attributes. This patch enforces it.
This behavior is mandated by UEFI spec 2.7.
Quoted 27 lines
Signed-off-by AKASHI Takahiro <[email protected]>--- lib/efi_loader/efi_variable.c | 9 +++++++++ 1 file changed, 9 insertions(+)lib/efi_loader/efi_variable.c +9
-0@@ -450,6 +450,15 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name, ret =EFI_WRITE_PROTECTED ; goto out; } + +/* +* attributes won't be changed +* TODO: take care of APPEND_WRITE once supported +*/ +if (attr != attributes) { + ret =EFI_INVALID_PARAMETER ; + goto out; + } } val =malloc (2 * data_size +strlen ("{ro,run,boot}(blob)" ) +1 );
PATCH 1/1 efi_loader: variable: attributes may not be changed if a variable exists
Quoted 7 lines · Heinrich Schuchardt
Quoted 2 lines · AKASHI Takahiro
If a variable already exists,
efi_set_variable()should not change the variable's attributes. This patch enforces it.This behavior is mandated by UEFI spec 2.7.
Reviewed-by Heinrich Schuchardt <[email protected]>
This patch let's bootefi selftestfail:
Executing 'variables'
lib/efi_selftest/efi_selftest_variables.c(60):
TODO: QueryVariableInfo failed
lib/efi_selftest/efi_selftest_variables.c(119):
ERROR: SetVariable failed
lib/efi_selftest/efi_selftest.c(110):
ERROR: Executing 'variables' failed
The preferred solution would be to implement APPEND_WRITE.
Otherwise at least adjust the unit test concerning APPEND_WRITE to use efi_st_todo() and not to abort the test.
I suggest that you always run bootefi selftest before submitting changes to the UEFI sub-system.
Best regards
Heinrich
Quoted 32 lines
Quoted 30 lines
Signed-off-by AKASHI Takahiro <[email protected]>---
lib/efi_loader/efi_variable.c| 9 +++++++++1 file changed, 9 insertions(+)lib/efi_loader/efi_variable.c +9
-0@@ -450,6 +450,15 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name, ret = EFI_WRITE_PROTECTED; goto out; } + + /* + * attributes won't be changed + * TODO: take care of APPEND_WRITE once supported + */ + if (attr != attributes) { + ret = EFI_INVALID_PARAMETER; + goto out; + } }val =
malloc(2 * data_size + strlen("{ro,run,boot}(blob)") + 1);
PATCH 1/1 efi_loader: variable: attributes may not be changed if a variable exists
Quoted 19 lines · Heinrich Schuchardt
Quoted 7 lines · Heinrich Schuchardt
Quoted 2 lines · AKASHI Takahiro
If a variable already exists,
efi_set_variable()should not change the variable's attributes. This patch enforces it.This behavior is mandated by UEFI spec 2.7.
Reviewed-by Heinrich Schuchardt <[email protected]>This patch let's
bootefi selftestfail:Executing 'variables'
lib/efi_selftest/efi_selftest_variables.c(60):
TODO: QueryVariableInfo failed
lib/efi_selftest/efi_selftest_variables.c(119):
ERROR: SetVariable failed
lib/efi_selftest/efi_selftest.c(110):
ERROR: Executing 'variables' failed
Quoted 4 lines
The preferred solution would be to implement
APPEND_WRITE.Otherwise at least adjust the unit test concerning
APPEND_WRITEto useefi_st_todo()and not to abort the test.
Since the current code doesn't supoort APPEND_WRITE, my commit doesn't break anything. You should fix selftest first.
I don't have an immediate plan to implement APPEND_WRITE for now.
-Takahiro Akashi
Quoted 40 lines
I suggest that you always run
bootefi selftestbefore submitting changes to the UEFI sub-system.Best regards
Heinrich
Quoted 32 lines
Quoted 30 lines
Signed-off-by AKASHI Takahiro <[email protected]>---
lib/efi_loader/efi_variable.c| 9 +++++++++1 file changed, 9 insertions(+)lib/efi_loader/efi_variable.c +9
-0@@ -450,6 +450,15 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name, ret = EFI_WRITE_PROTECTED; goto out; } + + /* + * attributes won't be changed + * TODO: take care of APPEND_WRITE once supported + */ + if (attr != attributes) { + ret = EFI_INVALID_PARAMETER; + goto out; + } }val =
malloc(2 * data_size + strlen("{ro,run,boot}(blob)") + 1);
PATCH 1/1 efi_loader: variable: attributes may not be changed if a variable exists
Quoted 56 lines · AKASHI Takahiro
Quoted 19 lines · Heinrich Schuchardt
Quoted 7 lines · Heinrich Schuchardt
Quoted 2 lines · AKASHI Takahiro
If a variable already exists,
efi_set_variable()should not change the variable's attributes. This patch enforces it.This behavior is mandated by UEFI spec 2.7.
Reviewed-by Heinrich Schuchardt <[email protected]>This patch let's
bootefi selftestfail:Executing 'variables'
lib/efi_selftest/efi_selftest_variables.c(60):
TODO: QueryVariableInfo failed
lib/efi_selftest/efi_selftest_variables.c(119):
ERROR: SetVariable failed
lib/efi_selftest/efi_selftest.c(110):
ERROR: Executing 'variables' failedQuoted 4 lines
The preferred solution would be to implement
APPEND_WRITE.Otherwise at least adjust the unit test concerning
APPEND_WRITEto useefi_st_todo()and not to abort the test.Since the current code doesn't supoort
APPEND_WRITE, my commit doesn't break anything. You should fix selftest first.I don't have an immediate plan to implement
APPEND_WRITEfor now.-Takahiro Akashi
Quoted 24 lines
I suggest that you always run
bootefi selftestbefore submitting changes to the UEFI sub-system.Best regards
Heinrich
Quoted 17 lines
Quoted 17 lines
Signed-off-by AKASHI Takahiro <[email protected]>---
lib/efi_loader/efi_variable.c| 9 +++++++++1 file changed, 9 insertions(+)lib/efi_loader/efi_variable.c +0
-0@@ -450,6 +450,15 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name, ret = EFI_WRITE_PROTECTED; goto out; }
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lib/efi_loader/efi_variable.c efi_status_t EFIAPI efi_set_variable(u16 · line 461
Quoted 8 lines
lib/efi_loader/efi_variable.c +8
-0+ + /* + * attributes won't be changed + * TODO: take care of APPEND_WRITE once supported + */ + if (attr != attributes) { + ret = EFI_INVALID_PARAMETER; + goto out;
You are freeing val. But this value was not allocated by you.
I saw this with bootefi selftest after applying
(quoted diff) +0 -0
b/lib/efi_selftest/efi_selftest_variables.c
index b028c64bbc..e8346d0d4a 100644
lib/efi_selftest/efi_selftest_variables.c +2 -4
@@ -115,10 +115,8 @@ static int execute(void)EFI_VARIABLE_BOOTSERVICE_ACCESS |EFI_VARIABLE_APPEND_WRITE , 7, v + 8); -if (ret !=EFI_SUCCESS ) { -efi_st_error ("SetVariable failed\n" ); -return EFI_ST_FAILURE ; - } +if (ret !=EFI_SUCCESS ) +efi_st_todo ("SetVariable: append failed\n" ); len =EFI_ST_MAX_DATA_SIZE ; ret = runtime->get_variable (L"efi_st_var1" , &guid_vendor1, &attr, &len, data);
Please, run (and if necessary adjust) unit tests before submitting patches.
Best regards
Heinrich
Quoted 9 lines
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
lib/efi_loader/efi_variable.c +1
-0+ } }val =
malloc(2 * data_size + strlen("{ro,run,boot}(blob)") + 1);