summaryrefslogtreecommitdiff
path: root/include
AgeCommit message (Collapse)Author
2021-02-16sbat: clang-format the whole thing.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-16Make the variable name and pointer const in all of our efi vars functionsPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-16Fix a bunch of trivial trailing whitespace issues.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-16console: Fix a typo in the EFI warning list in gnu-efiPeter Jones
Some versions of gnu-efi have a typo, in which "EFI_WARN_UNKNOWN_GLYPH" is accidentally "EFI_WARN_UNKOWN_GLYPH". Work around that, so that we can use the not-silly one in console.c's list of error and warning messages. This is a backport from devel for: commit 5f62b22ccd636d326b3229a2b196118701c6f3f7 Author: Peter Jones <pjones@redhat.com> Date: Mon Aug 26 16:12:05 2019 -0400 Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-16console: Move the countdown function to console.cGary Lin
Move the countdown function from MokManager to console.c to make the function public Also make console_save_and_set_mode() and console_restore_mode() public Signed-off-by: Gary Lin <glin@suse.com>
2021-02-16Make sure MIN() and MAX() are always defined.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-16SPDX: Clarify the attribution for crypt_blowfishPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-16Fix up a bunch of our license statements and add SPDX most placesPeter Jones
The license statements in our source files were getting to be a giant mess, and mostly they all just say the same thing. I've switched most of it to SPDX labels, but left copyright statements in place (where they were not obviously incorrect copy-paste jobs that I did...). If there's some change here you don't think is valid, let me know and we can fix it up together. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-15sbat: make the includes work like everything else.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-13add an ascii strndup() implementation.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-13Add some linked list primitives.Peter Jones
This adds basic linked list structures, initializers, and iterators. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-13Add a function to parse the SBAT metadata from the .sbat sectionJavier Martinez Canillas
Parse the SBAT [0] Version-Based Revocation Metadata that's contained in a .sbat data section of the loaded PE binary. This information is used along with data in a SBAT variable to determine if a EFI binary has been revoked. [0]: https://github.com/rhboot/shim/blob/sbat/SBAT.md Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2021-02-13Add the beginning of .sbat parsing stuffPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-13Move a bunch of PE-related stuff out of shim.cPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-13includes: add strchra() and strchrnula() implsPeter Jones
Unfortunately GNU-EFI doesn't currently implement ascii versions of strchr() or strchrnul(), and we kind of need them, so add an implementation here for now. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-01-29Renaming PeImage.h to pe.h wasn't actually a good idea.Peter Jones
I renamed PeImage.h to pe.h when I de-capitalized them, but this turns out to be a bad idea because we already have a pe.h on the SBAT branch. Woops. This moves it to peimage.h Signed-off-by: Peter Jones <pjones@redhat.com>
2021-01-29Work around some clang-format oddnessesPeter Jones
In the version of clang-format I've got locally[0], WhitespaceSensitiveMacros seems to only work sometimes. That means that if we ever run it on some particular things, it could seriously mess up a bunch of our debugging output. That's not great. In this patch, I've gone ahead and run clang-format on all the macros that use __LINE__, which are the obvious places this is dangerous, and then audited the result and fixed anything that's broken (including a couple of places where it was already broken.) [0] random:~/devel/github.com/shim/clang-format$ clang-format --version clang-format version 11.0.0 (Fedora 11.0.0-2.fc33) Signed-off-by: Peter Jones <pjones@redhat.com>
2021-01-29Always use lower case for our local include file names.Peter Jones
clang-format doesn't allow you to specify an include sort order, and just assumes asciibetical is a pretty good order, which doesn't work as well as you would hope. This makes them all lower case so they don't need to be re-sorted. I also went through and checked that we're using quoted local includes at all the appropriate places. Signed-off-by: Peter Jones <pjones@redhat.com>
2020-10-15Fix incorrect allocation size for EV_EFI_BOOT_SERVICES_APPLICATION events15.2James Bottomley
sizeof(EFI_IMAGE_LOAD_EVENT) needs to represent the size of the header so we can add the actual device path size to it to compute the event. Signed-off-by: Peter Jones <pjones@redhat.com>
2020-10-15hexdump.h: fix arithmetic error.Peter Jones
When I modified the hexdumper to help debug MokListRT mirroring not working because of PcdMaxVolatileVariableSize being tiny, I inadvertently added something that is effectively: hexdump(..., char *buf, ..., int position) { unsigned long begin = (position % 16); unsigned long i; ... for (i = 0; i < begin; i++) { ... } ... } Unfortunately, in c if 0x8 is set in position, that means begin is 0xfffffffffffff8, because signed integer math is horrifying: include/hexdump.h:99:vhexdumpf() &data[offset]:0x9E77E6BC size-offset:0x14 include/hexdump.h:15:prepare_hex() position:0x9E77E6BC include/hexdump.h:17:prepare_hex() before:0xFFFFFFFFFFFFFFFC size:0x14 include/hexdump.h:19:prepare_hex() before:0xFFFFFFFFFFFFFFFC after:0x0 include/hexdump.h:21:prepare_hex() buf:0x000000009E77E2BC offset:0 &buf[offset]:0x000000009E77E2BC Woops. This could further have been prevented in /some/ cases by simply not preparing the hexdump buffer when "verbose" is disabled. This patch makes "pos" be unsigned in all cases, and also checks for verbose in vhexdumpf() and simply returns if it is 0. Signed-off-by: Peter Jones <pjones@redhat.com>
2020-07-25Implement lennysz's suggestions for MokListRTPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2020-07-25Also use a config table to mirror mok variables.Peter Jones
Everything was going just fine until I made a vendor_db with 17kB of sha256 sums in it. And then the same source tree that had worked fine without that threw errors and failed all over the place. I wrote some code to diagnose the problem, and of course it was a failure in mirroring MokList to MokListRT. As Patrick noted in 741c61abba7, some systems have obnoxiously low amounts of variable storage available: mok.c:550:import_mok_state() BS+RT variable info: MaximumVariableStorageSize:0x000000000000DFE4 RemainingVariableStorageSize:0x000000000000D21C MaximumVariableSize:0x0000000000001FC4 The most annoying part is that on at least this edk2 build, SetVariable() /does actually appear to set the variable/, but it returns EFI_INVALID_PARAMETER. I'm not planning on relying on that behavior. So... yeah, the largest *volatile* (i.e. RAM only) variable this edk2 build will let you create is less than two pages. It's only got 7.9G free, so I guess it's feeling like space is a little tight. We're also not quite preserving that return code well enough for his workaround to work. New plan. We try to create variables the normal way, but we don't consider not having enough space to be fatal. In that case, we create an EFI_SECURITY_LIST with one sha256sum in it, with a value of all 0, and try to add that so we're sure there's /something/ there that's innocuous. On systems where the first SetVariable() / QueryVariableInfo() lied to us, the correct variable should be there, otherwise the one with the zero-hash will be. We then also build a config table to hold this info and install that. The config table is a packed array of this struct: struct mok_variable_config_entry { CHAR8 name[256]; UINT64 data_size; UINT8 data[]; }; There will be N+1 entries, and the last entry is all 0 for name and data_size. The total allocation size will always be a multiple of 4096. In the typical RHEL 7.9 case that means it'll be around 5 pages. It's installed with this guid: c451ed2b-9694-45d3-baba-ed9f8988a389 Anything that can go wrong will. Signed-off-by: Peter Jones <pjones@redhat.com> Upstream: not yet, I don't want people to read this before Wednesday. Signed-off-by: Peter Jones <pjones@redhat.com>
2020-07-25Improve debug output somePeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com> Upstream: pr#213
2020-07-23Add support for vendor_db built-in shim authorized list.Peter Jones
Potential new signing strategies ( for example signing grub, fwupdate and vmlinuz with separate certificates ) require shim to support a vendor provided bundle of trusted certificates and hashes, which allows shim to trust EFI binaries matching either certificate by signature or hash in the vendor_db. Functionality is similar to vendor_dbx. This also improves the mirroring quite a bit. Upstream: pr#206
2020-07-23tpm: Include information about PE/COFF images in the TPM Event LogJavier Martinez Canillas
The "TCG PC Client Specific Platform Firmware Profile Specification" says that when measuring a PE/COFF image, the TCG_PCR_EVENT2 structure Event field MUST contain a UEFI_IMAGE_LOAD_EVENT structure. Currently an empty UEFI_IMAGE_LOAD_EVENT structure is passed so users only have the hash of the PE/COFF image, but not information such the file path of the binary. Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Upstream-commit-id: c252b9ee94c
2020-07-23translate_slashes(): don't write to string literalsLaszlo Ersek
Currently, all three invocations of the translate_slashes() function may lead to writes to the string literal that is #defined with the DEFAULT_LOADER_CHAR macro. According to ISO C99 6.4.5p6, this is undefined behavior ("If the program attempts to modify such an array, the behavior is undefined"). This bug crashes shim on e.g. the 64-bit ArmVirtQemu platform ("Data abort: Permission fault"), where the platform firmware maps the .text section (which contains the string literal) read-only. Modify translate_slashes() so that it copies and translates characters from an input array of "char" to an output array of "CHAR8". While at it, fix another bug. Before this patch, if translate_slashes() ever encountered a double backslash (translating it to a single forward slash), then the output would end up shorter than the input. However, the output was not NUL-terminated in-place, therefore the original string length (and according trailing garbage) would be preserved. After this patch, the NUL-termination on contraction is automatic, as the output array's contents are indeterminate when entering the function, and so we must NUL-terminate it anyway. Fixes: 8e9124227d18475d3bc634c33518963fc8db7c98 Fixes: e62b69a5b0b87c6df7a4fc23906134945309e927 Fixes: 3d79bcb2651b9eae809b975b3e03e2f96c067072 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1795654 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Upstream-commit-id: 9813e8bc8b3
2020-07-23MokManager: console mode modification for hi-dpi screen devicesIvan Hu
There are lots of hi-dpi laptops nowadays, as doing mok enrollment, the font is too small to see. https://bugs.launchpad.net/ubuntu/+source/shim/+bug/1822043 This patch checks if the resolution is larger than Full HD (1920x1080) and current console output columns and rows is in a good mode. Then swith the console output to a better mode. Signed-off-by: Ivan Hu <ivan.hu@canonical.com> Upstream-commit-id: cf05af6d899
2020-07-23shim: Rework pause functions and add read_counter()Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com> Upstream-commit-id: fc6b0bca84e
2018-04-05Fix get_variable() usage in setup_verbosity()Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-04-05Get rid of dprinta(), it's uselessPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12console: Do not set EFI console to textmode until something is printedHans de Goede
Remove the setup_console(1) calls from shim and instead make lib/console.c make that call when necessary. This avoids shim forcing the EFI console to switch to text-mode if nothing is printed. This commit also modifies MokManager to work the same way for consistency, even though MokManager will always print something. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-03-12console: Add console_print and console_print_at helpersHans de Goede
This is a preparation commit for removing the setup_console(1) calls from MokManager and shim so that we don't force the EFI console to switch to text-mode. This commit replaces all direct calls to Print / PrintAt with calls to the new helpers (no functional changes) so that we can delay calling setup_console(1) till the first Print call in a follow-up patch. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-03-12Don't use uefi_call_wrapper(), ever.Peter Jones
I'm pretty done with typing uefi_call_wrapper() and counting arguments every time. Instead, just make the compiler error if we don't have ms_abi. Also, make it so nothing can use uefi_call_wrapper() directly. Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12Use gcc's offsetof() instead of hacking out our own.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12Don't have tons of local guid definitions for no reason at all.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12Clean up efiauthenticated.h a lot.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12Make sure all of our include files have proper guards.Peter Jones
... and make them all the same formatting too. Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12Move includes around to clean the source tree up a bit.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-12-19"in_protocol" is used in more than shim.o; make it not static.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-08-31Add a mechanism to print openssl errorsPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-08-31Make msleep() be a thingPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2016-09-06Add HTTP and IpConfig headersGary Ching-Pang Lin
Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2016-09-06Make translate_slashes() publicGary Ching-Pang Lin
Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2016-06-09shim: make the PE loader less overzealous on rejectionsPeter Jones
2015-06-16Fix console_print_box*() parameters.Peter Jones
When we made lib build with the correct CFLAGS, it inherited -Werror=sign-compare, and I fixed up some parameters on console_print_box() and console_print_box_at() to avoid sign comparison errors. The fixups were *completely wrong*, as some behavior relies on negative values. So this fixes them in a completely different way, by casting appropriately to signed types where we're doing comparisons. Signed-off-by: Peter Jones <pjones@redhat.com>
2015-04-13Make lib/ build right with the cflags it should be using...Peter Jones
... but isn't. Signed-off-by: Peter Jones <pjones@redhat.com>
2015-04-13Align the sections we're loading, and check for validity /after/ discarding.Peter Jones
Turns out a) the codegen on aarch64 generates code that has real alignment needs, and b) if we check the length of discardable sections before discarding them, we error for no reason. So do the error checking in the right order, and always enforce some alignment because we know we have to. Signed-off-by: Peter Jones <pjones@redhat.com>
2014-08-27Make sure we don't try to load a binary from a different arch.Peter Jones
Since in theory you could, for example, get an x86_64 binary signed that also behaves as an ARM executable, we should be checking this before people build on other architectures. Signed-off-by: Peter Jones <pjones@redhat.com>
2014-06-25Make sure we default to assuming we're locked down.Peter Jones
If "SecureBoot" exists but "SetupMode" does not, assume "SetupMode" says we're not in Setup Mode. Signed-off-by: Peter Jones <pjones@redhat.com>
2014-06-25MokManager: handle the error status from ReadKeyStrokeGary Ching-Pang Lin
On some machines, even though the key event was signaled, ReadKeyStroke still got EFI_NOT_READY. This commit handles the error status to avoid console_get_keystroke from returning unexpected keys. Signed-off-by: Gary Ching-Pang Lin <glin@suse.com> Conflicts: MokManager.c