Commit Graph

127 Commits

Author SHA1 Message Date
Peter Jones
b32a3ce14c Don't print that fallback isn't found in should_use_fallback()
The call can simply fail if it isn't found - which will be the case on
removeable install media.

Signed-off-by: Peter Jones <pjones@redhat.com>
2013-09-16 09:27:08 -04:00
Peter Jones
928886457e Fix some pointer casting issues.
This also fixes the size of an empty vendor_cert or dbx_cert.

Signed-off-by: Peter Jones <shim-owner@fedoraproject.org>
2013-06-11 14:59:48 -04:00
Peter Jones
5bb3e64ed8 Use the correct define on Open.
The value here doesn't actually change any, but we should still use the
right name.

Signed-off-by: Peter Jones <pjones@redhat.com>
2013-05-15 13:38:44 -04:00
Peter Jones
c9d11306e4 Add some error messages when things don't work.
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-05-15 13:38:27 -04:00
Peter Jones
2e7fc28d92 Remove some unnecessary code.
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-05-15 13:38:00 -04:00
Peter Jones
35b0b55b3e Fix some minor type errors.
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-05-15 13:37:15 -04:00
Peter Jones
6d6b022169 Make shim use fallback when appropriate.
If we're called as /BOOT/EFI/BOOT*.EFI, and /BOOT/EFI/FALLBACK.EFI exists,
give it a shot.

Signed-off-by: Peter Jones <pjones@redhat.com>
2013-04-30 09:46:22 -04:00
Gary Ching-Pang Lin
0283024e0e Adopt the UEFI shell style LoadOptions
The previous commit, 14d4b8e, caused shim failed to parse the name
of the 2nd stage loader in UEFI shell. Amend parsing of the name the
2nd stage loader to be compatible with UEFI shell.

To create an boot entry for elilo.efi:

 # efibootmgr -c -L "shim elilo" -l "efi\\shim.efi" -u "shim.efi elilo.efi"
2013-04-30 09:45:45 -04:00
Peter Jones
4a3013c76c Get rid of extra label.
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-04-26 12:12:48 -04:00
Peter Jones
155a76bb86 Don't put the directory in the file path twice.
Sometimes when we're creating paths, the ImagePath can contain the
directory name already.  If that happens, don't add it in again.

Signed-off-by: Peter Jones <pjones@redhat.com>
2013-04-26 11:44:28 -04:00
Peter Jones
6e1bd3dcb7 UEFI Shell sticks the UCS2 of li->FilePath in li->LoadOptions. Ignore it.
If li->LoadOptions tells us to execute our own binary, it's clearly not
what we want to do for the second stage.  So simply ignore that case.

Signed-off-by: Peter Jones <pjones@redhat.com>
2013-04-26 11:44:15 -04:00
Gary Ching-Pang Lin
92a136d823 Add support for deleting specific keys 2013-01-03 12:20:22 +08:00
Gary Ching-Pang Lin
09e2c93956 Get the second stage loader from the Load Options
This commit replaces the 2nd stage loader path with the first
argument in the Load Options and moves the rest arguments (if any)
to the Load Options for the 2nd stage loader.

For example, to make shim to load elilo.efi, just create a new
boot entry with efibootmgr:

 # efibootmgr -c -L "shim elilo" -l "efi\\shim.efi" -u "elilo.efi"
2012-12-10 16:34:35 +08:00
Matthew Garrett
8d311bc7e7 Remove debug code
secure_mode() was altered to always return true for debug purposes, and this
accidentally got committed to mainline. Fix that.
2012-11-27 23:52:27 -05:00
Matthew Garrett
ef8c9962a8 Sign MokManager with a locally-generated key
shim needs to verify that MokManager hasn't been modified, but we want to
be able to support configurations where shim is shipped without a vendor
certificate. This patch adds support for generating a certificate at build
time, incorporating the public half into shim and signing MokManager with
the private half. It uses pesign and nss, but still requires openssl for
key generation. Anyone using sbsign will need to figure this out for
themselves.
2012-11-26 13:43:50 -05:00
Matthew Garrett
4ad234f175 Merge branch 'mok' into netboot
Conflicts:
	shim.c
2012-11-01 15:29:23 -04:00
Matthew Garrett
20f6cde679 Add comments 2012-11-01 15:26:36 -04:00
Matthew Garrett
28a3e57c9a Merge branch 'mok' into netboot
Conflicts:
	Makefile
	shim.c
2012-11-01 10:45:22 -04:00
Matthew Garrett
201574d1be Fix AuthenticodeVerify loop
Cert needs to be modified inside the Index loop, not outside it. This is unlikely to
ever trigger since there will typically only be one X509 certificate per
EFI_SIGNATURE_LIST, but fix it anyway.
2012-11-01 10:39:31 -04:00
Matthew Garrett
058c0368ad Fix signature checking
We could potentially find a valid signature and then fail to validate it
due to not breaking out of the outer while loop.
2012-11-01 10:31:14 -04:00
Matthew Garrett
6f16162653 Fix double free
load_image() didn't allocate PathName, don't have it free it.
2012-11-01 10:12:20 -04:00
Matthew Garrett
ed711b02ec Fix up some types
Type-checking the UEFI calls picked up a couple of problems. Fix them up.
2012-11-01 09:46:51 -04:00
Matthew Garrett
0a0cd6ba77 Merge branch 'mok' of github.com:mjg59/shim into mok 2012-10-30 15:59:40 -04:00
Gary Ching-Pang Lin
8b7685b212 Check the vendor blacklist correctly 2012-10-30 10:35:36 -04:00
Matthew Garrett
832e5161b5 Boot unsigned binaries if we're not in secure mode
read_header would fail if the binary was unsigned, even if we weren't then
going to verify the signature. Move that check to the verify function
instead.
2012-10-24 00:10:29 -04:00
Matthew Garrett
cbe214072b Miscellaneous small fixups
Fixes for some small bugs noticed during review
2012-10-24 00:09:08 -04:00
Matthew Garrett
4049bc496f Merge branch 'mok' of github.com:mjg59/shim into mok 2012-10-23 15:45:04 -04:00
Matthew Garrett
d5a2d9ea08 Clean up checks for MokManager entry
Add a helper function and tidy up the calls for getting into MokManager
2012-10-23 13:01:25 -04:00
Peter Jones
5f0a358b63 Support a vendor-specific DBX list.
In some rare corner cases, it's useful to add a blacklist of things that
were allowed by a copy of shim that was never signed by the UEFI signing
service.  In these cases it's okay for them to go into a local dbx,
rather than taking up precious flash.

Signed-off-by: Peter Jones <pjones@redhat.com>
2012-10-23 11:47:41 -04:00
Matthew Garrett
801d1b936b Add MOK password auth
Add support for setting an MOK password. The OS passes down a password hash.
MokManager then presents an option for setting a password. Selecting it
prompts the user for the same password again. If they match, the hash is
enrolled into a boot services variable and MokManager will prompt for the
password whenever it's started.
2012-10-18 17:43:53 -04:00
Matthew Garrett
9eaadb0d11 Skip signature checking if insecure
If we're configured to run untrusted code, print a message and skip the
validation checks.
2012-10-18 17:43:53 -04:00
Matthew Garrett
9272bc5b84 Add support for disabling signature verification
Provide a mechanism for a physically present end user to disable signature
verification. This is handled by the OS passing down a variable that
contains a UINT32 and a SHA256 hash. If this variable is present, MokManager
prompts the user to choose whether to enable or disable signature validation
(depending on the value of the UINT32). They are then asked to type the
passphrase that matches the hash. This then saves a boot services variable
which is checked by shim, and if set will skip verification of signatures.
2012-10-18 17:41:52 -04:00
Matthew Garrett
1c5957068f Add draft version of Neil's netboot code 2012-10-12 20:14:14 -04:00
Matthew Garrett
683959d7ad Remove LoadImage/StartImage support
Some systems will show an error dialog if LoadImage() returned
EFI_ACCESS_DENIED, which then requires physical user interaction to skip.
Let's just remove the LoadImage/StartImage code, since the built-in code
is theoretically equivalent.
2012-10-12 19:55:20 -04:00
Matthew Garrett
0a6565c5ed 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
f394b22e86 Split out hashing
We want to be able to generate hashes, so split out the hash generation
function from the verification function
2012-10-11 12:24:36 -04:00
Matthew Garrett
ce6a5748b0 Add SHA1 support
In theory vendors could blacklist binaries with SHA1, so make sure we
calculate and check that hash as well.
2012-10-11 11:30:41 -04:00
Matthew Garrett
8cf182af8b Fall back to MokManager if grub failed to validate
If we can't verify grub, fall back to MokManager. This permits shipping a
copy of shim and MokManager without distributing a key, letting
distributions provide their own for user installation.
2012-10-06 17:20:30 -04:00
Gary Ching-Pang Lin
f3104a7314 Use LibDeleteVariable in gnu-efi 2012-10-02 11:55:44 +08:00
Gary Ching-Pang Lin
6919a3f7c7 Make sure the variables are not broken 2012-09-21 16:44:56 +08:00
Gary Ching-Pang Lin
6577945fba Reject the binary when there is no key in MokList 2012-09-21 15:10:31 +08:00
Gary Ching-Pang Lin
a1239f096b Check the MOK list correctly 2012-09-20 10:28:00 +08:00
Gary Ching-Pang Lin
1041805a18 Abandon the variable, MokMgmt 2012-09-19 14:54:35 +08:00
Gary Ching-Pang Lin
a903fb1088 Copy the MOK list to a RT variable
The RT variable, MokListRT, is a copy of MokList so that the
runtime applications can synchronize the key list without touching
the BS variable.
2012-09-11 17:43:44 +08:00
Gary Ching-Pang Lin
1342297309 Use the machine owner keys to verify images 2012-09-11 16:39:12 +08:00
Gary Ching-Pang Lin
cec6a0a964 Always try StartImage first 2012-09-11 16:37:02 +08:00
Gary Ching-Pang Lin
e470969e4e Only launch MokManager when necessary 2012-09-11 16:34:25 +08:00
Gary Ching-Pang Lin
31d3bd054a Retrieve attributes of variables
We have to make sure the machine owner key is stored in a BS
variable.
2012-09-11 16:31:05 +08:00
Gary Ching-Pang Lin
000c565c06 Merge branch 'master' into mok-prototype3
Conflicts:
	shim.c
2012-09-07 18:22:34 +08:00
Gary Ching-Pang Lin
4b34567dd5 Load MokManager for MOK management 2012-09-07 18:11:45 +08:00
Gary Ching-Pang Lin
822d089e3d Make the image loading process more generic 2012-09-07 17:43:21 +08:00
Peter Jones
7430b90148 Break out of our db checking loop at the appropriate time.
The break in check_db_cert is at the wrong level due to a typo in
indentation, and as a result only the last cert in the list can
correctly match.  Rectify that.

Signed-off-by: Peter Jones <pjones@redhat.com>
2012-09-06 12:13:44 -04:00
Matthew Garrett
ce78d2d250 Use the file size, not the image size field, for verification. 2012-09-06 12:13:44 -04:00
Peter Jones
8518b8cc1f Allow specification of vendor_cert through a build command line option.
This allows you to specify the vendor_cert as a file on the command line
during build.
2012-09-06 12:13:44 -04:00
Matthew Garrett
00ced0c125 Handle slightly stranger device paths 2012-07-13 00:30:22 -04:00
Matthew Garrett
bc6aaefa2d Make path generation more sensible 2012-07-11 10:58:15 -04:00
Matthew Garrett
5fe882ba74 Make sure ImageBase is set appropriately in the loaded_image protocol 2012-07-11 10:57:46 -04:00
Matthew Garrett
b2058cf897 Re-add whitelisting - needed for protocol validation 2012-07-05 16:39:25 -04:00
Matthew Garrett
6279b58e83 Check whether secure boot is enabled before performing verify call 2012-07-05 12:51:12 -04:00
Matthew Garrett
c13fc2f71f Fix up blacklist checking
This was not quite as bugfree as would be hoped for.
2012-07-02 14:43:18 -04:00
Matthew Garrett
1348448255 Remove whitelisting - the firmware will handle it via LoadImage/StartImage 2012-07-02 13:49:32 -04:00
Matthew Garrett
6eb1eca4f3 Fix type of buffersize 2012-07-02 11:54:21 -04:00
Matthew Garrett
f23d769727 Fix get_variable 2012-06-25 17:46:11 -04:00
Matthew Garrett
c16548d08b Add black/white listing 2012-06-25 10:59:08 -04:00
Matthew Garrett
3e890667fe Fix cert size 2012-06-19 15:25:02 -04:00
Matthew Garrett
0a232ca95c Uninstall protocol on exit 2012-06-18 17:31:42 -04:00
Matthew Garrett
3df68c187c Check binary against blacklist 2012-06-18 17:31:42 -04:00
Matthew Garrett
db54b0a4c6 Attempt to start image using LoadImage/StartImage first 2012-06-18 17:31:42 -04:00
Matthew Garrett
5bc80cec92 Check that platform is in user mode before doing any validation 2012-06-18 17:31:42 -04:00
Matthew Garrett
0db1af8aeb Minor cleanups 2012-06-07 14:00:48 -04:00
Matthew Garrett
7db60bd8c2 Rename variables 2012-06-05 10:56:45 -04:00
Matthew Garrett
f4b2473401 Install a protocol for sharing code with grub 2012-06-05 10:52:30 -04:00
Matthew Garrett
f898777d22 Some cleanups 2012-05-30 22:08:09 -04:00
Matthew Garrett
7f0553356c Add image verification 2012-05-30 18:36:46 -04:00
Matthew Garrett
9d56c38fd1 Fix path generation 2012-05-08 03:00:51 -04:00
Matthew Garrett
0e6b01958a Some additional paranoia 2012-04-11 17:13:07 -04:00
Matthew Garrett
b2fe178094 Initial commit 2012-04-11 13:59:55 -04:00