summaryrefslogtreecommitdiff
path: root/lib/efi_loader
AgeCommit message (Collapse)AuthorFilesLines
2021-08-02efi_loader: typo cerificateHeinrich Schuchardt1-1/+1
%s/cerificate/certificate/ Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-07-24efi_loader: remove asm/setjmp.h from efi_api.hAKASHI Takahiro1-0/+1
In the commit c982874e930d ("efi_loader: refactor efi_setup_loaded_image()"), setjmp-related definitions were moved to efi_loaded_image_obj in efi_loader.h. So setjmp.h is no longer refererenced in efi_api.h. This also fixes some error when efi_api.h will be included in mkeficapsule.c. Fixes: c982874e930d ("efi_loader: refactor efi_setup_loaded_image()") Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-07-24efi_loader: capsule: remove authentication dataAKASHI Takahiro1-13/+57
If capsule authentication is disabled and yet a capsule file is signed, its signature must be removed from image data to flush. Otherwise, the firmware will be corrupted after update. Fixes: 04be98bd6bcf ("efi: capsule: Add support for uefi capsule authentication") Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2021-07-24efi_loader: capsule: remove unused guidAKASHI Takahiro1-3/+0
efi_guid_capsule_root_cert_guid is never used. Just remove it. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-07-24smbios: error handling for invalid addressesHeinrich Schuchardt1-7/+8
SMBIOS tables only support 32bit addresses. If we don't have memory here handle the error gracefully: * on x86_64 fail to start U-Boot * during UEFI booting ignore the missing table Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-18efi_capsule: Move signature from DTB to .rodataIlias Apalodimas4-3/+47
The capsule signature is now part of our DTB. This is problematic when a user is allowed to change/fixup that DTB from U-Boots command line since he can overwrite the signature as well. So Instead of adding the key on the DTB, embed it in the u-boot binary it self as part of it's .rodata. This assumes that the U-Boot binary we load is authenticated by a previous boot stage loader. Reviewed-by: Masami Hiramatsu <masami.hiramatsu@linaro.org> Tested-by: Masami Hiramatsu <masami.hiramatsu@linaro.org> Tested-by: Sughosh Ganu <sughosh.ganu@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2021-07-18efi_loader: increase eventlog buffer sizeMasahisa Kojima1-1/+1
TCG PC Client PFP spec says "The Log Area Minimum Length for the TCG event log MUST be at least 64KB." in ACPI chapter. This commit increase the buffer size to 64KB. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-07-18efi_loader: Use %pD to log device-path instead of local efi_dp_str()Masami Hiramatsu1-5/+1
Use %pD to log device-path instead of using efi_dp_str() and efi_free_pool() locally in find_boot_device(). This is a cleanup patch, no feature update nor fix. Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-07-18efi_loader: set partition GUID in device path for SIG_TYPE_GUIDAlfonso Sánchez-Beato2-2/+9
Previously, the GPT device GUID was being used instead of the partition, which was incorrect. Signed-off-by: Alfonso Sánchez-Beato <alfonso.sanchez-beato@canonical.com> Let EFI_LOADER select CONFIG_PARTITION_UUIDS. Use log_warning() instead of printf() for warning. Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2021-07-12efi_loader: Fix to set bootdev_root correctly if bootdev foundMasami Hiramatsu1-1/+2
Fix find_boot_device() to set bootdev_root if it finds the bootdev from BootNext. Currently it sets the bootdev_root only when it finds bootdev from BootOrder. Fixes: c74cd8bd08d1 ("efi_loader: capsule: add capsule_on_disk support") Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org> Accked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-07-12efi_loader: set CapsuleLast after each capsuleHeinrich Schuchardt1-12/+13
If multiple capsules are applied, the FMP drivers for the individual capsules can expect the value of CapsuleLast to be accurate. Hence CapsuleLast must be updated after each capsule. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-07-12efi_loader: missing EFI_CALL() in set_capsule_resultHeinrich Schuchardt1-5/+5
efi_set_variable() should be called with EFI_CALL(). Use efi_set_variable_int() instead. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-07-12efi_loader: rework messages for capsule updatesHeinrich Schuchardt1-13/+15
* Use log category LOGC_EFI. This allows to remove 'EFI:' prefixes in messages. * Rephrase some of the messages. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-07-12efi_loader: provide file attributes in EFI_FILE_PROTOCOL.Read()Heinrich Schuchardt1-0/+15
When reading a directory using EFI_FILE_PROTOCOL.Read() provide file attributes and timestamps. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-07-02efi_loader: Allow capsule update on-disk without checking OsIndicationsIlias Apalodimas2-8/+38
Although U-Boot supports capsule update on-disk, it's lack of support for SetVariable at runtime prevents applications like fwupd from using it. In order to perform the capsule update on-disk the spec says that the OS must copy the capsule to the \EFI\UpdateCapsule directory and set a bit in the OsIndications variable. The firmware then checks for the EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED bit in OsIndications variable, which is set by the submitter to trigger processing of the capsule on the next reboot. Let's add a config option which ignores the bit and just relies on the capsule being present. Since U-Boot deletes the capsule while processing it, we won't end up applying it multiple times. Note that this is allowed for all capsules. In the future, once authenticated capsules are fully supported, we can limit the functionality to those only. Signed-off-by: apalos <ilias.apalodimas@linaro.org> Reword Kconfig description. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-07-02efi_loader: clear OsIndicationsHeinrich Schuchardt1-1/+39
After each reboot we must clear flag EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED in variable OsIndications. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-07-02efi_loader: Improve the parameter check for QueryVariableInfo()Masami Hiramatsu1-0/+13
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>
2021-07-02efi_loader: missing parentheses in query_console_sizeHeinrich Schuchardt1-1/+1
After if we should use parentheses to keep the code readable. Fixes: a95f4c885991 ("efi_loader: NULL dereference in EFI console") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-07-02efi_loader: Always install FMPsIlias Apalodimas2-8/+9
We only install FMPs if a CapsuleUpdate is requested. Since we now have an ESRT table which relies on FMPs to build the required information, it makes more sense to unconditionally install them. This will allow userspace applications (e.g fwupd) to make use of the ERST and provide us with files we can use to run CapsuleUpdate on-disk Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-07-02efi_loader: Force a single FMP instance per hardware storeIlias Apalodimas1-23/+22
Chapter 23 of the EFI spec (rev 2.9) says: "A specific updatable hardware firmware store must be represented by exactly one FMP instance". This is not the case for us, since both of our FMP protocols can be installed at the same time because they are controlled by a single 'dfu_alt_info' env variable. So make the config options depend on each other and allow the user to install one of them at any given time. If we fix the meta-data provided by the 'dfu_alt_info' in the future, to hint about the capsule type (fit or raw) we can revise this and enable both FMPs to be installed, as long as they target different firmware hardware stores Note that we are not using a Kconfig 'choice' on purpose, since we want to allow both of those to be installed and tested in sandbox Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-07-02efi: Fix to use null handle to create new handle for efi_fmp_rawMasami Hiramatsu1-1/+1
When running the efidebug capsule disk-update command, the efi_fmp_raw protocol installation fails with 2 (EFI_INVALID_PARAMETER) as below. This is because the code passes efi_root instead of the handle local var. => efidebug capsule disk-update EFI: Call: efi_install_multiple_protocol_interfaces( &handle, &efi_guid_firmware_management_protocol, &efi_fmp_fit, NULL) EFI: Entry efi_install_multiple_protocol_interfaces(00000000fbaf5988) EFI: Call: efi_install_protocol_interface( handle, protocol, EFI_NATIVE_INTERFACE, protocol_interface) EFI: Entry efi_install_protocol_interface(00000000fbaf5988, 86c77a67-0b97-4633-a187-49104d0685c7, 0, 00000000fbfa6ee8) EFI: new handle 00000000fbb37520 EFI: Exit: efi_install_protocol_interface: 0 EFI: 0 returned by efi_install_protocol_interface( handle, protocol, EFI_NATIVE_INTERFACE, protocol_interface) EFI: Exit: efi_install_multiple_protocol_interfaces: 0 EFI: 0 returned by efi_install_multiple_protocol_interfaces( &handle, &efi_guid_firmware_management_protocol, &efi_fmp_fit, NULL) EFI: Call: efi_install_multiple_protocol_interfaces( &efi_root, &efi_guid_firmware_management_protocol, &efi_fmp_raw, NULL) EFI: Entry efi_install_multiple_protocol_interfaces(00000000fbfec648) EFI: Call: efi_install_protocol_interface( handle, protocol, EFI_NATIVE_INTERFACE, protocol_interface) EFI: Entry efi_install_protocol_interface(00000000fbfec648, 86c77a67-0b97-4633-a187-49104d0685c7, 0, 00000000fbfa6f18) EFI: handle 00000000fbaf8520 EFI: Exit: efi_install_protocol_interface: 2 EFI: 2 returned by efi_install_protocol_interface( handle, protocol, EFI_NATIVE_INTERFACE, protocol_interface) EFI: Exit: efi_install_multiple_protocol_interfaces: 2 EFI: 2 returned by efi_install_multiple_protocol_interfaces( &efi_root, &efi_guid_firmware_management_protocol, &efi_fmp_raw, NULL) Command failed, result=1 To fix this issue, pass the handle local var which is set NULL right before installing efi_fmp_raw as same as the installing efi_fmp_fit. (In both cases, the local reference to the handle will be just discarded) Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-06-28efi_loader: TPL_HIGH_LEVEL not allowed for CreateEventHeinrich Schuchardt1-1/+0
According to chapter 7.1 "Event, Timer, and Task Priority Services" TPL_HIGH_LEVEL should not be exposed to applications and drivers. According to the discussion with EDK II contributors this implies that CreateEvent() shall not allow to create events with TPL_HIGH_LEVEL. Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Acked-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
2021-06-09efi_loader: fix Sphinx warningHeinrich Schuchardt1-1/+1
Brackets '[' need to be escaped to avoid a build warning lib/efi_loader/efi_image_loader.c:223: WARNING: Inline strong start-string without end-string. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Masahisa Kojima <masahisa.kojima@linaro.org>
2021-06-09efi_loader: efi_capsule_delete_file() NULL dereferenceHeinrich Schuchardt1-1/+2
If opening a file fails, the file handle pointer is not valid and must not be dereferenced. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-06-09efi_loader: partition numbers are hexadecimalHeinrich Schuchardt2-3/+3
If we want to address partition 15 of virtio block device 11, we have to write: virtio b:f When calling sprintf() we must use %x for the device and partition numbers. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-28efi_loader: add PE/COFF image measurementMasahisa Kojima3-26/+244
"TCG PC Client Platform Firmware Profile Specification" requires to measure every attempt to load and execute a OS Loader(a UEFI application) into PCR[4]. This commit adds the PE/COFF image measurement, extends PCR, and appends measurement into Event Log. Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Replace CONFIG_HASH_CALCULATE by CONFIG_HASH Fix conversions between pointers and u64. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2021-05-28efi_loader: Work-around build issue due to missing hash_calculate()Alexandru Gagniuc1-0/+2
The hash_calculate() symbol is provided by hash-checksum.c. It depends on hash_progressive_lookup_algo(), provided when CONFIG_HASH=y. The issue is that hash_calculate() is used by the efi_loader, irregardless of CONFIG_FIT_SIGNATURE. As pointed out in commit 87316da05f2f ("lib: introduce HASH_CALCULATE option"), enabling hash_calculate() based on CONFIG_FIT_SIGNATURE is incorrect. To resolve this, use CONFIG_HASH as the compile switch for hash-checksum.c. This ensures that all dependencies are compiled, and is the most natural Kconfig to use. There is the issue of having to 'select HASH' in a couple of places that already 'select SHA256'. This is a deeper problem with how hashes are organized, and fixing it is beyonf the scope of this change. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Acked-by: Masahisa Kojima <masahisa.kojima@linaro.org>
2021-05-28Revert "lib: introduce HASH_CALCULATE option"Alexandru Gagniuc1-2/+0
When we think of Kconfig, we usually think of features that we like to enable or not. Ideally, we wouldn't use Kconfig to fix a build issue, although sometimes it might make sense. With Kconfig it's hard to guarantee that the fix is universal. We can only say that it works for the set of tested configurations. In the majority of cases, it's preferable to let the linker figure things out for us. The reverted commit attempted to fix a build issue by adding an invisible Kconfig option. This is wrong in several ways: It invents a new Kconfig variable when CONFIG_HASH already exists for the same purpose. Second, hash-checksum.c makes use of the hash_progressive_lookup_algo() symbol, which is only provided with CONFIG_HASH, but this dependency was not expressed in the reverted patch. It feels like Kconfig is turning into a listing of all available source files, and a buffet to 'select' which ones to compile. The purpose of this revert is to enable the next change to make use of CONFIG_HASH instead of adding to Kconfig. This reverts commit 87316da05f2fd49d3709275e64ef0c5980366ade. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Acked-by: Masahisa Kojima <masahisa.kojima@linaro.org>
2021-05-28efi_loader: Fix coverity warnings for efi tcg2 protocolIlias Apalodimas1-2/+5
Coverity reported 3 warnings on the current code. CID 331856, 331855, 331854 on the latest scan. Fix the rest of the warnings by initializing the variables before passing them to tpm2_get_pcr_info(). In order to avoid future warnings and errors initialize them to 0 within the function as well, since the values are always OR'ed after querying the hardware. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2021-05-25efi_loader: Fix -Wextra warning for EFI TCG2Ilias Apalodimas1-18/+22
Compiling with -Wextra produces a number of (harmless) warnings for the EFI TCG2 protocol. Let's fix those in case we ever enable the flag on the EFI subsystem Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2021-05-25efi_loader: path length in efi_dp_from_name()Heinrich Schuchardt1-2/+7
Before this patch efi_dp_from_name() only accommodated a maximum file path length of 31 characters. This leads to boot failures due to file name truncation. Allow arbitrary path lengths. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-25efi_loader: expose efi_image_parse() even if UEFI Secure Boot is disabledMasahisa Kojima5-68/+73
This is preparation for PE/COFF measurement support. PE/COFF image hash calculation is same in both UEFI Secure Boot image verification and measurement in measured boot. PE/COFF image parsing functions are gathered into efi_image_loader.c, and exposed even if UEFI Secure Boot is not enabled. This commit also adds the EFI_SIGNATURE_SUPPORT option to decide if efi_signature.c shall be compiled. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-25efi_loader: remove weak efi_get_public_key_data()Heinrich Schuchardt1-10/+0
Configuring a system with CONFIG_EFI_CAPSULE_AUTHENTICATE=y but without a method to retrieve the public key data is a misconfiguration. We should get a build failure for it. Therefore remove the weak efi_get_public_key_data() implementation. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-18lib: introduce HASH_CALCULATE optionMasahisa Kojima1-0/+2
Build error occurs when CONFIG_EFI_SECURE_BOOT or CONFIG_EFI_CAPSULE_AUTHENTICATE is enabled, because hash-checksum.c is not compiled. Since hash_calculate() implemented in hash-checksum.c can be commonly used aside from FIT image signature verification, this commit itroduces HASH_CALCULATE option to decide if hash-checksum.c shall be compiled. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-18efi_loader: Fix Kconfig for EFI_TCG2 protocolIlias Apalodimas1-0/+6
EFI_TCG2 depends not only on TPMv2 but also on the underlying algorithms. So select the missing SHA1, SHA256, SHA384 and SHA512 we currently support Reported-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Add 'default y'. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-18efi_loader: Don't stop EFI subsystem init if installing TCG2 failsIlias Apalodimas1-5/+28
Up to now we are stopping the EFI subsystem if a TPMv2 exists but the protocol fails to install. Now that we've switched the config to 'default y' the sandbox TPM fails, since it doesn't support all the required capabilities of the protocol. Not installing the protocol is not catastrophic. If the protocol fails to install the PCRs will never be extended to the expected values, so some other entity later in the boot flow will eventually figure it out and take the necessary actions. While at it fix a corner case were the user can see an invalid error message when the protocol failed to install. We do have a tcg2_uninit() which we call when the protocol installation fails. There are cases though that this might be called before the configuration table is installed (e.g probing the TPM for capabilities failed). In that case the user will see "Failed to delete final events config table". So stop printing it since it's not an actual failure , simply because the config table was never installed in the first place. In order to stop printing it make efi_init_event_log() and create_final_event() cleanup themselves and only call tcg2_uninit() when the protocol installation fails. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-18efi_loader: Uninstall the TCG2 protocol if logging s-crtm failsIlias Apalodimas1-5/+3
Instead of just failing, clean up the installed config table and EventLog memory if logging an s-crtm event fails during the protocol installation Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Eliminate label 'out:' by using return. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-18efi_loader: Clean up tcg2 once in case of failureIlias Apalodimas1-4/+0
efi_init_event_log() calls tcg2_uninit() in case of failure. We can skip that since the function is called on efi_tcg2_register() which also cleans up if an error occurs Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-18efi_loader: loosen buffer parameter check in efi_file_read_intPeng Fan1-1/+1
This is same issue as https://bugzilla.redhat.com/show_bug.cgi?id=1733817, but that fix was wrongly partial reverted. When reading a directory, EFI_BUFFER_TOO_SMALL should be returned when the supplied buffer is too small, so a use-case is to call EFI_FILE_PROTOCOL.Read() with *buffer_size=0 and buffer=NULL to obtain the needed size before doing the actual read. So remove the check only for directory reading, file reading already do the check by itself. Fixes: db12f518edb0("efi_loader: implement non-blocking file services") Signed-off-by: Peng Fan <peng.fan@nxp.com> Cc: Stefan Sørensen <stefan.sorensen@spectralink.com> Tested-by: Peter Robinson <pbrobinson@gmail.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-18efi_loader: capsule: Remove the check for capsule_authentication_enabled ↵Sughosh Ganu1-3/+2
environment variable The current capsule authentication code checks if the environment variable capsule_authentication_enabled is set, for authenticating the capsule. This is in addition to the check for the config symbol CONFIG_EFI_CAPSULE_AUTHENTICATE. Remove the check for the environment variable. The capsule will now be authenticated if the config symbol is set. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviwed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-18efi_loader: build warning in efi_tcg2_hash_log_extend_eventHeinrich Schuchardt1-2/+2
Building 32bit boards with the TCG2 protocol enabled leads to a build warning due to a missing conversion. lib/efi_loader/efi_tcg2.c:774:27: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] 774 | ret = tcg2_create_digest((u8 *)data_to_hash, data_to_hash_len, | ^ Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2021-04-24efi_loader: capsule: return a correct error code at find_boot_device()AKASHI Takahiro1-1/+1
In case of failure at efi_get_variable_int("BootOrder"), we should skip examining boot option variables and return an appropriate error code which is the one the function returned. Fixes: CID 331153 Code maintainability issues (UNUSED_VALUE) Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-04-24efi: Fix ESRT refresh after Capsule updateJose Marinho1-1/+1
Indicated by Coverity Scan CID 331147 The ESRT was being refreshed in situations where the UpdateCapsule procedure failed. In that scenario: 1) the ESRT refresh was superfluous. 2) a failed ESRT refresh return code overwrites the UpdateCapsule error return code. This commit ensures that the ESRT is only refreshed when the UpdateCapsule performs successfully. CC: Heinrich Schuchardt <xypron.glpk@gmx.de> CC: Sughosh Ganu <sughosh.ganu@linaro.org> CC: AKASHI Takahiro <takahiro.akashi@linaro.org> CC: Tom Rini <trini@konsulko.com> CC: Andre Przywara <andre.przywara@arm.com> CC: nd@arm.com Signed-off-by: Jose Marinho <jose.marinho@arm.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-04-24efi_loader: simplify tcg2_create_digest()Ilias Apalodimas1-4/+1
Bumping the digest list count, for all supported algorithms, can be calculated outside of the individual switch statements. So let's do that for every loop iteration instead and simplify the code a bit. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-04-24efi_loader: missing include in efi_string.cHeinrich Schuchardt1-0/+1
To avoid diverging function definitions we need to include efi_loader.h. Fixes: fe179d7fb5c1 ("efi_loader: Add size checks to efi_create_indexed_name()") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-04-17efi_loader: fix possible buffer overflowMasahisa Kojima1-1/+1
Variable "final" will have SHA512 digest, but currently the array size is not sufficient. Let's fix it. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-04-17efi_loader: memory leak in efi_capsule_scan_dir()Heinrich Schuchardt1-0/+3
If realloc() fails, we should free the old buffer. Fixes: c74cd8bd08d1: ("efi_loader: capsule: add capsule_on_disk support") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-04-17efi_loader: esrt: Remove incorrect invocations of EFI_CALL macroSughosh Ganu1-14/+14
Remove function invocations using the EFI_CALL macro for those functions that do not have an EFI_ENTRY call in their definition. Such functions can use u-boot api's which rely on u-boot global data(gd) pointer. The Arm and RiscV architectures maintain a separate gd pointer, one for u-boot, and a separate gd for the efi application. Calling a function through the EFI_CALL macro changes the gd pointer to that used for the efi application, with u-boot gd being unavailable. Any function then trying to dereference u-boot's gd will result in an abort. Fix this issue by removing the EFI_CALL macro for all of such functions which do not begin by an EFI_ENTRY function call. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-04-10efi_loader: Change ptr arithmetics tcg eventlog bufferIlias Apalodimas1-9/+10
Although ptr arithmetics are allowed with extensions in gcc, they are not allowed by the C spec. So switch to (void *)(uintptr_t) instead Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2021-04-10efi_loader: esrt: wrong type for LocateHandleBuffer()Heinrich Schuchardt1-1/+1
efi_locate_handle_buffer() expects no_handles to be of type efi_uintn_t *. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>