Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functions UEFI.read_EFI_variables_from_SPI and dump_EFI_variables_from_SPI are broken #1844

Open
fishilico opened this issue Jun 6, 2023 · 0 comments
Assignees

Comments

@fishilico
Copy link
Contributor

Hello,
While trying to add type hints to many modules, I encountered an issue in

chipsec/chipsec/hal/uefi.py

Lines 352 to 361 in 36ca6fa

def dump_EFI_variables_from_SPI(self) -> bytes:
return self.read_EFI_variables_from_SPI(0, 0x800000)
def read_EFI_variables_from_SPI(self, BIOS_region_base: int, BIOS_region_size: int) -> bytes:
rom = self.cs.spi.read_spi(BIOS_region_base, BIOS_region_size)
efi_var_store = find_EFI_variable_store(rom, self._FWType)
if efi_var_store:
efi_vars = uefi_platform.EFI_VAR_DICT[self._FWType]['func_getefivariables']
return efi_vars
return efi_var_store

self.cs.spi does not exist. When trying to call this function with

# ... (initialize cs using chipsec.chipset.cs())
uefi = chipsec.hal.uefi.UEFI(cs)
uefi.dump_EFI_variables_from_SPI()

An AttributeError exception is raised:

AttributeError: 'Chipset' object has no attribute 'spi'

Moreover the call to func_getefivariables is never actually done, in read_EFI_variables_from_SPI and read_EFI_variables_from_file:

chipsec/chipsec/hal/uefi.py

Lines 366 to 368 in 36ca6fa

if efi_var_store:
efi_vars = uefi_platform.EFI_VAR_DICT[self._FWType]['func_getefivariables']
return efi_vars

I think (efi_var_store) is missing:

efi_vars = uefi_platform.EFI_VAR_DICT[self._FWType]['func_getefivariables'](efi_var_store)

In short, functions dump_EFI_variables_from_SPI, read_EFI_variables_from_SPI and read_EFI_variables_from_file do not work. As they are not currently used in chipsec, should them be removed?

@npmitche npmitche self-assigned this Jun 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants