[PATCH] efi_loader: check query_variable_info attributes

Vincent Stehlé vincent.stehle at arm.com
Thu Apr 29 19:46:50 CEST 2021


QueryVariableInfo() must return EFI_INVALID_PARAMETER when an invalid
combination of attribute bits is supplied.

This fixes three SCT QueryVariableInfo_Conf failures.

Signed-off-by: Vincent Stehlé <vincent.stehle at arm.com>
Reviewed-by: Grant Likely <grant.likely at arm.com>
Cc: Heinrich Schuchardt <xypron.glpk at gmx.de>
Cc: Alexander Graf <agraf at csgraf.de>

Changes since v1:
- Remove if/else and return directly
---
 lib/efi_loader/efi_var_common.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/efi_loader/efi_var_common.c b/lib/efi_loader/efi_var_common.c
index b11ed91a74a..cbf8685fad5 100644
--- a/lib/efi_loader/efi_var_common.c
+++ b/lib/efi_loader/efi_var_common.c
@@ -160,6 +160,10 @@ efi_status_t EFIAPI efi_query_variable_info(
 	EFI_ENTRY("%x %p %p %p", attributes, maximum_variable_storage_size,
 		  remaining_variable_storage_size, maximum_variable_size);
 
+	if (!attributes || ((attributes & EFI_VARIABLE_RUNTIME_ACCESS) &&
+			    !(attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS)))
+		return EFI_EXIT(EFI_INVALID_PARAMETER);
+
 	ret = efi_query_variable_info_int(attributes,
 					  maximum_variable_storage_size,
 					  remaining_variable_storage_size,
-- 
2.30.2



More information about the U-Boot mailing list