summaryrefslogtreecommitdiff
path: root/lib/efi_loader
AgeCommit message (Collapse)Author
2020-05-09efi_loader: variable: check a return value of uuid__str_to_bin()AKASHI Takahiro
The only error case is that a given UUID is in wrong format. So just return EFI_INVALID_PARAMETER here. Reported-by: Coverity (CID 300333) Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-09efi_loader: image_loader: fix a Coverity check against array accessAKASHI Takahiro
Coverity detected: Using "&opt->CheckSum" as an array. This might corrupt or misinterpret adjacent memory locations. The code should work as far as a structure, IMAGE_OPTIONAL_HEADER(64) is packed, but modify it in more logical form. Subsystem is a member next to CheckSum. Reported-by: Coverity (CID 300339) Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-07efi_loader: crypto/pkcs7_parser.h is not a local includeHeinrich Schuchardt
User <> and not "" for referencing a global include. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-07efi_loader: pkcs7_parse_message() returns error pointerPatrick Wildt
Since pkcs7_parse_message() returns an error pointer, we must not check for NULL. We have to explicitly set msg to NULL in the error case, otherwise the call to pkcs7_free_message() on the goto err path will assume it's a valid object. Signed-off-by: Patrick Wildt <patrick@blueri.se> Add missing include linux/err.h Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-07efi_loader: efi_variable_parse_signature() returns NULL on errorPatrick Wildt
efi_variable_parse_signature() returns NULL on error, so IS_ERR() is an incorrect check. The goto err leads to pkcs7_free_message(), which works fine on a NULL ptr. Signed-off-by: Patrick Wildt <patrick@blueri.se> Reviewed-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2020-05-07efi_loader: do not unnecessarily use EFI_CALL()Heinrich Schuchardt
There is no need to call efi_get_variable() instead of efi_get_variable_common(). So let's use the internal function. Move forward declarations to the top of the file. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-07efi_loader: error handling in efi_set_variable_common().Heinrich Schuchardt
Fix unreachable code. Free memory on error. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-07efi_loader: remove redundant assignment in dp_fill()Heinrich Schuchardt
The value of dp is overwritten without being used. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-07kbuild: efi: Avoid rebuilding efi targetsJan Kiszka
Add a couple of missing targets so that helloworld and other efi targets are not needlessly rebuilt. CC: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-04efi_loader: change setup sequenceHeinrich Schuchardt
If we want to restore variables from disk, we need to initialize block devices before variables. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-04efi_loader: correct comments for efi_status_tHeinrich Schuchardt
EFI_STATUS is unsigned (UINTN). Hence it cannot be negative. Correct comments for 'Return:'. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-04efi_loader: eliminate efi_set_(non)volatile_variableHeinrich Schuchardt
Eliminate superfluous functions efi_set_volatile_variable() and efi_set_nonvolatile_variable(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-04efi_loader: eliminate efi_get_(non)volatile_variableHeinrich Schuchardt
Eliminate superfluous functions efi_get_volatile_variable() and efi_get_nonvolatile_variable(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-04efi_loader: disk: add efi_disk_is_system_part()AKASHI Takahiro
This function will check if a given handle to device is an EFI system partition. It will be utilised in implementing capsule-on-disk feature. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Add function description. Return bool. Reviewed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-04efi_loader: factor out the common code from efi_transfer_secure_state()AKASHI Takahiro
efi_set_secure_stat() provides the common code for each stat transition caused by efi_transfer_secure_state(). Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Correct description of return value. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-04efi_loader: fix unreachable statement in efi_sigstore_parse_siglistAKASHI Takahiro
"if (left < esl->signature_size)" is not reachable in a while loop. But it is still valuable in case that a given signature database is somehow corrupted. So fix the while loop condition. Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-04lib/crypto, efi_loader: move some headers to include/cryptoAKASHI Takahiro
Pkcs7_parse.h and x509_parser.h are used in UEFI subsystem, in particular, secure boot. So move them to include/crypto to avoid relative paths. Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Don't include include x509_parser.h twice. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-04-30efi_loader: identify EFI system partitionHeinrich Schuchardt
In subsequent patches UEFI variables shalled be stored on the EFI system partition. Hence we need to identify the EFI system partition. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-04-16Merge tag 'efi-2020-07-rc1' of ↵Tom Rini
https://gitlab.denx.de/u-boot/custodians/u-boot-efi Pull request for UEFI sub-system for efi-2020-07-rc1 This pull request * provides an implementation of UEFI secure booting * fixes a problem with the rsa_mod_exp driver which stops some boards from booting when CONFIG_RSA is enabled which is needed for UEFI secure booting * enables the EFI_RNG_PROTOCOL if DM_RNG is enabled * fixes some function comments
2020-04-16x86: Move acpi_table header to main include/ directorySimon Glass
This file is potentially useful to other architectures saddled with ACPI so move most of its contents to a common location. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
2020-04-16efi_loader: set up secure bootAKASHI Takahiro
The following variable is exported as UEFI specification defines: SignatureSupport: array of GUIDs representing the type of signatures supported by the platform firmware Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2020-04-16efi_loader: image_loader: support image authenticationAKASHI Takahiro
With this commit, image validation can be enforced, as UEFI specification section 32.5 describes, if CONFIG_EFI_SECURE_BOOT is enabled. Currently we support * authentication based on db and dbx, so dbx-validated image will always be rejected. * following signature types: EFI_CERT_SHA256_GUID (SHA256 digest for unsigned images) EFI_CERT_X509_GUID (x509 certificate for signed images) Timestamp-based certificate revocation is not supported here. Internally, authentication data is stored in one of certificates tables of PE image (See efi_image_parse()) and will be verified by efi_image_authenticate() before loading a given image. It seems that UEFI specification defines the verification process in a bit ambiguous way. I tried to implement it as closely to as EDK2 does. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2020-04-16efi_loader: variable: add VendorKeys variableAKASHI Takahiro
The following variable is exported as UEFI specification defines: VendorKeys: whether the system is configured to use only vendor-provided keys or not The value will have to be modified if a platform has its own way of initializing signature database, in particular, PK. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2020-04-16efi_loader: variable: add secure boot state transitionAKASHI Takahiro
UEFI specification defines several global variables which are related to the current secure boot state. In this commit, those values will be maintained according to operations. Currently, AuditMode and DeployedMode are defined but not implemented. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2020-04-16efi_loader: variable: support variable authenticationAKASHI Takahiro
With this commit, EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS is supported for authenticated variables and the system secure state will transfer between setup mode and user mode as UEFI specification section 32.3 describes. Internally, authentication data is stored as part of authenticated variable's value. It is nothing but a pkcs7 message (but we need some wrapper, see efi_variable_parse_signature()) and will be validated by efi_variable_authenticate(), hence efi_signature_verify_with_db(). Associated time value will be encoded in "{...,time=...}" along with other UEFI variable's attributes. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2020-04-16efi_loader: add signature database parserAKASHI Takahiro
efi_signature_parse_sigdb() is a helper function will be used to parse signature database variable and instantiate a signature store structure in later patches. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2020-04-16efi_loader: add signature verification functionsAKASHI Takahiro
In this commit, implemented are a couple of helper functions which will be used to materialize variable authentication as well as image authentication in later patches. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2020-04-16efi_loader: add CONFIG_EFI_SECURE_BOOT config optionAKASHI Takahiro
Under this configuration, UEFI secure boot support will be added in later patches. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2020-04-16efi_loader: function descriptions efi_watchdog.cHeinrich Schuchardt
Correct function descriptions in efi_watchdog.c. Add the descriptions to the generated HTML documentation. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-04-16efi_loader: add missing doc comments in efi_disk.cHeinrich Schuchardt
Add missing descriptions for functions in efi_disk.c. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-04-16efi_loader: function descriptions efi_unicode_collation.cHeinrich Schuchardt
Correct function descriptions in efi_unicode_collation.c Add the Unicode collation protocol to the generated HTML documentation. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-04-16efi_loader: enable RNG if DM_RNG is enabledPeter Robinson
Enable EFI_RNG_PROTOCOL by default if DM_RNG is set. Signed-off-by: Peter Robinson <pbrobinson@gmail.com> Acked-by: Sughosh Ganu <sughosh.ganu@linaro.org> Remove superfluous 'if DM_RNG' Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-22efi_loader: definition of GetNextVariableName()Heinrich Schuchardt
'vendor' is both an input and an output parameter. So it cannot be constant. Fixes: 0bda81bfdc5c ("efi_loader: use const efi_guid_t * for variable services") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-22efi_loader: fix freestanding memmove()Heinrich Schuchardt
For EFI binaries we have to provide an implementation of memmove() in efi_freestanding.c. Before this patch the memmove() function was copying in the wrong direction. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-22efi_loader: description efi_convert_pointer()Heinrich Schuchardt
Correct the description of function efi_convert_pointer(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-22efi_loader: simplify logical expression in efi_disk_add_dev()Heinrich Schuchardt
To check if a variable is non-zero there is no need for '!= 0'. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-22efi_loader: correct reported length in GetNextVariable()Heinrich Schuchardt
The runtime service GetNextVariable() returns the length of the next variable including the closing 0x0000. This length should be in bytes. Comparing the output of EDK2 and U-Boot shows that this is currently not correctly implemented: EDK2: OsIndicationsSupported: 46 PlatformLang: 26 PlatformLangCodes: 36 U-Boot: OsIndicationsSupported: 23 PlatformLang: 13 PlatformLangCodes: 18 Provide correct length in GetNextVariable(). Fixes: d99a87f84b75 ("efi_loader: implement GetNextVariableName()") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-22efi_loader: fix function descriptions in efi_disk.cHeinrich Schuchardt
Use Sphinx style for function descriptions. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-22efi_loader: description of efi_variable.cHeinrich Schuchardt
Correct the file description. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-17efi_loader: export a couple of protocol related functionsAKASHI Takahiro
This is a preparatory patch. Those functions will be used in an implementation of UEFI firmware management protocol as part of my capsule update patch. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2020-03-11efi_loader: unnecessary assignment in efi_queue_eventHeinrich Schuchardt
The assigned value NULL is never used. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-11efi_loader: get_memory_map: return parameters whenever possibleAKASHI Takahiro
Currently, if GetMemoryMap API returns EFI_BUFFER_TOO_SMALL, it doesn't set valid values to other parameters, descriptor_size and descriptor_version, except memory_map_size. Some efi applications, however, may use those value; in particular, xen uses descriptor_size to calculate a size of buffer to be allocated. While UEFI specification is ambiguous in this point, it would be better to address this issue proactively to maximize the compatibility with existing efi applications. With this patch, for example, xen.efi (and hence linux kernel) can be started via bootefi without modification. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-02-28efi_loader: Implement FileLoad2 for initramfs loadingIlias Apalodimas
Following kernel's proposal for an arch-agnostic initrd loading mechanism [1] let's implement the U-boot counterpart. This new approach has a number of advantages compared to what we did up to now. The file is loaded into memory only when requested limiting the area of TOCTOU attacks. Users will be allowed to place the initramfs file on any u-boot accessible partition instead of just the ESP one. Finally this is an attempt of a generic interface across architectures in the linux kernel so it makes sense to support that. The file location is intentionally only supported as a config option argument(CONFIG_EFI_INITRD_FILESPEC), in an effort to enhance security. Although U-boot is not responsible for verifying the integrity of the initramfs, we can enhance the offered security by only accepting a built-in option, which will be naturally verified by UEFI Secure Boot. This can easily change in the future if needed and configure that via ENV or UEFI variable. [1] https://lore.kernel.org/linux-efi/20200207202637.GA3464906@rani.riverdale.lan/T/#m4a25eb33112fab7a22faa0fd65d4d663209af32f Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-02-26efi_loader: implement EFI_RT_PROPERTIES_TABLEHeinrich Schuchardt
UEFI spec 2.8 errata A replaces the RuntimeServicesSupported variable defined in UEFI spec 2.8 by the configuration table EFI_RT_PROPERTIES_TABLE. So let's follow suit. Cc: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Tested-by: Ard Biesheuvel <ardb@kernel.org>
2020-02-19efi_loader: EFI_RNG_PROTOCOLHeinrich Schuchardt
Do not use quotation marks for Kconfig help text. Replace rng abbreviation by full words. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-02-05dm: core: Create a new header file for 'compat' featuresSimon Glass
At present dm/device.h includes the linux-compatible features. This requires including linux/compat.h which in turn includes a lot of headers. One of these is malloc.h which we thus end up including in every file in U-Boot. Apart from the inefficiency of this, it is problematic for sandbox which needs to use the system malloc() in some files. Move the compatibility features into a separate header file. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-15efi_loader: imply VIDEO_ANSIHeinrich Schuchardt
UEFI programs like GRUB make change terminal colors which requires support for ANSI escape sequences. Let CONFIG_EFI_LOADER=y imply CONFIG_VIDEO_ANSI. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-15efi_loader: describe returning of controlHeinrich Schuchardt
Provide a sober description of how control can be returned by a UEFI binary. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-15efi_loader: document functions in efi_rng.cHeinrich Schuchardt
Add the missing Sphinx documentation. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-07efi_rng_protocol: Install the efi_rng_protocol on the root nodeSughosh Ganu
Install the EFI_RNG_PROTOCOL implementation for it's subsequent use by the kernel for features like kaslr. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>