Commit Graph

567 Commits

Author SHA1 Message Date
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
4d70f10481 lib/variables.c: reformat CreateTimeBasedPayload()
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12 16:21:43 -04:00
Peter Jones
324db6bbab Clean up efiauthenticated.h a lot.
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12 16:21:43 -04:00
Peter Jones
1f1ec4cea8 Make sure all of our include files have proper guards.
... and make them all the same formatting too.

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
1a44dbb8be Rename generate_path() because we have 2 of it.
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12 16:21:43 -04:00
Peter Jones
3832428e02 Fix the declaration of find_httpboot() to match its implementation.
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12 16:21:43 -04:00
Peter Jones
8c42b9389f Add "make scan-build" target.
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12 16:21:43 -04:00
Peter Jones
71bc0a8c86 Add a model file for coverity.
This is useful to hide some false positives from the covscan results.
We never build it.

Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12 16:21:43 -04:00
Peter Jones
d184bf1075 Add 'make coverity' target.
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12 16:21:43 -04:00
Peter Jones
b681123a87 Split makefiles up a bit
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12 16:21:43 -04:00
Peter Jones
5f3adcc2c0 Document REQUIRE_TPM
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12 16:21:43 -04:00
Hans de Goede
79cdb2a215 Fix failure to boot on systems without a TPM
This commit fixes 2 issues with the TPM support code:

1) Remove "REQUIRE_TPM ?=" line from the Makefile, further down the Makefile
checks if REQUIRE_TPM is undefined, but the above line sets it to an empty
string, which is not the same as undefined. Without this handle_image fails
after the tpm_log_pe() call even if REQUIRE_TPM=1 once was not set when
building the shim

2) When secure-boot is disabled then shim_verify() would exit with the
status of tpm_log_pe(), which on systems with a TPM is an error. Combined
with the recent change to always install the shim protocols, this causes
grub to refuse to boot any kernel since the verify() call now always fails.
This commit fixes this by explicitly setting status = EFI_SUCCESS when
secure-boot is disabled.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-03-08 11:18:33 -05:00
Peter Jones
6c8d08c0af shim: Ignore UEFI LoadOptions that are just NUL characters.
I don't know when or why we ever see this, but it's easy enough to
avoid.

Resolves github issue #95

Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-06 15:28:00 -05:00
Tamas K Lengyel
e207388577 Install shim_lock protocol even when SecureBoot is off
Currently the shim_lock protocol is only installed when SecureBoot is enabled.
However, having Verify just measure into the TPM without SecureBoot is a useful
feature.

Signed-off-by: Tamas K Lengyel <lengyelt@ainfosec.com>
2018-03-06 14:42:32 -05:00
Tamas K Lengyel
571bfc95a6 Fall-back TPM2 measurement if it fails with PE_COFF_IMAGE flag
Signed-off-by: Tamas K Lengyel <lengyelt@ainfosec.com>
2018-03-06 14:42:32 -05:00
Tamas K Lengyel
ba06a4362d Add REQUIRE_TPM flag to treat TPM related errors as critical
Currently TPM related errors are being silently discarded.

Signed-off-by: Tamas K Lengyel <lengyelt@ainfosec.com>
2018-03-06 14:42:32 -05:00
Tamas K Lengyel
555ef92650 Measure into the TPM even if SecureBoot is off in shim_lock verify
Signed-off-by: Tamas K Lengyel <lengyelt@ainfosec.com>
2018-03-06 14:37:07 -05:00
Tamas K Lengyel
829d3c8265 Log measurements in PCR4 for applications being verified through shim_lock
Currently the only measurement the shim logs in the TPM is that of the EFI
application it directly loads. However, there are no measurements being taken
of application that are being verified through the shim_lock protocol. In this
patch we extend PCR4 for any binary for which Verify is being called through
the shim_lock protocol.

Signed-off-by: Tamas K Lengyel <lengyelt@ainfosec.com>
2018-03-06 14:37:07 -05:00
Tamas K Lengyel
3d93263198 Add -m64 compiler flag to allow cross-compiling to 64-bit version on 32-bit system
Signed-off-by: Tamas K Lengyel <lengyelt@ainfosec.com>
2018-03-06 14:33:19 -05:00
Peter Jones
0da5fb8c9d ident: We don't actually need the hostname or kernel version, and it makes the builds differ.
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-02-28 15:01:07 -05:00
cdadmin
5f4fd53641 Add proxy dhcp support 2018-02-28 14:56:10 -05:00
Gary Lin
bc3b6525d8 Cryptlib: replace CryptPem with CryptPemNull
We don't need the functions in CryptPem.c.

Signed-off-by: Gary Lin <glin@suse.com>
2018-02-28 14:47:18 -05:00
Gary Lin
62d8397202 httpboot: include console.h
in_protocol is declared in console.h, so httpboot.c has to include the
header.

Signed-off-by: Gary Lin <glin@suse.com>
2018-02-28 14:47:15 -05:00
Gary Lin
736af67122 httpboot: fix the infinite loop
We should get out of the loop once the uri node is not the last node in
the device path.

Signed-off-by: Gary Lin <glin@suse.com>
2018-02-28 14:47:12 -05:00
Gary Lin
a752290c38 httpboot: Amend the device path matching rule
Originally, we check if the last 2 nodes in the device path are
IPv4()/Uri() or IPv6()/Uri() to determine whether httpboot is used or
not. However, since UEFI 2.7, the DNS node will be inserted between the
IP node and the URI node if the server provides the DNS server address.
This commit changes the matching rule to search IP node and URI node
and ignore any node between those two nodes.

Signed-off-by: Gary Lin <glin@suse.com>
2018-02-28 14:47:12 -05:00
Mathieu Trudel-Lapierre
c8ca1c5696 Uninstall shim protocols before re-installing them
Make sure if we chainload things, a chainloaded bootloader will be able to use
the latest systab replacements and protocols. They need to match for things
to validate correctly.

Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
2018-02-01 13:50:44 -05:00
Peter Jones
02e2fc61bd Bump the version to 14
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-12-19 16:52:01 -05:00
Peter Jones
0f50328189 Don't allow undefined symbols at all.
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-12-19 16:52:01 -05:00
Peter Jones
97a3f6cf94 "in_protocol" is used in more than shim.o; make it not static.
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-12-19 16:52:01 -05:00
Peter Jones
b9e81483bb Don't let openssl() try to call an external abort()
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-12-19 16:36:55 -05:00
Peter Jones
5e827007b3 Bump the version to 13
shim 13:
- OpenSSL reverted to 1.0.2k to make the cert chaining of existing deployments stay working
- Better PCR usage for TPM
- TPM documentation in README.tpm
- More configurable build via make variables:
  ENABLE_SHIM_CERT
  ENABLE_SHIM_HASH
  ENABLE_SBSIGN
  LIBDIR
  EFIDIR
  VENDOR_CERT_FILE
  VENDOR_DB_FILE
- Better MoK documentation in MokVars.txt
- Better debuginfo generation
- Lots of minor bug fixes.

Signed-off-by: Peter Jones <pjones@redhat.com>
2017-09-29 11:10:49 -04:00
Mathieu Trudel-Lapierre
cc08ed0e28 buildid: Check the return values of write() calls
Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
2017-09-29 11:10:32 -04:00
Peter Jones
dca65ca254 Make shim_cert.h able to be included more safely.
If you build with ENABLE_SHIM_CERT=1, the include chain right now winds
up meaning shim_cert is defined in a header that gets included in
netboot.c as well, which never uses it:

  In file included from shim.h:125:0,
                   from netboot.c:36:
  shim_cert.h:1:14: error: ‘shim_cert’ defined but not used [-Werror=unused-variable]
   static UINT8 shim_cert[] = {
                ^~~~~~~~~
  cc1: all warnings being treated as errors

So make that okay by adding __attribute__((__unused__)) to the variable
decl.

Signed-off-by: Peter Jones <pjones@redhat.com>
2017-09-29 11:10:32 -04:00
Peter Jones
d8f4773408 buildid: make 'make clean' remove it. 2017-09-29 11:10:32 -04:00
Peter Jones
23ce039c43 Use iconv for UCS-2 encoding.
Cyphermox discovered that when you run this:

  ( printf "\xff\x00\xfe\x00" ; echo "shimx64.efi,foo,,This is the boot entry for foo" ) | sed -z 's/./&\x00/g'

on some debian machines, printf(1) doesn't interpret the \x.. characters,
and that results in this being the encoded text:

00000000  5c 78 66 66 5c 78 66 65  73 00 68 00 69 00 6d 00  |\xff\xfes.h.i.m.|
00000010  78 00 36 00 34 00 2e 00  65 00 66 00 69 00 2c 00  |x.6.4...e.f.i.,.|
00000020  66 00 6f 00 6f 00 2c 00  2c 00 54 00 68 00 69 00  |f.o.o.,.,.T.h.i.|

which... yeah, that's wrong.  So instead, use iconv instead of
printf+sed to encode it in UCS-2.  Unfortunately, that means we don't
get endian markers, because for some reason iconv(1) doesn't have any way
to say it should include them.  But that's okay; fallback already
handles not having them and just assumes the second byte being \x00
means UCS-2LE.

Signed-off-by: Peter Jones <pjones@redhat.com>
2017-09-26 11:16:45 -04:00
Peter Jones
49e9775e07 Fix an LDFLAGS issue on arm and aarch64
Commit 1e71734992 inadvertantly switched ARM's
LDFLAGS+=--defsym=EFI_SUBSYSTEM=$(SUBSYSTEM) to be before LDFLAGS is set,
and so it got clobbered away.

Signed-off-by: Peter Jones <pjones@redhat.com>
2017-09-19 14:58:51 -04:00
Peter Jones
51c497b8db Try to do a slightly better job at 'make clean'
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-09-19 14:58:51 -04:00
Mathieu Trudel-Lapierre
35fd2c170c Don't build shim_cert.h in parallel with other targets.
shim_cert.h is required by other pieces (such as netboot.o, cert.o) and
might not be built by the time these targets are reached. In that case the
build would fail as it can't find a required header.

Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
2017-09-14 18:07:10 -04:00
Mathieu Trudel-Lapierre
b71838a35a Clean up after BOOT$(ARCH).CSV.
It should not be left around after clean since it's a generated file.

Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
2017-09-14 18:07:10 -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
00753a0a28 Add some debugging data to the last malformed binary check...
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-09-13 15:16:43 -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
1dc35a4fe0 Work around some annoying compiler grievances
I'm still having some trouble with the offsetof() definition, so just
nerf it to what stddef.h would say anyway.

Signed-off-by: Peter Jones <pjones@redhat.com>
2017-09-08 14:49:31 -04:00
Peter Jones
9802023c13 Some things went weird with the openssl revert...
I think this works around most of them.

Signed-off-by: Peter Jones <pjones@redhat.com>
2017-09-08 14:48:57 -04:00
Gary Lin
e992a913cf Cryptlib: remove DES
Disable DES completely since it's already old and insecure.
This makes MokManager not support the DES based password hash but
probably no one is using it.

Signed-off-by: Gary Lin <glin@suse.com>
2017-09-08 14:47:09 -04:00
Gary Lin
70d49e332d Cryptlib: Remove MD4
MD4 is known to be insecure and shim never uses it.

Signed-off-by: Gary Lin <glin@suse.com>
2017-09-08 14:47:09 -04:00
Gary Lin
80a5aa9d1b Cryptlib: amend the headers and fix signness
- Declare some functions in the proper headers
  + We missed them for a long time...

- Cast offsetof to UINTN
  + The original casting triggers the gcc warning since int can not
    present the offset for the 64bit machines.

- Cast the "char" array to "CHAR8 *" to avoid the gcc warnings

- Implement atoi correctly

Signed-off-by: Gary Lin <glin@suse.com>
2017-09-08 14:47:09 -04:00
Mathieu Trudel-Lapierre
2fdba73012 Fix build with ENABLE_SHIM_CERT and ENABLE_SBSIGN: shim.key is created by the shim.crt target
Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
2017-08-31 15:28:17 -04:00
Gary Lin
e06765ae0d Cryptlib: implement strcmp() and strcasecmp()
strcmp() and strcasecmp() are widely used in openssl. Implement those
two functions to eliminate the gcc warnings and the potential crash.

Signed-off-by: Gary Lin <glin@suse.com>
2017-08-31 15:14:20 -04:00