efi: fix panic in kdump kernel
authorOleksandr Tymoshenko <ovt@google.com>
Sat, 23 Mar 2024 06:33:33 +0000 (06:33 +0000)
committerArd Biesheuvel <ardb@kernel.org>
Sun, 24 Mar 2024 08:28:33 +0000 (09:28 +0100)
Check if get_next_variable() is actually valid pointer before
calling it. In kdump kernel this method is set to NULL that causes
panic during the kexec-ed kernel boot.

Tested with QEMU and OVMF firmware.

Fixes: bad267f9e18f ("efi: verify that variable services are supported")
Signed-off-by: Oleksandr Tymoshenko <ovt@google.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/efi.c

index 8859fb0b006d3b852225ffdd4040389844522cee..fdf07dd6f4591ddd4c32a80a2cf940e3d8b9d6f0 100644 (file)
@@ -203,6 +203,8 @@ static bool generic_ops_supported(void)
 
        name_size = sizeof(name);
 
+       if (!efi.get_next_variable)
+               return false;
        status = efi.get_next_variable(&name_size, &name, &guid);
        if (status == EFI_UNSUPPORTED)
                return false;