efi_loader: Improve the parameter check for QueryVariableInfo()

Improve efi_query_variable_info() to check the parameter settings and
return correct error code according to the UEFI Specification 2.9,
and the Self Certification Test (SCT) II Case Specification, June
2017, chapter 4.1.4 QueryVariableInfo().

Reported-by: Kazuhiko Sakamoto <sakamoto.kazuhiko@socionext.com>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
Masami Hiramatsu 2021-07-01 00:49:48 +09:00 committed by Heinrich Schuchardt
parent abd62e4d41
commit 417a3c24c9
1 changed files with 13 additions and 0 deletions

View File

@ -163,6 +163,19 @@ 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 (!maximum_variable_storage_size ||
!remaining_variable_storage_size ||
!maximum_variable_size ||
!(attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS))
return EFI_EXIT(EFI_INVALID_PARAMETER);
if ((attributes & ~(u32)EFI_VARIABLE_MASK) ||
(attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) ||
(attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) ||
(!IS_ENABLED(CONFIG_EFI_SECURE_BOOT) &&
(attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS)))
return EFI_EXIT(EFI_UNSUPPORTED);
ret = efi_query_variable_info_int(attributes,
maximum_variable_storage_size,
remaining_variable_storage_size,