summaryrefslogtreecommitdiff
path: root/Makefile
AgeCommit message (Collapse)Author
2024-01-22Bump version to 15.815.8Peter Jones
What's changed * Various CVE fixes: CVE-2023-40546 mok: fix LogError() invocation CVE-2023-40547 - avoid incorrectly trusting HTTP headers CVE-2023-40548 Fix integer overflow on SBAT section size on 32-bit system CVE-2023-40549 Authenticode: verify that the signature header is in bounds. CVE-2023-40550 pe: Fix an out-of-bound read in verify_buffer_sbat() CVE-2023-40551: pe-relocate: Fix bounds check for MZ binaries * Add make infrastructure to set the NX_COMPAT flag by @vathpela in https://github.com/rhboot/shim/pull/530 * Make sbat_var.S parse right with buggy gcc/binutils by @vathpela in https://github.com/rhboot/shim/pull/535 * Drop invalid calls to CRYPTO_set_mem_functions by @nicholasbishop in https://github.com/rhboot/shim/pull/537 * pe: Align section size up to page size for mem attrs by @nicholasbishop in https://github.com/rhboot/shim/pull/539 * test-sbat: Fix exit code by @vathpela in https://github.com/rhboot/shim/pull/540 * pe: Add IS_PAGE_ALIGNED macro by @nicholasbishop in https://github.com/rhboot/shim/pull/541 * CryptoPkg/BaseCryptLib: Fix buffer overflow issue in realloc wrapper by @nicholasbishop in https://github.com/rhboot/shim/pull/546 * Don't loop forever in load_certs() with buggy firmware by @rmetrich in https://github.com/rhboot/shim/pull/547 * Block Debian grub binaries with SBAT < 4 by @steve-mcintyre in https://github.com/rhboot/shim/pull/550 * Shim unable to locate grubx64 in PXE boot mode when grubx64 is stored in a different file path by @Alberto-Perez-Guevara in https://github.com/rhboot/shim/pull/551 * Further improve load_certs() for non-compliant drivers/firmwares by @pbatard in https://github.com/rhboot/shim/pull/560 * pe: only process RelocDir->Size of reloc section by @mikebeaton in https://github.com/rhboot/shim/pull/562 * Rename 'msecs' to 'usecs' to avoid potential confusion by @aronowski in https://github.com/rhboot/shim/pull/563 * Optionally allow to keep shim protocol installed by @bluca in https://github.com/rhboot/shim/pull/565 * SBAT-related documents formatting and spelling by @aronowski in https://github.com/rhboot/shim/pull/566 * Add SbatLevel_Variable.txt to document the various revocations by @jsetje in https://github.com/rhboot/shim/pull/569 * Add a security contact email address in README.md by @vathpela in https://github.com/rhboot/shim/pull/572 * Use -Wno-unused-but-set-variable for Cryptlib and OpenSSL by @vathpela in https://github.com/rhboot/shim/pull/576 * mok: fix LogError() invocation by @vathpela in https://github.com/rhboot/shim/pull/577 * Minor housekeeping by @vathpela in https://github.com/rhboot/shim/pull/578 * Test ImageAddress() by @vathpela in https://github.com/rhboot/shim/pull/579 * FreePages() is used to return memory allocated by AllocatePages() by @dennis-tseng99 in https://github.com/rhboot/shim/pull/580 * Size should minus 1 when calculating 'RelocBaseEnd' by @jsetje in https://github.com/rhboot/shim/pull/581 * Verify signature before verifying sbat levels by @jsetje in https://github.com/rhboot/shim/pull/583 * Add libFuzzer support for csv.c and sbat.c by @vathpela in https://github.com/rhboot/shim/pull/584 * mok: Avoid underflow in maximum variable size calculation by @alpernebbi in https://github.com/rhboot/shim/pull/587 * Housekeeping by @vathpela in https://github.com/rhboot/shim/pull/605 Signed-off-by: Peter Jones <pjones@redhat.com>
2023-08-25compile_commands.json: remove stuff clang doesn't likePeter Jones
This is a "creature comfort" change to make it so gcc-specific options don't make it into compile_commands.json. Signed-off-by: Peter Jones <pjones@redhat.com>
2023-08-25Make some of the static analysis tools a little easier to runPeter Jones
With "gcc -fanalyzer" and "scan-build", it's convenient to be able to continue even though the compiler has returned error on one or more source files. This makes it so compiler errors are ignored in some of those cases. Signed-off-by: Peter Jones <pjones@redhat.com>
2023-06-29Add libFuzzer support for csv.cPeter Jones
shim takes several forms of input from several sources that are not necessarily trustworthy. As such, we need to take measures to validate that we don't have unacceptable results from bad inputs. One such measure is "fuzzing" the inputs which parse untrusted data by running them with randomized or partially randomized input. This change adds such testing using clang's "libFuzzer" to our CSV parser. I've run this on 24-cores at 4GHz for half an hour, and so far each fuzzer has converged on 79% coverage. I expect the 21% that's not getting covered are the EFI API mock interfaces we're building in from test.c and similar. So far no errors have been found, which is what was expected since this particular API is being manually fuzzed with ~8kB of /dev/urandom on every build since 2021-02-23. Signed-off-by: Peter Jones <pjones@redhat.com>
2023-06-23Split pe.c up even more.Peter Jones
This moves the parts of pe.c that *don't* depend on Cryptlib into pe-relocate.c, so we can write test cases for them without having to make a second openssl build without EFI support. Signed-off-by: Peter Jones <pjones@redhat.com>
2023-06-23Add a make rule for compile_commands.jsonPeter Jones
This adds a make rule to generate compile_commands.json, which some verifier tools depend on. Signed-off-by: Peter Jones <pjones@redhat.com>
2023-01-27Enable the NX compatibility flag by default.Peter Jones
Currently by default, when we build shim we do not set the PE NX-compatibility DLL Characteristic flag. This signifies to the firmware that shim (including the components it loads) is not prepared for several related firmware changes: - non-executable stack - non-executable pages from AllocatePages()/AllocatePool()/etc. - non-writable 0 page (not strictly related but some firmware will be transitioning at the same time) - the need to use the UEFI 2.10 Memory Attribute Protocol to set page permissions. This patch changes that default to be enabled by default. Distributors of shim will need to ensure that either their builds disable this bit (using "post-process-pe -N"), or that the bootloaders and kernels you support loading are all compliant with this change. A new make variable, POST_PROCESS_PE_FLAGS, has been added to simplify doing so. Signed-off-by: Peter Jones <pjones@redhat.com>
2022-11-16Update version to 15.715.7Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2022-08-03Make SBAT variable payload introspectableChris Coulson
Given a set of EFI variables and boot assets, it should be possible to compute what the value of PCR 7 will be on the next boot. As shim manages the contents of the SbatLevel variable and this is measured to PCR 7, export the payloads that shim contains in a new COFF section (.sbatlevel) so that it can be introspected by code outside of shim. The new section works a bit like .vendor_cert - it contains a header and then the payload. In this case, the header contains no size fields because the strings are NULL terminated. Shim uses this new section internally in set_sbat_uefi_variable. The .sbatlevel section starts with a 4 byte version field which is not used by shim but may be useful for external auditors if the format of the section contents change in the future. Signed-off-by: Chris Coulson <chris.coulson@canonical.com>
2022-06-01bump version to shim-15.615.6Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2022-05-31shim-15.6~rc215.6-rc2Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2022-05-24shim-15.6~rc1Peter Jones
2022-05-18make: unbreak scan-build again for gnu-efiPeter Jones
When using clang-analyzer, scan-build sets CC to /usr/bin/../libexec/ccc-analyzer, which for whatever reason when we're in the sub-make to build gnu-efi, then gets confused and invokes gcc rather than clang. This causes gnu-efi's attempt to check which compiler it's using to fail, because "/usr/bin/../libexec/ccc-analyzer -v" invokes GCC. At that point ccc-analyzer complains that it can't find the clang invocation in its own output, which it chose not to use clang for, as such: /usr/bin/../libexec/ccc-analyzer -I/home/pjones/devel/github.com/shim/worktree/gnu-efi//lib -I/home/pjones/devel/github.com/shim/worktree/gnu-efi/inc -I/home/pjones/devel/github.com/shim/worktree/gnu-efi/inc/x86_64 -I/home/pjones/devel/github.com/shim/worktree/gnu-efi/inc/protocol -Wno-error=pragmas -mno-red-zone -mno-avx -fpic -Os -Wall -Wextra -Wno-missing-field-initializers -Werror -fshort-wchar -fno-strict-aliasing -ffreestanding -fno-stack-protector -fno-stack-check -nostdinc -isystem /home/pjones/devel/github.com/shim/worktree/gnu-efi/../include/system -isystem /usr/lib/gcc/x86_64-redhat-linux/11/include -DCONFIG_x86_64 -DGNU_EFI_USE_MS_ABI -DGNU_EFI_USE_EXTERNAL_STDARG -maccumulate-outgoing-args --std=c11 -c /home/pjones/devel/github.com/shim/worktree/gnu-efi//lib/smbios.c -o smbios.o could not find clang line make[3]: *** [/home/pjones/devel/github.com/shim/worktree/gnu-efi//lib/../Make.rules:52: smbios.o] Error 1 This patch passes CCC_CC=$(COMPILER) to the gnu-efi sub-make, which forces ccc-analyzer to use $(COMPILER), which is still clang. Signed-off-by: Peter Jones <pjones@redhat.com>
2022-05-17make: don't treat cert.S speciallyPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2022-02-15Update to version 15.515.5Robbie Harwood
Mark this officially as shim 15.5 Signed-off-by: Robbie Harwood <rharwood@redhat.com>
2022-02-03Remove post-proccess-pe on 'make clean'Peter Jones
This resolves issue #442 Signed-off-by: Peter Jones <pjones@redhat.com>
2022-02-03Fix the version string for -rc2Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-11-03Bump the version number to 15.5~rc1Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-07tests: Add a 'test-coverage' make target for gcovPeter Jones
This adds a make target that builds the tests with gcov so we can identify coverage gaps in the test suite. It also makes a special test-lto invocation, so that a developer can run these tests with the somewhat different optimization results LTO will have. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-07shim/mm/fb: move global state to its own source filePeter Jones
This moves the globals from shim.c (and lib/console.c) into their own file, to make it so that unit tests can more easily link against code that uses that state. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-07tests: clean up temp data after running testsPeter Jones
This makes sure we clean up the builds that aren't for the EFI environment after we build and run the unit tests. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-07More minor improvements to support for COMPILER=clangPeter Jones
A couple of places snuck in where building with COMPILER=clang didn't work right; this makes them work again. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-09-03fallback: add compile option FALLBACK_NONINTERACTIVEDimitri John Ledkov
In the cloud, all boots are non-interactive with keyboard and console access either typically not available or prohibited. Also clouds always do firstboot via fallback. This currently results in an unacceptable 5s boot delay whilst fallback offers interactive reset options that cannot be actioned. In Ubuntu, we'd like to make fallback noninteractive by default without any boot delays, due to bootspeed impact on firstboot of the preinstalled images. Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/shim/+bug/1922581 Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
2021-07-20arm/aa64: fix the size of .rela* sectionsGary Lin
The previous commit(*) merged .rel* and .dyn* into .rodata, and this made ld to generate the wrong size for .rela* sections that covered other unrelated sections. When the EFI image was loaded, _relocate() went through the unexpected data and may cause unexpected crash. This commit moves .rel* and .dyn* out of .rodata in the ld script but also moves the related variables, such as _evrodata, _rodata_size, and _rodata_vsize, to the end of the new .dyn section, so that the crafted pe-coff section header for .rodata still covers our new .rela and .dyn sections. (*) 212ba30544f ("arm/aa64 targets: put .rel* and .dyn* in .rodata") Fix issue: https://github.com/rhboot/shim/issues/371 Signed-off-by: Gary Lin <glin@suse.com>
2021-07-20shim: move the bulk of set_second_stage() to its own filePeter Jones
This moves set_second_stage() and some of the helper functions it uses out of shim.c, so that it's easier to write test cases for. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-05-25Post-process our PE to be sure.Peter Jones
On some versions of binutils[0], including binutils-2.23.52.0.1-55.el7, do not correctly initialize the data when computing the PE optional header checksum. Unfortunately, this means that any time you get a build that reproduces correctly using the version of objcopy from those versions, it's just a matter of luck. This patch introduces a new utility program, post-process-pe, which does some basic validation of the resulting binaries, and if necessary, performs some minor repairs: - sets the timestamp to 0 - this was previously done with dd using constant offsets that aren't really safe. - re-computes the checksum. [0] I suspect, but have not yet fully verified, that this is accidentally fixed by the following upstream binutils commit: commit cf7a3c01d82abdf110ef85ab770e5997d8ac28ac Author: Alan Modra <amodra@gmail.com> Date: Tue Dec 15 22:09:30 2020 +1030 Lose some COFF/PE static vars, and peicode.h constify This patch tidies some COFF and PE code that unnecessarily used static variables to communicate between functions. v2 - MAP_PRIVATE was totally wrong... Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-30Update version to 15.415.4Peter Jones
Mark this officially as shim 15.4 Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-30arm/aa64 targets: put .rel* and .dyn* in .rodataPeter Jones
For every problem, there exists a solution which is simple, elegant, and wrong. d74629207188d290810db15dbfe91a89e7751ffb is that solution. This patch leaves that intact, but adds a .rodata section wrapping .rel/.rela and .dynsym/.dynstr., so that they are correctly incorporated into the authenticode hash. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-29Fix openssl's 'make clean'Peter Jones
2021-03-28Makefile: sort vendor sbats to remove duplicatesChris Co
If no TOPDIR is defined and a vendor sbat CSV is placed in $(BUILDDIR)/data/sbat.*.csv, objcopy fails with the following error. objcopy --add-section .sbat=/shim/data/sbat.csv \ --set-section-flags .sbat=contents,alloc,load,readonly,data \ sbat_data.o objcopy --add-section ".sbat.microsoft=sbat.microsoft.csv" sbat_data.o objcopy --add-section ".sbat.microsoft=sbat.microsoft.csv" sbat_data.o objcopy:stuf2iKG: can't add section '.sbat.microsoft': bad value make: *** [Makefile:120: sbat_data.o] Error 1 The sbat.vendor.csv is getting included twice in VENDOR_SBATS. Use sort to ensure unique entries in VENDOR_SBATS Signed-off-by: Chris Co <chrco@microsoft.com>
2021-03-26make: Fix search paths for vendor sbat.*.csv filesPeter Jones
Currently if you're building in a subdirectory, we're not correctly finding vendor sbat.foo.csv files if they're in $(TOPDIR)/data/sbat.foo.csv rather than $(BUILDDIR)/data/sbat.foo.csv. This patch makes it search both of those during the build. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-26make: make 'make install-as-data' install BOOT*.CSVPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-25Make building outside of the top directory work.Peter Jones
This also makes the cross-build targets (and not the others) /use/ this functionality, so we'll catch it if we break it again. This fixes issue #340. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-23Bump version to 15.3upstream/shim-15.315.3Peter Jones
Here's the full shortlog since shim 15.2: Alex Burmashev (4): strndupa: allocate len + 1, so that \0 is not lost add list_empty to linked list primitives pe.c: parse SBAT variable and perform basic verification Fix compilation for older gcc Chris Co (2): sbat: add minor fixes to parse_sbat Add initial sbat unit testing code Chris Coulson (8): Fix sbsign command usage Rename check_{white,black}list to check_{allow,deny}list build: Pass the correct paths to sbsign Include missing .text sections in PE/COFF binary sbat: Don't assume VirtualSize == SizeOfRawData Ensure that MOK variable mirroring creates well formed ESLs Avoid creating unnecessary mirrored MOK variables Fix boot failures due to variable size constraints Colin Walters (1): Convert README -> README.md Dimitri John Ledkov (2): Add testsuite to the github pull request workflow. Drop comments, and make push workflow use same matrix as pullrequest. Gary Lin (9): src/netboot.c: remove the execute bit lib: move print_crypto_errors() out of console.c console: Move the countdown function to console.c fallback: show a countdown menu before reset sbat: fix the gcc warnings sbat: fix the residual "resource section" for SBAT Restore loaded image of shim at Exit() Set the section flags for .sbat arm and aarch64: include the aligned part in SizeOfRawData of sbat Hai Huang (1): Fix EV_EFI_VARIABLE_AUTHORITY event in eventlog Jan Setje-Eilers (8): Add Secure Boot Advanced Targeting (SBAT) specification document Add --set-section-alignment '.sbat=512' to objcopy command line Drop --set-section-alignment from Makefile since linker ALIGN(4096) already enforces the alignment, clarify that objcopy only needs to do the alignment in the SBAT spec. If the SBAT UEFI variable is not set, initialize it as a bootservices variable. Javier Martinez Canillas (10): Add a .sbat section to EFI binaries Add a function to parse the SBAT metadata from the .sbat section sbat: remove unused buffer parameter in parse_sbat() function sbat: use correct type for parse_sbat_var() return value Don't re-parse the SBAT EFI variable for each binary we load. sbat: include NULL terminator when calculating buffer end in parse_sbat() shim: initialize OpenSSL after parsing SBAT data sbat: make shim to parse it's own .sbat section on init shim: Fix a NULL pointer dereference caused by start not being set shim: Use the default loader if an EFI_LOAD_OPTION can't be parsed Jia Zhang (1): Ignore *.hash João Paulo Rechi Vita (8): fallback: Store label size instead of calculating on every use fallback: Consider all Boot* vars when checking for duplicates fallback: Only use VerbosePrint for debug messages fallback: Be silent by default fallback: Print original BootOrder value in verbose mode fallback: Wait before chainloading in verbose mode fallback: Make verbose mode's wait time configurable fallback: Allow defining FALLBACK_VERBOSE at build time Lisa White (1): Fix typo in a comment Luca Boccassi (1): Makefile: use fixed build host if SOURCE_DATE_EPOCH is defined Mathieu Trudel-Lapierre (1): Add mm/fb hashing to TODO, put that and related things under 'Reproducible builds' Matthew Garrett (1): build: Import gnu-efi as a submodule and build against it Nicholas Bishop (1): BUILDING: Fix a typo Paul Menzel (1): README: Remove superfluous *and* Paul Moore (7): shim: compile time option to bypass the ExitBootServices() check build: add some basic $EFI_PATH checking SBAT: fix some typos in the SBAT docs SBAT: update the raw Markdown to look less terrible openssl: fix various build errors and warnings shim: attempt to improve the argument handling build: load local build configuration from Make.local if present Peter Jones (119): Use github actions for CI builds Split up push and PR CI/CD and build all patches in series on PRs Try to kick the github PR workflow... Add a .clang-format file. Always use lower case for our local include file names. Work around some clang-format oddnesses Renaming PeImage.h to pe.h wasn't actually a good idea. Fix pe.h -> peimage.h in /both/ places. github workflows: Unify the x86 pull request build rules steps github workflows: add the sbat branch to one PR builds run for efi bins: add an easy way for vendors to add .sbat data Remove my .syntastic_c_config, it doesn't belong in the repo. includes: add strchra() and strchrnula() impls Move a bunch of PE-related stuff out of shim.c Refactor some PE handling code Add some more PE helpers we need for SBAT Add the beginning of .sbat parsing stuff SBAT: parse a copy of the table that's got a NUL at the end Add an example SBAT workflow document Add some linked list primitives. get_variable: always allocate a NUL character at the end. add an ascii strndup() implementation. sbat: make the includes work like everything else. We're not using travis-build.sh any more. Try to make coverity.mk work without cov-build installed. Try to make scan-build.mk work without scan-build installed. Add some more TODOs for shim 16 Add another unfortunate TODO entry. Add some *more* TODO tasks. Add fallback boot loop detection to TODO Also ignore .sw? Add screen logs to .gitignore Add .cer/.crt/.esl to .gitignore BUILDING: fix missing DISABLE_EBS_PROTECTION section Re-alphabetize .gitignore. .gitignore: add build dirs and shim_cert.h .gitignore: ignore .gdbinit Fix up a bunch of our license statements and add SPDX most places SPDX: Clarify the attribution for crypt_blowfish SPDX: Clarify the attribution for James's lib/ code Make sure MIN() and MAX() are always defined. console: Fix a typo in the EFI warning list in gnu-efi Fix a bunch of trivial trailing whitespace issues. Make httpboot.c always get built. Make the variable name and pointer const in all of our efi vars functions Add ENABLE_SHIM_DEVEL config to change what our debug variable name is Use gcc -Os instead of -O0. sbat: clang-format the whole thing. SBAT: make the variable be CSV in our spec. SBAT: Fix all the docs examples to start with version 1 Fix an off by one in strnlena() shim: use an enum for efi_main's error messages. sbat: drop the struct sbat and just use two variables instead parse_sbat: handle the realloc failure leak and batch allocations. pe.c: move sbat verification to its own function. sbat: Fix two NULL derefs found with "gcc -fanalyzer" tpm: minor cleanup: use EV_IPL not 0xd Document struct mok_state_variable better. SBAT: mirror SBAT to SbatRT and extend to PCR7 + log Move the coverity and scan-build makefiles out of the top directory Make 'make fanalyzer' targets compiler.h: fix a typo and add some more function attribute macros Fix all the places we need UNUSED on arguments. Tidy up our string primitives... Add a list_size() primitive Move is_utf8_bom() to str.h includes: include all gnu-efi includes at one place. Fix our debuginfo paths hopefully Add a stand-alone CSV parser. SBAT: make our sbat section parser use the csv parser SBAT: make our SBAT variable parser use the CSV parser make 'make test' able to run unit test harnesses Add a tester for our string functions. Add test cases for our CSV parser. Fix-up and enable a bunch of .sbat section parsing tests. Make verify_sbat() more testable Fix two errant 'shim,0' outdated sbat cases. Add get_variable_size()/set_variable()del_variable() wrappers. CI: try to update submodules CI: show our compilation when it fails Re-organize a bunch of CFLAGS-related makefile bits Minor OpenSSL fixes static analysis: make our build targets work better More minor makefile cleanups Switch to using -std=gnu11 Don't use WCHAR even when we're assigning wide string literals Cryptlib: make some Str*() args const. Restructure our includes. Fix Cryptlib's va_* definitions. Consolidate most of our standard lib functions to lib Fix stdarg to work the same everywhere. Add some test cases, and make "make test" actually work. make: use -Wextra (minus some obnoxious bits) Test our strncmp vs known failing ones as well Add more string test cases. set_sbat_uefi_variable(): avoid comparing unsafe data shim: simplify sbat self-check logic. linker scripts: put .sbat after _edata arm arches: include .sbat in our section headers. Fix the compiler when invoking scan-build/fanalyzer/etc openssl: nerf some -W flags for clang. get_variable_attr(): fix a nit scan-build found. Fix include order More va_* work Don't even try to use builtins, just make sure we have the same types. Make ENABLE_SHIM_DEVEL work better. sbat variable: use UEFI_VAR_NV_BS_RT when we've got ENABLE_SHIM_DEVEL set_sbat_uefi_variable(): add a pile of debug prints. set_sbat_uefi_variable(): align some decisions that are off-by-one. Fix a plausible NULL dereference. 'make test': try harder to make it build in the right order. Nerf an unnecessary string test on arm. arm and aarch64: fix some PE headers. Make 'make test' work on gcc 4.8.5 Don't set LIBDIR in CI builds any more. Fix cross-compilation from x86_64->i686 Try multi-arch CI building using cross compilation Update 'make archive' to include gnu-efi Bump version to 15.3 Steve McIntyre (5): Second attempt at SBAT doc tweaks Fixups after Peter's review Fix bashisms in Make.coverity Stop using EFI_PATH, and error out if people try to use it Fix up build of test code using gcc 8 Thomas Frauendorfer | Miray Software (2): Fix column size check in SBAT variable parsing. Sort input file names in lib/Makefile Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-23Update 'make archive' to include gnu-efiPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-22Fix cross-compilation from x86_64->i686Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-15Stop using EFI_PATH, and error out if people try to use itSteve McIntyre
We need to be using our patched version of gnu-efi Signed-off-by: Steve McIntyre <93sam@debian.org>
2021-03-12Make ENABLE_SHIM_DEVEL work better.Peter Jones
This fixes ENABLE_SHIM_DEVEL to actually work, and also makes our "goto die" failure behavior change (to wait considerably longer) based on it. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-12More va_* workPeter Jones
Be much more explicit about exactly which va_* stuff comes from which ABI in both shim and gnu-efi. This fixes the problem where we see: | (null):0:(null)() v->name:"(null)" v->rtname:"(null)" | (null):0:(null)() v->data_size:0 v->data:0x0 and similar messages where everything is NULL. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-10fallback: Allow defining FALLBACK_VERBOSE at build timeJoão Paulo Rechi Vita
If FALLBACK_VERBOSE is defined at build time the resulting fallback will always be verbose despite having the EFI variable defined or not, which facilitates testing in some scenarios. Signed-off-by: João Paulo Rechi Vita <jprvita@endlessos.org>
2021-03-10fallback: Make verbose mode's wait time configurableJoão Paulo Rechi Vita
Make it possible to configure at build time for how long fallback will wait before moving to the next step when in verbose mode. Also remind the user they can press the Pause key to pause the boot process at that point. Signed-off-by: João Paulo Rechi Vita <jprvita@endlessos.org>
2021-03-10Consolidate most of our standard lib functions to libPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-10Restructure our includes.Peter Jones
This re-structures our includes so we can be sure everything is always including all the system headers in a uniform, predictable way. Temporarily it also adds a bunch of junk at all the places we use variadic functions to specifically pick either the MS (cdecl) or ELF ABIs. I'm not 100% sure that's all correct (see later patch) but it's enough to allow this to build. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-09build: Import gnu-efi as a submodule and build against itMatthew Garrett
Shim is rather more friendly with EFI internals than most code, and as a result can end up making assumptions that are out of step with those made by gnu-efi. Since both projects are developed independently, and since distributions are often trying to build versions of shim against whatever version of gnu-efi they are shipping, this can result in awkward build failures. The easiest way to handle this is to use a git submodule and import a known-good version of shim directly into the build tree. Given static linking, this will also make reproducible builds easier. Plus some changes from pjones: - Fix up some more include paths - more fine grained clean rules - use our make ARCH - use an rhboot/ repo for the gnu-efi remote Signed-off-by: Matthew Garrett <mjg59@google.com>
2021-03-09Re-organize a bunch of CFLAGS-related makefile bitsPeter Jones
Some of our makefile bits are a mess, as you may have noticed, making changes to them difficult to review. This patch attempts to make some parts of them vaguely less of a mess, in order to facilitate review of follow-up changes. To so it: - coalesces feature flags, optimizations, -W{no-,}, -W{no-}error, include directives, and define/undefine directives into (mostly) separate groups. - exports them as appropriate so the sub-makes can use them - Makes sure we have -Wextra -Werror everywhere, but adds -Wno-foo and -Wno-error=foo directives at the appropriate places to keep the net warnings the same. - makes the arch defines in Cryptlib and Cryptlib/OpenSSL use the appropriate ones, with no attempt to make them less stupid, without changing the overall order. - coalesces the various includes, with no attempt to make them less stupid, without changing the overall order. - One giant glaring whitespace fix in Cryptlib/OpenSSL/Makefile Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-09Set the section flags for .sbatGary Lin
When using "objcopy -O binary", it silently drops the sections without "alloc" or "load" or the sections with "unload". Since we didn't set any section flags for .sbat, it just contains the "readonly" flag and objcopy ignored the section totally when generating EFI images for ARM32 and AArch64. This commit sets the common read-only data section flags to .sbat so that objcopy would always copy the section to the final EFI image. Signed-off-by: Gary Lin <glin@suse.com>
2021-02-25make 'make test' able to run unit test harnessesPeter Jones
This adds a couple of make targets to do unit tests that are linked to libc: test-FOO : builds and runs test-FOO for any test-FOO.c test : builds and runs all test-FOO tests Note that building and running this test does not quite work yet /on this branch/. In order to do that, we need some cleanups and reorganizing that I don't want to push just yet, which can be found on https://github.com/rhboot/shim/tree/test-reorg Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-25Add a stand-alone CSV parser.Peter Jones
This adds a simple to use, one-function-call CSV parser that takes a blob of data and gives you a linked list with an array of values. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-25Make 'make fanalyzer' targetsPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-25Move the coverity and scan-build makefiles out of the top directoryPeter Jones
I'm adding even more of this stuff, and it's feeling pretty cluttered, so this moves the scan-build and coverity makefiles into include/, where we'll see them less. Signed-off-by: Peter Jones <pjones@redhat.com>