efi_loader: segfault in efi_clear_os_indications()
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sat, 20 Nov 2021 10:53:12 +0000 (11:53 +0100)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Fri, 26 Nov 2021 20:30:59 +0000 (21:30 +0100)
commit9d1564dabc5897ebaf2fad842d800473790479a2
tree6b27b1cfc1a227d21a5e025114bdfd88f52aded7
parent1ae35c72b8196dc353b99e9c73ff9f138808ac28
efi_loader: segfault in efi_clear_os_indications()

If we call efi_clear_os_indications() before initializing the memory store
for UEFI variables a NULL pointer dereference occurs.

The error was observed on the sandbox with:

    usb start
    host bind 0 sandbox.img
    load host 0:1 $kernel_addr_r helloworld.efi
    bootefi $kernel_addr_r

Here efi_resister_disk() failed due to an error in the BTRFS implementation.

Move the logic to clear EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED
to the rest of the capsule code.

If CONFIG_EFI_IGNORE_OSINDICATIONS=y, we should still clear the flag.
If OsIndications does not exist, we should not create it as it is owned by
the operating system.

Fixes: 149108a3eb59 ("efi_loader: clear OsIndications")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
lib/efi_loader/efi_capsule.c
lib/efi_loader/efi_setup.c