Commit Graph

32 Commits

Author SHA1 Message Date
Peter Jones
9c64b6278c Make sure MIN() and MAX() are always defined.
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-16 09:12:48 +01:00
Peter Jones
aedb8470bd Fix up a bunch of our license statements and add SPDX most places
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-16 09:12:48 +01:00
Peter Jones
5fb5537fa9 sbat: make the includes work like everything else.
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-15 18:40:07 +01:00
Peter Jones
94ad063e94 Add some linked list primitives.
This adds basic linked list structures, initializers, and iterators.

Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-13 12:58:23 -05:00
Peter Jones
16732ad128 Add the beginning of .sbat parsing stuff
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-13 11:02:59 -05:00
Peter Jones
dea41d4c27 Refactor some PE handling code
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-13 11:02:59 -05:00
Peter Jones
06e98a10f6 Move a bunch of PE-related stuff out of shim.c
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-13 11:02:59 -05:00
Peter Jones
edc08062f1 Fix pe.h -> peimage.h in /both/ places.
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-01 16:18:05 -05:00
Peter Jones
0172d43507 Work around some clang-format oddnesses
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-29 18:24:57 -05:00
Peter Jones
0789f48d70 Always use lower case for our local include file names.
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-29 18:24:57 -05:00
Peter Jones
fc4368fed5 Improve debug output some
Signed-off-by: Peter Jones <pjones@redhat.com>
Upstream: pr#213
2020-07-25 22:14:08 -04:00
Peter Jones
dd3a5d7125 Add support for vendor_db built-in shim authorized list.
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-23 22:22:04 -04:00
Peter Jones
7d542805ba Make cert.S not impossible to read.
Signed-off-by: Peter Jones <pjones@redhat.com>
Upstream: pr#206
2020-07-23 20:53:24 -04:00
Peter Jones
1b382ef850 shim: Rework pause functions and add read_counter()
Signed-off-by: Peter Jones <pjones@redhat.com>
Upstream-commit-id: fc6b0bca84e
2020-07-23 20:52:12 -04:00
Gary Lin
7a3638173e shim: only include shim_cert.h in shim.c
The shim_cert array was declared as a static array, and every user of
shim_cert.h would create a shim_cert array for its own and grow the file
size. To remove the unnecessary duplicate shim_cert arrays, this commit
declares shim_cert in shim.c while other users still can access the
array through the external variables: build_cert and build_cert_size.

Signed-off-by: Gary Lin <glin@suse.com>
Upstream-commit-id: 4e2d62f0f4e
2020-07-23 20:52:12 -04:00
Peter Jones
ff6e5cda13 mok: consolidate mirroring code in a helper instead of using goto
There's no reason to complicate the logic with a goto here, instead just
pull the logic we're jumping to out to a helper function.

Signed-off-by: Peter Jones <pjones@redhat.com>
Upstream-commit-id: 29c11483101
2020-07-23 20:52:12 -04:00
Gary Lin
409b59af29 Fix typo in debug path in shim.h
Signed-off-by: Gary Lin <glin@suse.com>
Upstream-commit-id: a98c20bbdbb
2020-07-23 20:51:18 -04:00
Hans de Goede
1fe31ee1b4 console: Add console_print and console_print_at helpers
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-12 18:00:41 -04:00
Peter Jones
4181a16f62 shim: Make our variable validation and mirroring table driven.
This makes it so shim's idea of Mok variables all resides in one table
of data, and we don't need a bunch of nearly identical ad-hoc functions
to handle each of them.

Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12 16:21:43 -04:00
Peter Jones
dd712378a7 shim: make everything use a common perror() call.
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12 16:21:43 -04:00
Peter Jones
9fdca5bbe1 Don't use uefi_call_wrapper(), ever.
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-12 16:21:43 -04:00
Peter Jones
7ee19bdc41 Use gcc's offsetof() instead of hacking out our own.
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12 16:21:43 -04:00
Peter Jones
b953468e91 Don't have tons of local guid definitions for no reason at all.
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12 16:21:43 -04:00
Peter Jones
dc62a3c4dc Move includes around to clean the source tree up a bit.
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12 16:21:43 -04:00
Peter Jones
25f6fd08cd try to show errors more usefully.
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-09-13 15:18:28 -04:00
Peter Jones
19a7e1bcd5 Add some defaults and a syntastic file so vim helps more.
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-09-13 15:00:22 -04:00
Peter Jones
7ad94952cd Ensure that apps launched by shim get correct BS->Exit() behavior
Right now applications run by shim get our wrapper for Exit(), but it
doesn't do as much cleanup as it should - shim itself also exits, but
currently is not doing all the cleanup it should be doing.

This changes it so all of shim's cleanup is also performed.

Based on a patch and lots of review from Gary Lin.

Signed-off-by: Peter Jones <pjones@redhat.com>
2015-06-11 13:25:56 -04:00
Peter Jones
2901506937 Make SHIM_LOCK_GUID a first-class object with a symbol.
Right now the CA is checking if shim builds expose a particular version
of the shim protocol.  To do this, they're looking for SHIM_LOCK_GUID's
value in the resulting binary.

Currently, with SHIM_LOCK_GUID as a macro that gets assigned to local
variables, that means they have to compensate for mov instructions mixed
in with the actual value.  This is completely absurd, so promote it to a
first-class object with a symbol to make it both easy to find and
continuous.

Signed-off-by: Peter Jones <pjones@redhat.com>
2013-09-23 10:40:49 -04:00
Matthew Garrett
0848fab98d Switch to using db format for MokList and MokNew
Using the same format as the UEFI key databases makes it easier for the
kernel to parse and extract keys from MOK, and also permits MOK to contain
multiple key or hash types. Additionally, add support for enrolling hashes.
2012-10-12 19:55:20 -04:00
Matthew Garrett
21543b6c8e We're not MSABI, so don't advertise this as such 2012-07-05 12:52:42 -04:00
Peter Jones
303724021c Fix typos. 2012-06-18 11:36:57 -04:00
Matthew Garrett
f4b2473401 Install a protocol for sharing code with grub 2012-06-05 10:52:30 -04:00