[PATCH 2/3] hw/uefi: check access for first variable

Gerd Hoffmann posted 3 patches 3 months ago
Maintainers: Gerd Hoffmann <kraxel@redhat.com>
[PATCH 2/3] hw/uefi: check access for first variable
Posted by Gerd Hoffmann 3 months ago
When listing variables (via get-next-variable-name) only the names of
variables which can be accessed will be returned.  That check was
missing for the first variable though.  Add it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/uefi/var-service-vars.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/uefi/var-service-vars.c b/hw/uefi/var-service-vars.c
index cbeccdbd2664..8533533ea5c8 100644
--- a/hw/uefi/var-service-vars.c
+++ b/hw/uefi/var-service-vars.c
@@ -357,6 +357,9 @@ uefi_vars_mm_get_next_variable(uefi_vars_state *uv, mm_header *mhdr,
     if (uefi_strlen(name, nv->name_size) == 0) {
         /* empty string -> first */
         var = QTAILQ_FIRST(&uv->variables);
+        while (var && !check_access(uv, var)) {
+            var = QTAILQ_NEXT(var, next);
+        }
         if (!var) {
             return uefi_vars_mm_error(mhdr, mvar, EFI_NOT_FOUND);
         }
-- 
2.50.1
Re: [PATCH 2/3] hw/uefi: check access for first variable
Posted by Philippe Mathieu-Daudé 3 months ago
On 11/8/25 15:01, Gerd Hoffmann wrote:
> When listing variables (via get-next-variable-name) only the names of
> variables which can be accessed will be returned.  That check was
> missing for the first variable though.  Add it.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>   hw/uefi/var-service-vars.c | 3 +++
>   1 file changed, 3 insertions(+)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>