summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-02-15README: Remove superfluous *and*Paul Menzel
2021-02-15Add .cer/.crt/.esl to .gitignorePeter Jones
This was previously on devel as: commit 2e29c0358888412e9addfb016cc72f6e89ffb536 Author: Peter Jones <pjones@redhat.com> Date: Mon Jun 29 14:06:34 2020 -0400 Add .cer/.crt/.esl to .gitignore But .cer and .crt were added independently in another commit since then. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-15Add screen logs to .gitignorePeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-15Also ignore .sw?Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-15Ignore *.hashJia Zhang
*.hash should be ignored by git status if ENABLE_SHIM_HASH is configured. Signed-off-by: Jia Zhang <zhang.jia@linux.alibaba.com>
2021-02-15Add mm/fb hashing to TODO, put that and related things under 'Reproducible ↵Mathieu Trudel-Lapierre
builds'
2021-02-15Add fallback boot loop detection to TODOPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-15Add some *more* TODO tasks.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-15Add another unfortunate TODO entry.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-15Add some more TODOs for shim 16Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-15Try to make scan-build.mk work without scan-build installed.Peter Jones
2021-02-15Try to make coverity.mk work without cov-build installed.Peter Jones
2021-02-15We're not using travis-build.sh any more.Peter Jones
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-13get_variable: always allocate a NUL character at the end.Peter Jones
Sometimes we're loading structures that are parsed in string-like ways, but can't necessarily be trusted to be zero-terminated. Solve that by making sure we always have enough aligned, trailing zero bytes to always have at least one NUL character, no matter which character type is being parsed. 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 an example SBAT workflow documentPeter Jones
Add a file that contains example workflows for SBAT and better illustrate what type of content is expected to be present in both the .sbat section and the SBAT authenticated EFI variable. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-13Add Secure Boot Advanced Targeting (SBAT) specification documentJan Setje-Eilers
SBAT is a new Generation Number Based Revocation meant to replace the DBX Revocation List Files mechanism. It is more flexible and allow to revoke sets of binaries, instead of having to list all of them as with the DBX. Metadata that includes the vendor, product family, product, component, version and generation are added to artifacts in a .sbat section. This is protected by the digital signature and so it cannot be tampered. Signed-off-by: Jan Setje-Eilers <jan.setjeeilers@oracle.com> Signed-off-by: Peter Jones <pjones@redhat.com> Signed-off-by: Gary Lin <glin@suse.com>
2021-02-13SBAT: parse a copy of the table that's got a NUL at the endPeter Jones
Right now we allocate the PE file's contents in RW memory, but hopefully that won't always be the case. Our SBAT parsing, however, very much expects to be able to edit it. We also don't actually know that shim's .sbat section is loaded r/w, so we can't necessarily write there. This patch copies the SBAT data to its own buffer, plus one NUL byte at the end, so we can always be sure that will work. 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-13Add some more PE helpers we need for SBATPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-13Refactor some PE handling codePeter 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-02-12Remove my .syntastic_c_config, it doesn't belong in the repo.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-12efi bins: add an easy way for vendors to add .sbat dataPeter Jones
In cases where we accept vendor shim binaries with additional patches, it may become necessary to identify those builds with additional SBAT data. When we consider such patches, we should be proactive in asking vendors to include that data in the .sbat sections of their trusted EFI binaries. This patch adds any data in data/sbat.*.csv (after a quick sanitizing pass) after data/sbat.csv in the .sbat section, so that no changes to the upstream data/sbat.csv are ever required. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-12Add a .sbat section to EFI binariesJavier Martinez Canillas
The Secure Boot Advanced Targeting (SBAT) [0] is a Generation Number Based Revocation mechanism that is meant to replace the DBX revocation file list. Binaries must contain a .sbat data section that has a set entries, each of them consisting of UTF-8 strings as comma separated values. Allow to embed this information into the fwupd EFI binary at build time. The SBAT metadata must contain at least two entries. One that defines the SBAT version used and another one that defines the component generation. This patch adds a sbat.csv that contains these two entries and downstream users can override if additional entries are needed due changes that make them diverge from upstream code and potentially add other vulnerabilities. The same SBAT metadata is added to the fallback and MOK manager binaries because these are built from the same shim source. These need to have SBAT metadata as well to be booted if a .sbat section is mandatory. [0]: https://github.com/rhboot/shim/blob/sbat/SBAT.md Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2021-02-05github workflows: add the sbat branch to one PR builds run forPeter Jones
This adds the "sbat" branch to the list of branches where a build is done if a PR is submitted against that branch. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-05github workflows: Unify the x86 pull request build rules stepsPeter Jones
This makes each of the f32/f33/f34 distro builds use the same steps to do the build, as well as making each of them build both x64 and ia32 targets. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-01Fix pe.h -> peimage.h in /both/ places.Peter Jones
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>
2021-01-29Add a .clang-format file.Peter Jones
There's clearly not enough conformance to a single coding style here. To some extent that can't really change - I don't intend to adopt edk2's style for the main codebase, but re-formatting the code we borrow from edk2 would be insane. This commit adds a .clang-format file, to be used on new files as such: clang-format --style=file -i foo.c It can also be used when new free-standing code is added to existing files, using the clang-format --lines= option. The starting style in this is pretty close to the Linux kernel style, with a couple of minor modifications. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-01-29shim: compile time option to bypass the ExitBootServices() checkPaul Moore
On systems where a second stage bootloader is not used, and the Linux Kernel is booted directly from shim, shim's ExitBootServices() hook can cause problems as the kernel never calls the shim's verification protocol. In this case calling the shim verification protocol is unnecessary and redundant as shim has already verified the kernel when shim loaded the kernel as the second stage loader. This functionality is disabled by default and must be enabled via the DISABLE_EBS_PROTECTION macro/define at build time. Signed-off-by: Paul Moore <pmoore2@cisco.com>
2020-12-11Try to kick the github PR workflow...Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2020-12-10Split up push and PR CI/CD and build all patches in series on PRsPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2020-12-07Use github actions for CI buildsPeter Jones
This could still use a bit of work, but it's better than Travis failing... 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-10-15Fix some mokmanager deletion pathsPeter Jones
This fixes several codepaths where MokList and MokListX are supposed to be deleted, but are not. It also adds debug logging to much of the deletion codepath.
2020-09-09Fix buffer overrun due DEFAULT_LOADER length miscalculationJavier Martinez Canillas
The DEFAULT_LOADER is a UCS-2 string and the StrLen() function returns the number of UCS-2 encoded characters in the string. But the allocated memory is in bytes, so only half of the needed memory to store it is allocated. This leads to a buffer overrun when the StrCpy() function attempts to copy the DEFAULT_LOADER to the allocated buffer. Fixes: 354bd9b1931 ("Actually check for errors from set_second_stage()") Reported-by: Stuart Hayes <stuart_hayes@dell.com> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2020-08-04mirror_one_mok_variable(): round allocation up to a full pagePeter Jones
The code currently computes the size of the MoK variable in ram and rounds up to a full page, but then actually allocates the exact size, rather than the rounded up version. This should be completely safe, but the intent was to round up to at least the page size boundary, and to always guarantee rounding up /some/, to ensure extra 0-bytes at the end of the buffer. 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-23Make openssl accept the right set of KU/EKUsPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com> Upstream: pr#211
2020-07-23Handle binaries with multiple signatures.Peter Jones
This adds support for multiple signatures. It first tries validating the binary by hash, first against our dbx lists, then against our db lists. If it isn't allowed or rejected at that step, it continues to the normal routine of checking all the signatures. At this point it does *not* reject a binary just because a signature is by a cert on a dbx list, though that will override any db list that certificate is listed on. If at any point any assertion about the binary or signature list being well-formed fails, the binary is immediately rejected, though we do allow skipping over signatures which have an unsupported sig->Hdr.wCertificateType. Signed-off-by: Peter Jones <pjones@redhat.com> Upstream: pr#210