* [PATCH 0/2] efi: fix and verify variables append_write
@ 2026-11-13 15:07 Vincent Stehlé
2026-11-13 15:07 ` [PATCH 1/2] efi_loader: prevent set_variable() to record append_write Vincent Stehlé
2026-11-13 15:07 ` [PATCH 2/2] efi_selftest: verify get_variable() never returns append_write Vincent Stehlé
0 siblings, 2 replies; 8+ messages in thread
From: Vincent Stehlé @ 2026-11-13 15:07 UTC (permalink / raw)
To: u-boot; +Cc: Heinrich Schuchardt, Ilias Apalodimas, Tom Rini,
Vincent Stehlé
This couple of patches does the following:
- Fix a corner case of the non-TEE SetVariable(), which could record the
APPEND_WRITE attribute when appending to non-existing variables.
- Enhance the existing selftest to verify that the APPEND_WRITE attribute
is never returned by GetVariable().
See the second patch for the details to run on the sandbox.
I have also verified that the selftest changes do not harm with OP-TEE +
StMM. (This hits other issues with QueryVariableInfo() but they are
unrelated.)
We could reasonably reduce the test to verify the attributes only in the
cases where GetVariable() follows a SetVariable() with the append attribute
set, as those are arguably more likely to be buggy.
If this is preferred just let me know and I will send a v2.
Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
---
Vincent Stehlé (2):
efi_loader: prevent set_variable() to record append_write
efi_selftest: verify get_variable() never returns append_write
lib/efi_loader/efi_variable.c | 3 ++-
lib/efi_selftest/efi_selftest_variables.c | 17 ++++++++++++++++-
2 files changed, 18 insertions(+), 2 deletions(-)
---
base-commit: ff8a9bc41e4e5bdd3406932af5abb4c18064e539
change-id: 20261113-append-1cfc64c0e0d8
Best regards,
--
Vincent.
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 1/2] efi_loader: prevent set_variable() to record append_write 2026-11-13 15:07 [PATCH 0/2] efi: fix and verify variables append_write Vincent Stehlé @ 2026-11-13 15:07 ` Vincent Stehlé 2026-11-22 11:55 ` Heinrich Schuchardt 2026-11-13 15:07 ` [PATCH 2/2] efi_selftest: verify get_variable() never returns append_write Vincent Stehlé 1 sibling, 1 reply; 8+ messages in thread From: Vincent Stehlé @ 2026-11-13 15:07 UTC (permalink / raw) To: u-boot; +Cc: Heinrich Schuchardt, Ilias Apalodimas, Tom Rini, Vincent Stehlé If SetVariable() records the Attributes bitmask with the EFI_VARIABLE_APPEND_WRITE attribute set, this attribute can be returned later on by GetVariable(), while this is forbidden by the UEFI specification. [1] While the non-TEE SetVariable() already makes sure not to record the attribute when appending to an existing variable, it forgets to do so when appending to a non-existing variable; fix it. Link: https://uefi.org/specs/UEFI/2.11/08_Services_Runtime_Services.html#getvariable [1] Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Cc: Tom Rini <trini@konsulko.com> --- lib/efi_loader/efi_variable.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index 9923936c1b5..8bf2c91f3f9 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -384,7 +384,8 @@ efi_status_t efi_set_variable_int(const u16 *variable_name, var->length, old_data, data_size, data, time, &changed); } else { - ret = efi_var_mem_ins(variable_name, vendor, attributes, + ret = efi_var_mem_ins(variable_name, vendor, + attributes & ~EFI_VARIABLE_APPEND_WRITE, data_size, data, 0, NULL, time, &changed); } -- 2.53.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] efi_loader: prevent set_variable() to record append_write 2026-11-13 15:07 ` [PATCH 1/2] efi_loader: prevent set_variable() to record append_write Vincent Stehlé @ 2026-11-22 11:55 ` Heinrich Schuchardt 2026-11-24 8:48 ` Vincent Stehlé 0 siblings, 1 reply; 8+ messages in thread From: Heinrich Schuchardt @ 2026-11-22 11:55 UTC (permalink / raw) To: Vincent Stehlé; +Cc: Ilias Apalodimas, Tom Rini, u-boot On 11/13/26 16:07, Vincent Stehlé wrote: > If SetVariable() records the Attributes bitmask with the > EFI_VARIABLE_APPEND_WRITE attribute set, this attribute can be returned > later on by GetVariable(), while this is forbidden by the UEFI > specification. [1] > > While the non-TEE SetVariable() already makes sure not to record the > attribute when appending to an existing variable, it forgets to do so when > appending to a non-existing variable; fix it. > > Link: https://uefi.org/specs/UEFI/2.11/08_Services_Runtime_Services.html#getvariable [1] > Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com> > Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> > Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> > Cc: Tom Rini <trini@konsulko.com> > --- > lib/efi_loader/efi_variable.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c > index 9923936c1b5..8bf2c91f3f9 100644 > --- a/lib/efi_loader/efi_variable.c > +++ b/lib/efi_loader/efi_variable.c > @@ -384,7 +384,8 @@ efi_status_t efi_set_variable_int(const u16 *variable_name, > var->length, old_data, data_size, data, > time, &changed); > } else { > - ret = efi_var_mem_ins(variable_name, vendor, attributes, > + ret = efi_var_mem_ins(variable_name, vendor, > + attributes & ~EFI_VARIABLE_APPEND_WRITE, Hello Vincent, Thank you for detecting this bug. If the variable does not exists yet (var == NULL) and data is provided (data_size > 0), you still end up passing around EFI_VARIABLE_APPEND_WRITE in unsolicited ways. Should we remove the flag from `attributes` directly after setting variable `append`? Best regards Heinrich > data_size, data, 0, NULL, time, > &changed); > } > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] efi_loader: prevent set_variable() to record append_write 2026-11-22 11:55 ` Heinrich Schuchardt @ 2026-11-24 8:48 ` Vincent Stehlé 2026-11-24 9:53 ` Vincent Stehlé 0 siblings, 1 reply; 8+ messages in thread From: Vincent Stehlé @ 2026-11-24 8:48 UTC (permalink / raw) To: Heinrich Schuchardt; +Cc: Ilias Apalodimas, Tom Rini, u-boot On Sun, Nov 22, 2026 at 12:55:09PM +0100, Heinrich Schuchardt wrote: Hi Heinrich, Thanks for reviewing. My comments below; I will send a v2. Best regards, Vincent. > On 11/13/26 16:07, Vincent Stehlé wrote: > > If SetVariable() records the Attributes bitmask with the > > EFI_VARIABLE_APPEND_WRITE attribute set, this attribute can be returned > > later on by GetVariable(), while this is forbidden by the UEFI > > specification. [1] > > > > While the non-TEE SetVariable() already makes sure not to record the > > attribute when appending to an existing variable, it forgets to do so when > > appending to a non-existing variable; fix it. > > > > Link: https://uefi.org/specs/UEFI/2.11/08_Services_Runtime_Services.html#getvariable [1] > > Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com> > > Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> > > Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> > > Cc: Tom Rini <trini@konsulko.com> > > --- > > lib/efi_loader/efi_variable.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c > > index 9923936c1b5..8bf2c91f3f9 100644 > > --- a/lib/efi_loader/efi_variable.c > > +++ b/lib/efi_loader/efi_variable.c > > @@ -384,7 +384,8 @@ efi_status_t efi_set_variable_int(const u16 *variable_name, > > var->length, old_data, data_size, data, > > time, &changed); > > } else { > > - ret = efi_var_mem_ins(variable_name, vendor, attributes, > > + ret = efi_var_mem_ins(variable_name, vendor, > > + attributes & ~EFI_VARIABLE_APPEND_WRITE, > > Hello Vincent, > > Thank you for detecting this bug. > > If the variable does not exists yet (var == NULL) and data is provided > (data_size > 0), you still end up passing around EFI_VARIABLE_APPEND_WRITE > in unsolicited ways. At least we are sure now that the 'APPEND attribute does not re-surface from GetVariable() in this specific case. Is your concern that we risk passing the attribute to other internal functions, such as efi_variable_authenticate() maybe? > Should we remove the flag from `attributes` directly after setting variable > `append`? You are right, this is a better solution overall; I will send a v2. > > Best regards > > Heinrich > > > data_size, data, 0, NULL, time, > > &changed); > > } > > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] efi_loader: prevent set_variable() to record append_write 2026-11-24 8:48 ` Vincent Stehlé @ 2026-11-24 9:53 ` Vincent Stehlé 2026-11-24 10:10 ` Heinrich Schuchardt 0 siblings, 1 reply; 8+ messages in thread From: Vincent Stehlé @ 2026-11-24 9:53 UTC (permalink / raw) To: Heinrich Schuchardt; +Cc: Ilias Apalodimas, Tom Rini, u-boot On Tue, Nov 24, 2026 at 09:48:21AM +0100, Vincent Stehlé wrote: > On Sun, Nov 22, 2026 at 12:55:09PM +0100, Heinrich Schuchardt wrote: > > Hi Heinrich, > > Thanks for reviewing. My comments below; I will send a v2. On second thought: we do in fact need to pass all the attributes to efi_variable_authenticate(), including 'APPEND. We can thus not remove 'APPEND early in efi_set_variable_int(). I think you need to take the v1 as it is, please. (FWIW this is exercised by the python tests test_efi_var_auth3, test_efi_signed_image_auth5 and test_efi_signed_image_auth7.) Best regards, Vincent. > > Best regards, > Vincent. > > > On 11/13/26 16:07, Vincent Stehlé wrote: > > > If SetVariable() records the Attributes bitmask with the > > > EFI_VARIABLE_APPEND_WRITE attribute set, this attribute can be returned > > > later on by GetVariable(), while this is forbidden by the UEFI > > > specification. [1] > > > > > > While the non-TEE SetVariable() already makes sure not to record the > > > attribute when appending to an existing variable, it forgets to do so when > > > appending to a non-existing variable; fix it. > > > > > > Link: https://uefi.org/specs/UEFI/2.11/08_Services_Runtime_Services.html#getvariable [1] > > > Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com> > > > Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> > > > Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> > > > Cc: Tom Rini <trini@konsulko.com> > > > --- > > > lib/efi_loader/efi_variable.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c > > > index 9923936c1b5..8bf2c91f3f9 100644 > > > --- a/lib/efi_loader/efi_variable.c > > > +++ b/lib/efi_loader/efi_variable.c > > > @@ -384,7 +384,8 @@ efi_status_t efi_set_variable_int(const u16 *variable_name, > > > var->length, old_data, data_size, data, > > > time, &changed); > > > } else { > > > - ret = efi_var_mem_ins(variable_name, vendor, attributes, > > > + ret = efi_var_mem_ins(variable_name, vendor, > > > + attributes & ~EFI_VARIABLE_APPEND_WRITE, > > > > Hello Vincent, > > > > Thank you for detecting this bug. > > > > If the variable does not exists yet (var == NULL) and data is provided > > (data_size > 0), you still end up passing around EFI_VARIABLE_APPEND_WRITE > > in unsolicited ways. > > At least we are sure now that the 'APPEND attribute does not re-surface > from GetVariable() in this specific case. > Is your concern that we risk passing the attribute to other internal > functions, such as efi_variable_authenticate() maybe? > > > Should we remove the flag from `attributes` directly after setting variable > > `append`? > > You are right, this is a better solution overall; I will send a v2. > > > > > Best regards > > > > Heinrich > > > > > data_size, data, 0, NULL, time, > > > &changed); > > > } > > > > > -- Vincent. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] efi_loader: prevent set_variable() to record append_write 2026-11-24 9:53 ` Vincent Stehlé @ 2026-11-24 10:10 ` Heinrich Schuchardt 2026-11-24 10:41 ` Vincent Stehlé 0 siblings, 1 reply; 8+ messages in thread From: Heinrich Schuchardt @ 2026-11-24 10:10 UTC (permalink / raw) To: Vincent Stehlé; +Cc: Ilias Apalodimas, Tom Rini, u-boot On 11/24/26 10:53, Vincent Stehlé wrote: > On Tue, Nov 24, 2026 at 09:48:21AM +0100, Vincent Stehlé wrote: >> On Sun, Nov 22, 2026 at 12:55:09PM +0100, Heinrich Schuchardt wrote: >> >> Hi Heinrich, >> >> Thanks for reviewing. My comments below; I will send a v2. > > On second thought: we do in fact need to pass all the attributes to > efi_variable_authenticate(), including 'APPEND. We can thus not remove > 'APPEND early in efi_set_variable_int(). > > I think you need to take the v1 as it is, please. > > (FWIW this is exercised by the python tests test_efi_var_auth3, > test_efi_signed_image_auth5 and test_efi_signed_image_auth7.) Your are right in that efi_variable_authenticate() considers attributes in the signature check. How about EFI_VARIABLE_APPEND_WRITE in efi_set_variable_runtime()? Furthermore efi_set_variable_runtime() returns EFI_INVALID_PARAMETER for authenticated variables. I wonder if that is the correct value. Would EFI_SECURITY_VIOLATION be more adequate as we don't accept the variable for missing capability to check the signature? Best regards Heinrich > > Best regards, > Vincent. > >> >> Best regards, >> Vincent. >> >>> On 11/13/26 16:07, Vincent Stehlé wrote: >>>> If SetVariable() records the Attributes bitmask with the >>>> EFI_VARIABLE_APPEND_WRITE attribute set, this attribute can be returned >>>> later on by GetVariable(), while this is forbidden by the UEFI >>>> specification. [1] >>>> >>>> While the non-TEE SetVariable() already makes sure not to record the >>>> attribute when appending to an existing variable, it forgets to do so when >>>> appending to a non-existing variable; fix it. >>>> >>>> Link: https://uefi.org/specs/UEFI/2.11/08_Services_Runtime_Services.html#getvariable [1] >>>> Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com> >>>> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> >>>> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> >>>> Cc: Tom Rini <trini@konsulko.com> >>>> --- >>>> lib/efi_loader/efi_variable.c | 3 ++- >>>> 1 file changed, 2 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c >>>> index 9923936c1b5..8bf2c91f3f9 100644 >>>> --- a/lib/efi_loader/efi_variable.c >>>> +++ b/lib/efi_loader/efi_variable.c >>>> @@ -384,7 +384,8 @@ efi_status_t efi_set_variable_int(const u16 *variable_name, >>>> var->length, old_data, data_size, data, >>>> time, &changed); >>>> } else { >>>> - ret = efi_var_mem_ins(variable_name, vendor, attributes, >>>> + ret = efi_var_mem_ins(variable_name, vendor, >>>> + attributes & ~EFI_VARIABLE_APPEND_WRITE, >>> >>> Hello Vincent, >>> >>> Thank you for detecting this bug. >>> >>> If the variable does not exists yet (var == NULL) and data is provided >>> (data_size > 0), you still end up passing around EFI_VARIABLE_APPEND_WRITE >>> in unsolicited ways. >> >> At least we are sure now that the 'APPEND attribute does not re-surface >> from GetVariable() in this specific case. >> Is your concern that we risk passing the attribute to other internal >> functions, such as efi_variable_authenticate() maybe? >> >>> Should we remove the flag from `attributes` directly after setting variable >>> `append`? >> >> You are right, this is a better solution overall; I will send a v2. >> >>> >>> Best regards >>> >>> Heinrich >>> >>>> data_size, data, 0, NULL, time, >>>> &changed); >>>> } >>>> >>> > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] efi_loader: prevent set_variable() to record append_write 2026-11-24 10:10 ` Heinrich Schuchardt @ 2026-11-24 10:41 ` Vincent Stehlé 0 siblings, 0 replies; 8+ messages in thread From: Vincent Stehlé @ 2026-11-24 10:41 UTC (permalink / raw) To: Heinrich Schuchardt; +Cc: Ilias Apalodimas, Tom Rini, u-boot On Tue, Nov 24, 2026 at 11:10:53AM +0100, Heinrich Schuchardt wrote: > On 11/24/26 10:53, Vincent Stehlé wrote: > > On Tue, Nov 24, 2026 at 09:48:21AM +0100, Vincent Stehlé wrote: > > > On Sun, Nov 22, 2026 at 12:55:09PM +0100, Heinrich Schuchardt wrote: > > > > > > Hi Heinrich, > > > > > > Thanks for reviewing. My comments below; I will send a v2. > > > > On second thought: we do in fact need to pass all the attributes to > > efi_variable_authenticate(), including 'APPEND. We can thus not remove > > 'APPEND early in efi_set_variable_int(). > > > > I think you need to take the v1 as it is, please. > > > > (FWIW this is exercised by the python tests test_efi_var_auth3, > > test_efi_signed_image_auth5 and test_efi_signed_image_auth7.) > > Your are right in that efi_variable_authenticate() considers attributes in > the signature check. > > How about EFI_VARIABLE_APPEND_WRITE in efi_set_variable_runtime()? Hi Heinrich, In efi_set_variable_runtime(), the 'APPEND attribute is indeed cleared ASAP: 527 append = !!(attributes & EFI_VARIABLE_APPEND_WRITE); 528 attributes &= ~EFI_VARIABLE_APPEND_WRITE; This works here because authenticated variables are not supported at all as you mentioned. > Furthermore efi_set_variable_runtime() returns EFI_INVALID_PARAMETER for > authenticated variables. I wonder if that is the correct value. Would > EFI_SECURITY_VIOLATION be more adequate as we don't accept the variable for > missing capability to check the signature? It is indeed not easy to choose between "invalid parameter", "security violation" or even "unsupported". EDK II does seem to return "invalid parameter" in a similar situation. [1] Best regards, Vincent. [1] https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c?utm_source=chatgpt.com#L2675 > > Best regards > > Heinrich > > > > > Best regards, > > Vincent. > > > > > > > > Best regards, > > > Vincent. > > > > > > > On 11/13/26 16:07, Vincent Stehlé wrote: > > > > > If SetVariable() records the Attributes bitmask with the > > > > > EFI_VARIABLE_APPEND_WRITE attribute set, this attribute can be returned > > > > > later on by GetVariable(), while this is forbidden by the UEFI > > > > > specification. [1] > > > > > > > > > > While the non-TEE SetVariable() already makes sure not to record the > > > > > attribute when appending to an existing variable, it forgets to do so when > > > > > appending to a non-existing variable; fix it. > > > > > > > > > > Link: https://uefi.org/specs/UEFI/2.11/08_Services_Runtime_Services.html#getvariable [1] > > > > > Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com> > > > > > Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> > > > > > Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> > > > > > Cc: Tom Rini <trini@konsulko.com> > > > > > --- > > > > > lib/efi_loader/efi_variable.c | 3 ++- > > > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > > > > > diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c > > > > > index 9923936c1b5..8bf2c91f3f9 100644 > > > > > --- a/lib/efi_loader/efi_variable.c > > > > > +++ b/lib/efi_loader/efi_variable.c > > > > > @@ -384,7 +384,8 @@ efi_status_t efi_set_variable_int(const u16 *variable_name, > > > > > var->length, old_data, data_size, data, > > > > > time, &changed); > > > > > } else { > > > > > - ret = efi_var_mem_ins(variable_name, vendor, attributes, > > > > > + ret = efi_var_mem_ins(variable_name, vendor, > > > > > + attributes & ~EFI_VARIABLE_APPEND_WRITE, > > > > > > > > Hello Vincent, > > > > > > > > Thank you for detecting this bug. > > > > > > > > If the variable does not exists yet (var == NULL) and data is provided > > > > (data_size > 0), you still end up passing around EFI_VARIABLE_APPEND_WRITE > > > > in unsolicited ways. > > > > > > At least we are sure now that the 'APPEND attribute does not re-surface > > > from GetVariable() in this specific case. > > > Is your concern that we risk passing the attribute to other internal > > > functions, such as efi_variable_authenticate() maybe? > > > > > > > Should we remove the flag from `attributes` directly after setting variable > > > > `append`? > > > > > > You are right, this is a better solution overall; I will send a v2. > > > > > > > > > > > Best regards > > > > > > > > Heinrich > > > > > > > > > data_size, data, 0, NULL, time, > > > > > &changed); > > > > > } > > > > > > > > > > > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/2] efi_selftest: verify get_variable() never returns append_write 2026-11-13 15:07 [PATCH 0/2] efi: fix and verify variables append_write Vincent Stehlé 2026-11-13 15:07 ` [PATCH 1/2] efi_loader: prevent set_variable() to record append_write Vincent Stehlé @ 2026-11-13 15:07 ` Vincent Stehlé 1 sibling, 0 replies; 8+ messages in thread From: Vincent Stehlé @ 2026-11-13 15:07 UTC (permalink / raw) To: u-boot; +Cc: Heinrich Schuchardt, Ilias Apalodimas, Tom Rini, Vincent Stehlé Verify that EFI_VARIABLE_APPEND_WRITE is never set in the Attributes bitmask returned by GetVariable() when it succeeds. This can be run on the sandbox with the following command: ./u-boot -T -c 'setenv efi_selftest variables; bootefi selftest' Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Cc: Tom Rini <trini@konsulko.com> --- lib/efi_selftest/efi_selftest_variables.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/efi_selftest/efi_selftest_variables.c b/lib/efi_selftest/efi_selftest_variables.c index 976eee8dcef..35d6387009d 100644 --- a/lib/efi_selftest/efi_selftest_variables.c +++ b/lib/efi_selftest/efi_selftest_variables.c @@ -65,6 +65,10 @@ static int execute(void) efi_st_error("GetVariable wrote past the end of the buffer\n"); return EFI_ST_FAILURE; } + if (attr & EFI_VARIABLE_APPEND_WRITE) { + efi_st_error("APPEND_WRITE in returned attributes\n"); + return EFI_ST_FAILURE; + } /* Set variable 1 */ ret = st_runtime->set_variable(u"efi_st_var1", &guid_vendor1, EFI_VARIABLE_BOOTSERVICE_ACCESS, 8, v); @@ -88,6 +92,10 @@ static int execute(void) efi_st_error("GetVariable returned wrong value\n"); return EFI_ST_FAILURE; } + if (attr & EFI_VARIABLE_APPEND_WRITE) { + efi_st_error("APPEND_WRITE in returned attributes\n"); + return EFI_ST_FAILURE; + } /* Append variable 1 */ ret = st_runtime->set_variable(u"efi_st_var1", &guid_vendor1, EFI_VARIABLE_BOOTSERVICE_ACCESS | @@ -109,7 +117,10 @@ static int execute(void) (unsigned int)len); if (memcmp(data, v, len)) efi_st_todo("GetVariable returned wrong value\n"); - + if (attr & EFI_VARIABLE_APPEND_WRITE) { + efi_st_error("APPEND_WRITE in returned attributes\n"); + return EFI_ST_FAILURE; + } /* Append variable 2, write to non-existent variable with datasize=0 */ ret = st_runtime->set_variable(u"efi_none", &guid_vendor1, EFI_VARIABLE_BOOTSERVICE_ACCESS | @@ -149,6 +160,10 @@ static int execute(void) (unsigned int)len); if (memcmp(data, v, len)) efi_st_todo("GetVariable returned wrong value\n"); + if (attr & EFI_VARIABLE_APPEND_WRITE) { + efi_st_error("APPEND_WRITE in returned attributes\n"); + return EFI_ST_FAILURE; + } /* Delete variable efi_none */ ret = st_runtime->set_variable(u"efi_none", &guid_vendor1, 0, 0, NULL); if (ret != EFI_SUCCESS) { -- 2.53.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-24 10:41 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-13 15:07 [PATCH 0/2] efi: fix and verify variables append_write Vincent Stehlé 2026-11-13 15:07 ` [PATCH 1/2] efi_loader: prevent set_variable() to record append_write Vincent Stehlé 2026-11-22 11:55 ` Heinrich Schuchardt 2026-11-24 8:48 ` Vincent Stehlé 2026-11-24 9:53 ` Vincent Stehlé 2026-11-24 10:10 ` Heinrich Schuchardt 2026-11-24 10:41 ` Vincent Stehlé 2026-11-13 15:07 ` [PATCH 2/2] efi_selftest: verify get_variable() never returns append_write Vincent Stehlé
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox