Commit Graph

265 Commits

Author SHA1 Message Date
Peter Jones
556c445ea1 Don't free GetVariable() return data without checking the status code.
This breaks every machine from before Secure Boot was a thing.

Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-30 16:36:01 -04:00
Peter Jones
83b3a7cf6d We should be checking both mok and the system's SB settings
When we call hook_system_services(), we're currently only checking mok's
setting.  We should use secure_mode() instead so it'll check both.

Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-28 10:41:03 -04:00
Peter Jones
56fb385a17 Revert "additional bounds-checking on section sizes"
This reverts commit 21e40f0174.

In principle I like the idea of what's going on here, but
generate_hash() really does need to have the expected result.
2013-10-23 10:50:36 -04:00
Peter Jones
be73f6bd4f Don't reject all binaries without a certificate database.
If a binary isn't signed, but its hash is enrolled in db, it won't have
a certificate database.  So in those cases, don't check it against
certificate databases in db/dbx/etc, but we don't need to reject it
outright.

Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-22 13:40:08 -04:00
Kees Cook
21e40f0174 additional bounds-checking on section sizes
This adds additional bounds-checking on the section sizes. Also adds
-Wsign-compare to the Makefile and replaces some signed variables with
unsigned counteparts for robustness.

Signed-off-by: Kees Cook <kees@ubuntu.com>
2013-10-22 11:23:51 -04:00
Peter Jones
baebb090ea Bump version to 0.5
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-04 17:04:21 -04:00
Peter Jones
f95ccd0a7f Unhook system services as we exit.
If we never find a valid thing to boot, we need to undo the weird things
we've done.

Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-04 15:31:48 -04:00
Peter Jones
3c0ee51ad8 Put SHIM_VERBOSE under shim's guid, not global.
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-04 13:54:35 -04:00
Peter Jones
880f9de412 Try to actually make debug printing look reasonable.
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-04 11:51:09 -04:00
Peter Jones
53a318f52e Do more strict checking on PE Headers.
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-04 11:51:09 -04:00
Matthew Garrett
aa8f89d08f Reapply patches lost in the update 2013-10-04 11:51:09 -04:00
Matthew Garrett
9107ff9046 Update to current Tiano Cryptlib 2013-10-04 11:51:09 -04:00
Matthew Garrett
16c55f99e8 Add Tiano patch e98e59c237e17f064a4ecffb39d45499f89720a1
This is:
    Fix a bug in OpensslLib that PKCS7_verify will use over 8k stack space.

    Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
    Reviewed-by: Ye Ting  <ting.ye@intel.com>
    Reviewed-by: Dong Guo <guo.dong@intel.com>

from upstream.
2013-10-04 11:51:09 -04:00
Peter Jones
8c46e07fec Improve PE image bounds checking.
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-03 17:04:45 -04:00
Peter Jones
fc986307fb Add ident-like blobs to shim.efi for version checking.
I feel dirty.
2013-10-03 11:11:09 -04:00
Peter Jones
d83213cec3 Update for Josh's changes.
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-02 13:33:52 -04:00
Josh Boyer
ef0383d008 Add support for disabling db for verification
Provide a mechanism for a physically present end user to disable the use
of db when doing 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 the use of db for verification purposes (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 cause shim to not use db for verification purposes.  If
db is to be ignored, shim will export a runtime variable called
'MokIgnoreDB' for the OS to query at runtime.

Signed-off-by: Josh Boyer <jwboyer@fedoraproject.org>
2013-10-02 11:29:34 -04:00
Peter Jones
91c5a05037 Remove "shim.cer" on "make clean".
If we don't do this, an old key winds up being reused and
MokManager.efi.signed is signed with a different key than shim_cert
reflects.

Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-02 10:48:41 -04:00
Peter Jones
322a0f9ef7 Use CHAR8 not UINT8 for character work.
This gets rid of a lot of type casting that we don't need, and helps
reduce warnings when I switch a bunch of gnu-efi stuff to taking const
arguments.

Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-02 10:46:26 -04:00
Peter Jones
aec345c0b2 CompareMem expects void * and gcc complains.
Sorry about that.

Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-02 10:02:01 -04:00
Peter Jones
041b686274 Fix wrong type on console_error() call.
Stupid L"".

Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-02 10:00:11 -04:00
Peter Jones
51583bd500 If we fail to install our protocol, don't continue.
This shouldn't be exploitable unless you've got a way to make
InstallProtocol fail and still, for example, have memory free to
actually load and run something.

Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-01 16:33:58 -04:00
Peter Jones
6e5d86e565 Clean up warnings.
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-01 14:38:09 -04:00
Peter Jones
f330528786 Conditionalize overriding the security policy.
Make OVERRIDE_SECURITY_POLICY a build option.

Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-01 14:03:16 -04:00
Peter Jones
4537217422 Merge console_control.h and console.h
Since these are topically the same thing, they can live together.

Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-01 14:03:16 -04:00
Peter Jones
09a37bbc69 Make verbose stuff use console_notify
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-01 14:03:16 -04:00
Peter Jones
f7b849be1c MokManager needs to disable the graphics console.
Without this patch, on some machines we never see MokManager's UI.  This
protocol has never (I think?) been officially published, and yet I still
have new hardware that needs it.

If you're looking for a reference, look at:

EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.c

in the edk2 tree from Tiano.

Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-01 14:03:16 -04:00
Peter Jones
b538992dd4 Include shim's vendor_cert in MokListRT
There needs to be some way to communicate to the kernel that it's a
trusted key, and since this mechanism already exists, it's by far the
easiest.
2013-10-01 14:03:16 -04:00
Peter Jones
39df41ceb5 Harden shim against non-participating bootloaders.
It works like this: during startup of shim, we hook into the system's
ExitBootServices() and StartImage().  If the system's StartImage() is
called, we automatically unhook, because we're chainloading to something
the system can verify.

When shim's verify is called, we record what kind of certificate the
image was verified against.  If the call /succeeds/, we remove our
hooks.

If ExitBootServices() is called, we check how the bootloader verified
whatever it is loading.  If it was verified by its hash, we unhook
everything and call the system's EBS().  If it was verified by
certificate, we check if it has called shim_verify().  If it has, we
unhook everything and call the system's EBS()

If the bootloader has not verified anything, and is itself verified by
a certificate, we display a security violation warning and halt the
machine.
2013-10-01 14:03:16 -04:00
Peter Jones
02388bcd58 Make vendor_cert/vendor_dbx actually replaceable by an external tool.
This moves them both to be computed at runtime from a pointer+offset
rather than just a pointer, so that their real address can be entirely
derived from the section they're in.

This means you can replace the whole .vendor_cert section with a new one
with certs that don't have the same size.
2013-10-01 14:03:16 -04:00
Peter Jones
73de2ec2d8 Remove TODO items fixed by merging lf_merge and lcp/lf-security-override.
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-01 14:03:16 -04:00
Peter Jones
195e63f911 Don't use LibGetVariable(), since it doesn't give us real error codes. 2013-09-26 13:44:05 -04:00
Gary Ching-Pang Lin
3508c40c39 integrate security override 2013-09-26 11:58:03 -04:00
Peter Jones
9197943206 Clean up tarballs in "make clean"
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
7d602e843c Merge variable retrieving functions 2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
79424b09ca Merge signature.h into efiauthenticated.h and guid.h
Conflicts:
	shim.c
2013-09-26 11:58:02 -04:00
Peter Jones
526ed5a231 Merge two PeImage.h into one
Conflicts:
	Makefile
2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
804f8f7797 Free unused memory space 2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
f6d1f6aa32 Adjust the result of gmtime() to fit the definition 2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
681082e6c4 Rand: check the status of the pseudorandom number generator 2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
9fd4e4a54e MokManager: check the suffix of the key file 2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
6212d9baa6 MokManager: fetch more info from X509 name 2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
09f11d6aae MokManager: reboot the system after clearing MOK password 2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
e727d6007c MokManager: enhance the password prompt for SB state 2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
f514439923 MokManager: rearrange the output of MOK info 2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
9222860d32 Disable floating points in b_print
The long double declaration will enable SSE and cause a compilation
error. Disabling everything related to floating points avoids the
error.
2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
ad23233e2d Enable openssl bio_printf()
bio_printf() was replaced with a dummy function and this made
several openssl functions useless. This commit adds the print
functions back, so that we don't have to implement our own
ASN1 time print function.
2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
e9e320e474 MokManager: enhance the password prompt 2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
8494a1a323 MokManager: remove the duplicate get_keystroke() 2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
cc62e19d05 MokManager: draw the countdown screen 2013-09-26 11:58:02 -04:00