]> git.proxmox.com Git - efi-boot-shim.git/log
efi-boot-shim.git
3 years agoUpdate upstream source from tag 'upstream/15.4'
Steve McIntyre [Wed, 31 Mar 2021 17:24:30 +0000 (18:24 +0100)]
Update upstream source from tag 'upstream/15.4'

Update to upstream version '15.4'
with Debian dir 93160080661283eee071d2c92a27ce9b39acb998

3 years agoNew upstream version 15.4
Steve McIntyre [Wed, 31 Mar 2021 17:24:24 +0000 (18:24 +0100)]
New upstream version 15.4

3 years agoPrint sha256 checksums of the EFI binaries when the build is done
Steve McIntyre [Wed, 24 Mar 2021 16:34:14 +0000 (16:34 +0000)]
Print sha256 checksums of the EFI binaries when the build is done

3 years agoTweak the SBAT data to keep reproducibility
Steve McIntyre [Wed, 24 Mar 2021 13:23:26 +0000 (13:23 +0000)]
Tweak the SBAT data to keep reproducibility

Only include the upstream version in the Debian SBAT metadata, so
we don't break reproducibility on every minor packaging change.

3 years agoAdd missing build-dep on xxd for build-time unit tests
Steve McIntyre [Wed, 24 Mar 2021 02:21:53 +0000 (02:21 +0000)]
Add missing build-dep on xxd for build-time unit tests

3 years agoNew upstream version 15.3
Steve McIntyre [Tue, 23 Mar 2021 23:49:46 +0000 (23:49 +0000)]
New upstream version 15.3

3 years agoUpdate upstream source from tag 'upstream/15.3'
Steve McIntyre [Tue, 23 Mar 2021 23:49:46 +0000 (23:49 +0000)]
Update upstream source from tag 'upstream/15.3'

Update to upstream version '15.3'
with Debian dir 1b484f1c1ac270604a5a1451b34de4b0865c6211

3 years agoSwitch to using the 15.3 release from upstream
Steve McIntyre [Tue, 23 Mar 2021 23:43:27 +0000 (23:43 +0000)]
Switch to using the 15.3 release from upstream

3 years agoRemove all out outstanding patches
Steve McIntyre [Tue, 23 Mar 2021 23:38:30 +0000 (23:38 +0000)]
Remove all out outstanding patches

 * cast-CHAR8-string-handling.patch no longer needed
 * fix-Make.coverity-bashisms.patch went upstream

3 years agoUpdate copyright file
Steve McIntyre [Mon, 15 Mar 2021 21:39:49 +0000 (21:39 +0000)]
Update copyright file

Update a couple of top-level changes, copy in gnu-efi information from
the gnu-efi package

3 years agoFix up some of the options we're using at build time
Steve McIntyre [Mon, 15 Mar 2021 20:19:01 +0000 (20:19 +0000)]
Fix up some of the options we're using at build time

Definitely don't want to be setting EFI_PATH, as that over-rides the
vendored gnu-efi. Argh

3 years agoImprove how the dbx hashes are handled
Steve McIntyre [Sun, 14 Mar 2021 16:04:15 +0000 (16:04 +0000)]
Improve how the dbx hashes are handled

Only include the hashes for the architecture we're building for - no
point in adding bloat and delay here.

Add a script "block_signed_deb" to scan a set of .deb files, extract
the hashes for .efi binaries and list them in the format wanted for
the dbx hashes file.

Split out the code to use that file from the rules file into a
separate helper.

3 years agoTweak the gnu-efi tarball code
Steve McIntyre [Sat, 13 Mar 2021 20:00:58 +0000 (20:00 +0000)]
Tweak the gnu-efi tarball code

3 years agoAdd an extra rule to generate the extra gnu-efi tarball
Steve McIntyre [Sat, 13 Mar 2021 19:43:00 +0000 (19:43 +0000)]
Add an extra rule to generate the extra gnu-efi tarball

Thanks to Dmitri John Ledkov for help

3 years agoAdd Debian SBAT data to the shim build
Steve McIntyre [Sat, 13 Mar 2021 19:06:37 +0000 (19:06 +0000)]
Add Debian SBAT data to the shim build

Add a Debian SBAT template, and rules to use it
Adds a build-dep on dos2unix

3 years agoAdd dbx entries for all our existing grub binaries
Steve McIntyre [Sat, 13 Mar 2021 18:59:25 +0000 (18:59 +0000)]
Add dbx entries for all our existing grub binaries

They're insecure, let's break the chainloading hole

3 years agoChange changelog to shut lintian up
Steve McIntyre [Sun, 21 Feb 2021 17:06:12 +0000 (17:06 +0000)]
Change changelog to shut lintian up

3 years agoRemove artifacts that upstream installs that we don't use
Steve McIntyre [Sun, 21 Feb 2021 16:14:14 +0000 (16:14 +0000)]
Remove artifacts that upstream installs that we don't use

... to keep debhelper from complaining

3 years agoAdd new patch cast-CHAR8-string-handling.patch
Steve McIntyre [Sun, 21 Feb 2021 15:25:06 +0000 (15:25 +0000)]
Add new patch cast-CHAR8-string-handling.patch

Cast CHAR8 strings to use (const char *) when using string functions

Looks like gnu-efi definitions of CHAR8 are problematic

3 years agoTrivial change to remove bashisms in Make.coverity
Steve McIntyre [Sun, 21 Feb 2021 15:06:56 +0000 (15:06 +0000)]
Trivial change to remove bashisms in Make.coverity

3 years agoRemove all our old patches, no longer needed:
Steve McIntyre [Sun, 21 Feb 2021 14:27:01 +0000 (14:27 +0000)]
Remove all our old patches, no longer needed:

 - avoid_null_vsprint.patch
 - check_null_sn_ln.patch
 - fixup_git.patch
 - uname.patch
 - use_compare_mem_gcc9.patch

3 years agoSwitch to using gcc-10 rather than gcc-9. Closes: #978521
Steve McIntyre [Sun, 21 Feb 2021 13:53:17 +0000 (13:53 +0000)]
Switch to using gcc-10 rather than gcc-9. Closes: #978521

3 years agoSwitch to newer upstream "release" 15+1613861442.888f5b5
Steve McIntyre [Sun, 21 Feb 2021 13:50:33 +0000 (13:50 +0000)]
Switch to newer upstream "release" 15+1613861442.888f5b5

Many many updates, but caring mainly about SBAT support

3 years agoUpdate upstream source from tag 'upstream/15+1613861442.888f5b5'
Steve McIntyre [Sun, 21 Feb 2021 13:46:16 +0000 (13:46 +0000)]
Update upstream source from tag 'upstream/15+1613861442.888f5b5'

Update to upstream version '15+1613861442.888f5b5'
with Debian dir 15b0853a73144b1f8571ce2bebc2eea68af4a8e3

3 years agoAdd --set-section-alignment '.sbat=512' to objcopy command line
Jan Setje-Eilers [Fri, 19 Feb 2021 23:40:42 +0000 (15:40 -0800)]
Add --set-section-alignment '.sbat=512' to objcopy command line

3 years agoInclude missing .text sections in PE/COFF binary
Chris Coulson [Wed, 15 Jul 2020 11:33:27 +0000 (12:33 +0100)]
Include missing .text sections in PE/COFF binary

At the default -Os optimization level, gcc emits ".text.startup"
and ".text.unlikely" sections for static initializers and noreturn
functions which end up in the intermediate ELF binary:

$ objdump -h build-x64/shimx64.efi.so

build-x64/shimx64.efi.so:     file format elf64-x86-64

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .text         00046e7b  0000000000001000  0000000000001000  00001000  2**10
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .text.startup 00000118  0000000000047e7b  0000000000047e7b  00047e7b  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  2 .text.unlikely 00000046  0000000000047f93  0000000000047f93  00047f93  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  3 .data         000315e8  0000000000048000  0000000000048000  00048000  2**9

These additional .text.* sections are omitted from the final PE/COFF
binary, resulting in a crash when processing the ctors. Taking a look at
_init_array in gdb:

(gdb) p/x &_init_array
$1 = 0x78510
(gdb) p/x &_init_array_end
$2 = 0x7851c
(gdb) x/x (void*)&_init_array
0x78510 <_init_array>:  0x00047e7b
(gdb) x/x (void*)(&_init_array)+8
0x78518 <_init_array+8>:  0x00000000

See that 0x00047e7b falls inside the padding between the .text and .data
sections:

$ objdump -h build-x64/shimx64.efi

build-x64/shimx64.efi:     file format pei-x86-64

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .text         00046e7b  0000000000001000  0000000000001000  00000400  2**10
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .data         000315e8  0000000000048000  0000000000048000  00047400  2**9

Adjust the linker script to merge the .text.startup and .text.unlikely
sections in to the .text section.

[edited by pjones to use .text.* instead of naming the sections
individually, and to sync up with what other arches have in .text]

3 years agobuild: Pass the correct paths to sbsign
Chris Coulson [Fri, 19 Feb 2021 17:37:00 +0000 (17:37 +0000)]
build: Pass the correct paths to sbsign

Signed-off-by: Chris Coulson <chris.coulson@canonical.com>
3 years agosbat: Fix two NULL derefs found with "gcc -fanalyzer"
Peter Jones [Fri, 19 Feb 2021 19:23:57 +0000 (14:23 -0500)]
sbat: Fix two NULL derefs found with "gcc -fanalyzer"

"gcc -fanalyzer" found two NULL pointer checks we're missing in sbat.c:

include/str.h: In function ‘get_sbat_field.part.0’:
sbat.c:20:14: error: dereference of NULL ‘offset’ [CWE-476] [-Werror=analyzer-null-dereference]
   20 |         if (!*offset)

and

include/str.h: In function ‘parse_sbat’:
sbat.c:140:27: error: dereference of NULL ‘current’ [CWE-476] [-Werror=analyzer-null-dereference]
  140 |         } while (entry && *current != '\0');

Both are simple, and this patch fixes them.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agosbat: make shim to parse it's own .sbat section on init
Javier Martinez Canillas [Wed, 17 Feb 2021 13:03:48 +0000 (14:03 +0100)]
sbat: make shim to parse it's own .sbat section on init

This is needed for shim to verify itself when booting, to make sure that
shim binaries can't be executed anymore after been revoked by SBAT.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
3 years agoshim: initialize OpenSSL after parsing SBAT data
Javier Martinez Canillas [Thu, 18 Feb 2021 00:12:49 +0000 (01:12 +0100)]
shim: initialize OpenSSL after parsing SBAT data

A following patch will make shim to verify its .sbat section and it
should be done before doing the OpenSSL initialization. But having
the debugger attached may be useful at this point.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
3 years agosbat: include NULL terminator when calculating buffer end in parse_sbat()
Javier Martinez Canillas [Wed, 17 Feb 2021 13:03:01 +0000 (14:03 +0100)]
sbat: include NULL terminator when calculating buffer end in parse_sbat()

The parse_sbat() function is currently removing the last character of the
passed buffer, which will usually be a null-terminated string to parse.

There's no reason to do this and just take the whole size as specified by
the caller.

Reported-by: Chris Coulson <chris.coulson@canonical.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
3 years agope.c: move sbat verification to its own function.
Peter Jones [Wed, 17 Feb 2021 23:33:36 +0000 (18:33 -0500)]
pe.c: move sbat verification to its own function.

handle_image() is quite huge and complex.

This patch moves the SBAT validation code from handle_image() to a new
function, handle_sbat().

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoDon't re-parse the SBAT EFI variable for each binary we load.
Javier Martinez Canillas [Thu, 18 Feb 2021 11:39:10 +0000 (12:39 +0100)]
Don't re-parse the SBAT EFI variable for each binary we load.

On a typical boot we validate at least two binaries; parsing the SBAT
EFI variable each time, when it should not be changing, is not worth the
effort.

This patch moves the parsing out to some setup code, instead of doing it
during the verification stage.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoparse_sbat: handle the realloc failure leak and batch allocations.
Peter Jones [Thu, 18 Feb 2021 02:06:28 +0000 (21:06 -0500)]
parse_sbat: handle the realloc failure leak and batch allocations.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agope.c: parse SBAT variable and perform basic verification
Alex Burmashev [Tue, 16 Feb 2021 12:08:35 +0000 (07:08 -0500)]
pe.c: parse SBAT variable and perform basic verification

Per Peter Jones suggestion, we will be flexible in what data we expect
while parsing the variable. Three fields are mandatory:
component_generation, component_name_size, component_name
However we also support adding comments and additional information to be
added after component name, with ',' as a separator. Those information
will be ignored and not used for verification purposes.
So:
grub,1
and
grub,1,wow,this,is,my,comment
will provide exactly same set of data for verification.

[0]: https://github.com/rhboot/shim/blob/main/SBAT.md

Signed-off-by: Alex Burmashev <alexander.burmashev@oracle.com>
Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agosbat: drop the struct sbat and just use two variables instead
Peter Jones [Thu, 18 Feb 2021 09:36:23 +0000 (10:36 +0100)]
sbat: drop the struct sbat and just use two variables instead

The struct sbat isn't doing anything and only has two fields so let's pass
pass those two to the functions directly instead of storing it in a struct.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoshim: use an enum for efi_main's error messages.
Peter Jones [Thu, 18 Feb 2021 00:50:16 +0000 (19:50 -0500)]
shim: use an enum for efi_main's error messages.

Numbering the error messages in efi_main directly was a mistake, and the
following patches just make it more apparent.

This makes it an enum so we don't have to re-number at more than one
place when we add or remove them.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoFix EV_EFI_VARIABLE_AUTHORITY event in eventlog
Hai Huang [Tue, 10 Nov 2020 15:23:57 +0000 (10:23 -0500)]
Fix EV_EFI_VARIABLE_AUTHORITY event in eventlog

Currently, for an EV_EFI_VARIABLE_AUTHORITY event, the shim puts only
EFI_SIGNATURE_DATA.SignatureData in the VariableData field, but omits
EFI_SIGNATURE_DATA.SignatureOwner. According to reference implementation
in EDK2, the entire EFI_SIGNATURE_DATA is put into the VariableData
field, shown here:
https://github.com/tianocore/edk2/blob/master/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c#L1032

3 years agobuild: add some basic $EFI_PATH checking
Paul Moore [Tue, 20 Oct 2020 17:08:02 +0000 (13:08 -0400)]
build: add some basic $EFI_PATH checking

Not all distributions put the crt0-efi-$(ARCH).o file under
$LIB_DIR/gnuefi, some stash it directly in $LIB_DIR.  In an effort
to make the build a bit more user friendly, check if $LIB_DIR/gnuefi
exits before setting $EFI_PATH to that value; if $LIB_DIR/gnuefi does
not exist, fallback to $LIB_DIR for $EFI_PATH.

Signed-off-by: Paul Moore <pmoore2@cisco.com>
3 years agoadd list_empty to linked list primitives
Alex Burmashev [Tue, 16 Feb 2021 12:07:14 +0000 (07:07 -0500)]
add list_empty to linked list primitives

Signed-off-by: Alex Burmashev <alexander.burmashev@oracle.com>
3 years agostrndupa: allocate len + 1, so that \0 is not lost
Alex Burmashev [Tue, 16 Feb 2021 11:58:05 +0000 (06:58 -0500)]
strndupa: allocate len + 1, so that \0 is not lost

Signed-off-by: Alex Burmashev <alexander.burmashev@oracle.com>
3 years agoFix an off by one in strnlena()
Peter Jones [Mon, 15 Feb 2021 16:41:08 +0000 (11:41 -0500)]
Fix an off by one in strnlena()

I wrote a test case for strnlena() and strndupa() and of course both
were off by one in the opposite directions...

... but the next patch obviates the need for them, hopefully, so this
will wind up getting dropped.

3 years agoFixups after Peter's review
Steve McIntyre [Mon, 15 Feb 2021 18:55:41 +0000 (18:55 +0000)]
Fixups after Peter's review

3 years agoSecond attempt at SBAT doc tweaks
Steve McIntyre [Mon, 15 Feb 2021 00:13:47 +0000 (00:13 +0000)]
Second attempt at SBAT doc tweaks

3 years agofix nit
Jan Setje-Eilers [Thu, 18 Feb 2021 00:24:20 +0000 (16:24 -0800)]
fix nit

Co-authored-by: Christopher Co <christopher.co@microsoft.com>
3 years agofix nit
Jan Setje-Eilers [Thu, 18 Feb 2021 00:24:04 +0000 (16:24 -0800)]
fix nit

Co-authored-by: Christopher Co <christopher.co@microsoft.com>
3 years agofix nit
Jan Setje-Eilers [Thu, 18 Feb 2021 00:23:55 +0000 (16:23 -0800)]
fix nit

Co-authored-by: Christopher Co <christopher.co@microsoft.com>
3 years agofix not
Jan Setje-Eilers [Thu, 18 Feb 2021 00:23:14 +0000 (16:23 -0800)]
fix not

Co-authored-by: Christopher Co <christopher.co@microsoft.com>
3 years agoSBAT: Fix all the docs examples to start with version 1
Peter Jones [Tue, 16 Feb 2021 20:22:18 +0000 (15:22 -0500)]
SBAT: Fix all the docs examples to start with version 1

Since we have atol() but not strtoul(), we need to make all versions
positive integers.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoSBAT: make the variable be CSV in our spec.
Peter Jones [Tue, 16 Feb 2021 20:15:47 +0000 (15:15 -0500)]
SBAT: make the variable be CSV in our spec.

We noticed that we'd originally specified the SBAT variable as binary
records, but talked as if they're CSV.  Woops.  Anyway, this makes them
CSV, which also means they don't need the size field.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agosbat: add minor fixes to parse_sbat
Chris Co [Tue, 16 Feb 2021 06:21:12 +0000 (06:21 +0000)]
sbat: add minor fixes to parse_sbat

Add parameter checking to parse_sbat().

Set end pointer to be sbat_base + sbat_size - 1. We directly
dereference the end pointer but this is technically outside of
our sbat_base buffer range.

Remove current and end while loops that account for extra CRLF
or LF characters before and after the .sbat section. We will
rely on automated tooling to verify the .sbat section is sane.

Remove the overwriting of *(end - 1) with '\0'. This behavior
causes a segfault in the unit test. parse_sbat_entry() expects
a very specific pattern "_,_,_,_,_,_\n" for every entry and uses
strchrnul() to process each individual field. When *(end - 1)='\0'
is present, it short-circuits the final \n and causes the final
get_sbat_field() to return NULL, thereby setting current = NULL.

Eventually parse_sbat attempts to access current in the do-while
condition and the segfault happens.

Signed-off-by: Chris Co <chrco@microsoft.com>
3 years agosbat: use correct type for parse_sbat_var() return value
Javier Martinez Canillas [Tue, 16 Feb 2021 09:55:27 +0000 (10:55 +0100)]
sbat: use correct type for parse_sbat_var() return value

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
3 years agosbat: remove unused buffer parameter in parse_sbat() function
Javier Martinez Canillas [Tue, 16 Feb 2021 09:55:22 +0000 (10:55 +0100)]
sbat: remove unused buffer parameter in parse_sbat() function

It's a left over from an early implementation that was never cleaned.

Reported-by: Christopher Co <christopher.co@microsoft.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
3 years agosbat: clang-format the whole thing.
Peter Jones [Sat, 13 Feb 2021 17:01:47 +0000 (12:01 -0500)]
sbat: clang-format the whole thing.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoUse gcc -Os instead of -O0.
Peter Jones [Fri, 22 Nov 2019 21:14:23 +0000 (16:14 -0500)]
Use gcc -Os instead of -O0.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoRename check_{white,black}list to check_{allow,deny}list
Chris Coulson [Fri, 3 Jul 2020 00:47:51 +0000 (01:47 +0100)]
Rename check_{white,black}list to check_{allow,deny}list

v2 - updated for conflicts and to include documentation (pjones)

3 years agoAdd ENABLE_SHIM_DEVEL config to change what our debug variable name is
Peter Jones [Wed, 27 Jan 2021 17:14:01 +0000 (12:14 -0500)]
Add ENABLE_SHIM_DEVEL config to change what our debug variable name is

Currently, if you have two boot entries, say one for
\EFI\fedora\shimx64.efi and one for \EFI\devel\shimx64.efi, and you set
the efi variable SHIM_DEBUG=1, both of these will trigger, and you need
to write your debugging scripts to allow each of the builds to continue.

This is a pain.

This patch makes it so on your development build, it will instead check
SHIM_DEVEL_DEBUG, thus meaning you can have it pause for a debugger only
on the development branch and not the OS you need to boot to scp in a
new development build.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoMake the variable name and pointer const in all of our efi vars functions
Peter Jones [Wed, 27 Jan 2021 17:10:44 +0000 (12:10 -0500)]
Make the variable name and pointer const in all of our efi vars functions

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoMake httpboot.c always get built.
Peter Jones [Fri, 22 Nov 2019 20:14:22 +0000 (15:14 -0500)]
Make httpboot.c always get built.

This is a backport from devel of:

  commit 634fd72ac6a6c6c9010c32506d524586826a8637
  Author: Peter Jones <pjones@redhat.com>
  Date:   Fri Nov 22 15:14:22 2019 -0500

      Make httpboot.c always get built.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoFix a bunch of trivial trailing whitespace issues.
Peter Jones [Sun, 14 Feb 2021 16:21:27 +0000 (11:21 -0500)]
Fix a bunch of trivial trailing whitespace issues.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoconsole: Fix a typo in the EFI warning list in gnu-efi
Peter Jones [Mon, 26 Aug 2019 20:12:05 +0000 (16:12 -0400)]
console: Fix a typo in the EFI warning list in gnu-efi

Some versions of gnu-efi have a typo, in which "EFI_WARN_UNKNOWN_GLYPH"
is accidentally "EFI_WARN_UNKOWN_GLYPH".  Work around that, so that we
can use the not-silly one in console.c's list of error and warning
messages.

This is a backport from devel for:

  commit 5f62b22ccd636d326b3229a2b196118701c6f3f7
  Author: Peter Jones <pjones@redhat.com>
  Date:   Mon Aug 26 16:12:05 2019 -0400

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agofallback: show a countdown menu before reset
Gary Lin [Wed, 23 May 2018 10:13:05 +0000 (18:13 +0800)]
fallback: show a countdown menu before reset

Some machines with the faulty firmware may keep booting the default boot
path instead of the boot option we create. To avoid the infinite reset
loop, this commit introduce a countdown screen before fallback resets the
system, so the user can interrupt the system reset and choose to boot
the restored boot option. The "Always continue boot" option creates a
BS+RT+NV variable, FB_NO_REBOOT, to make fallback boot the first boot
option afterward without asking. The user can revert the behavior by
removing the variable.

https://github.com/rhboot/shim/issues/128

Signed-off-by: Gary Lin <glin@suse.com>
This is a backport from devel of:

  commit da6284569c4b5d60d14e6187f696f54cccb7b3d2
  Author: Gary Lin <glin@suse.com>
  Date:   Wed May 23 18:13:05 2018 +0800

      fallback: show a countdown menu before reset

      Some machines with the faulty firmware may keep booting the default boot
      path instead of the boot option we create. To avoid the infinite reset
      loop, this commit introduce a countdown screen before fallback resets the
      system, so the user can interrupt the system reset and choose to boot
      the restored boot option. The "Always continue boot" option creates a
      BS+RT+NV variable, FB_NO_REBOOT, to make fallback boot the first boot
      option afterward without asking. The user can revert the behavior by
      removing the variable.

      https://github.com/rhboot/shim/issues/128

Signed-off-by: Gary Lin <glin@suse.com>
Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoconsole: Move the countdown function to console.c
Gary Lin [Wed, 23 May 2018 08:58:31 +0000 (16:58 +0800)]
console: Move the countdown function to console.c

Move the countdown function from MokManager to console.c to make the
function public

Also make console_save_and_set_mode() and console_restore_mode() public

Signed-off-by: Gary Lin <glin@suse.com>
3 years agolib: move print_crypto_errors() out of console.c
Gary Lin [Fri, 22 Nov 2019 09:22:15 +0000 (17:22 +0800)]
lib: move print_crypto_errors() out of console.c

print_crypto_errors() will pull in the whole openssl library which
bloats the size of fallback.efi. Move the function to an independent
file (lib/print_crypto.c) to reduce the file size of fallback.efi from
1.3MB to 93KB.

Signed-off-by: Gary Lin <glin@suse.com>
3 years agoFix sbsign command usage
Chris Coulson [Wed, 15 Jul 2020 11:16:10 +0000 (12:16 +0100)]
Fix sbsign command usage

The previous make target was passing all of the target's prerequisites
as boot images to sbsign, causing it to fail.

3 years agoMake sure MIN() and MAX() are always defined.
Peter Jones [Thu, 10 Dec 2020 16:24:09 +0000 (11:24 -0500)]
Make sure MIN() and MAX() are always defined.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoMakefile: use fixed build host if SOURCE_DATE_EPOCH is defined
Luca Boccassi [Fri, 15 Feb 2019 21:42:10 +0000 (21:42 +0000)]
Makefile: use fixed build host if SOURCE_DATE_EPOCH is defined

If SOURCE_DATE_EPOCH is defined then we can be reasonably sure the
user wants the build to be fully reproducible, so use a fixed string.
In case of a cross build, using uname -s -m -p -i o will still report
the host's kernel architecture, which will trip some CIs like
Debian's.

This is a backport from devel of:

  commit 11fd3197d21f94b491ccfc1da6d38b14060e62d7
  Author: Luca Boccassi <bluca@debian.org>
  Date:   Fri Feb 15 21:42:10 2019 +0000

      Makefile: use fixed build host if SOURCE_DATE_EPOCH is defined

      If SOURCE_DATE_EPOCH is defined then we can be reasonably sure the
      user wants the build to be fully reproducible, so use a fixed string.
      In case of a cross build, using uname -s -m -p -i o will still report
      the host's kernel architecture, which will trip some CIs like
      Debian's.

Signed-off-by: Luca Boccassi <bluca@debian.org>
Signed-off-by: Luca Boccassi <bluca@debian.org>
Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agosrc/netboot.c: remove the execute bit
Gary Lin [Wed, 13 May 2020 07:07:55 +0000 (15:07 +0800)]
src/netboot.c: remove the execute bit

Signed-off-by: Gary Lin <glin@suse.com>
3 years agoSPDX: Clarify the attribution for James's lib/ code
Peter Jones [Sun, 14 Feb 2021 16:22:08 +0000 (11:22 -0500)]
SPDX: Clarify the attribution for James's lib/ code

At the time, this was explicitly contributed under the Tiano license,
even though the original code[0] is LGPLv2.1.

[0]: git://git.kernel.org/pub/scm/linux/kernel/git/jejb/efitools.git

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoSPDX: Clarify the attribution for crypt_blowfish
Peter Jones [Sun, 14 Feb 2021 16:21:43 +0000 (11:21 -0500)]
SPDX: Clarify the attribution for crypt_blowfish

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoFix up a bunch of our license statements and add SPDX most places
Peter Jones [Fri, 11 Dec 2020 20:54:55 +0000 (15:54 -0500)]
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>
3 years agoFix typo in a comment
Lisa White [Sat, 8 Feb 2020 19:22:39 +0000 (19:22 +0000)]
Fix typo in a comment

3 years agoConvert README -> README.md
Colin Walters [Tue, 23 Jun 2020 01:57:05 +0000 (01:57 +0000)]
Convert README -> README.md

One of the really great things about Github IMO is how
"front and center" the README file in a repository is (just
compare with Sourceforge).

Github renders it more nicely if the file is declared to be Markdown,
so let's do that.  Add a bit of formatting: using code fences
for code, hyperlinks for other files etc.

I also added a title block from the Fedora package `Summary`
since while I know in theory shim is independent of bootloaders,
let's say what the 95% case is here.

3 years ago.gitignore: ignore .gdbinit
Peter Jones [Wed, 27 Jan 2021 16:54:16 +0000 (11:54 -0500)]
.gitignore: ignore .gdbinit

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years ago.gitignore: add build dirs and shim_cert.h
Peter Jones [Mon, 15 Feb 2021 21:42:46 +0000 (16:42 -0500)]
.gitignore: add build dirs and shim_cert.h

This adds stuff that only ever gets made as an artifact of building
(though build*/ generally doesn't, as of this commit.)

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoRe-alphabetize .gitignore.
Peter Jones [Mon, 15 Feb 2021 21:18:52 +0000 (16:18 -0500)]
Re-alphabetize .gitignore.

This had gotten weird in a couple of ways.  Easy to fix.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoBUILDING: Fix a typo
Nicholas Bishop [Thu, 17 May 2018 23:28:53 +0000 (19:28 -0400)]
BUILDING: Fix a typo

This is a backport from devel for:

  commit 852091d63f73011742c61c976e40f35edd74d598
  Author: Nicholas Bishop <nicholasbishop@gmail.com>
  Date:   Thu May 17 19:28:53 2018 -0400

      Fix typo

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoBUILDING: fix missing DISABLE_EBS_PROTECTION section
Peter Jones [Sun, 14 Feb 2021 22:15:54 +0000 (17:15 -0500)]
BUILDING: fix missing DISABLE_EBS_PROTECTION section

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoREADME: Remove superfluous *and*
Paul Menzel [Wed, 23 May 2018 10:43:45 +0000 (12:43 +0200)]
README: Remove superfluous *and*

3 years agoAdd .cer/.crt/.esl to .gitignore
Peter Jones [Mon, 29 Jun 2020 18:06:34 +0000 (14:06 -0400)]
Add .cer/.crt/.esl to .gitignore

This was previously on devel as:

  commit 2e29c0358888412e9addfb016cc72f6e89ffb536
  Author: Peter Jones <pjones@redhat.com>
  Date:   Mon Jun 29 14:06:34 2020 -0400

  Add .cer/.crt/.esl to .gitignore

But .cer and .crt were added independently in another commit since then.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoAdd screen logs to .gitignore
Peter Jones [Mon, 18 Nov 2019 19:34:38 +0000 (14:34 -0500)]
Add screen logs to .gitignore

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoAlso ignore .sw?
Peter Jones [Wed, 4 Sep 2019 15:01:48 +0000 (11:01 -0400)]
Also ignore .sw?

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoIgnore *.hash
Jia Zhang [Tue, 30 Oct 2018 13:33:22 +0000 (21:33 +0800)]
Ignore *.hash

*.hash should be ignored by git status if ENABLE_SHIM_HASH is
configured.

Signed-off-by: Jia Zhang <zhang.jia@linux.alibaba.com>
3 years agoAdd mm/fb hashing to TODO, put that and related things under 'Reproducible builds'
Mathieu Trudel-Lapierre [Tue, 21 Aug 2018 18:43:12 +0000 (14:43 -0400)]
Add mm/fb hashing to TODO, put that and related things under 'Reproducible builds'

3 years agoAdd fallback boot loop detection to TODO
Peter Jones [Wed, 1 Aug 2018 15:04:14 +0000 (11:04 -0400)]
Add fallback boot loop detection to TODO

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoAdd some *more* TODO tasks.
Peter Jones [Fri, 13 Apr 2018 19:17:58 +0000 (15:17 -0400)]
Add some *more* TODO tasks.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoAdd another unfortunate TODO entry.
Peter Jones [Thu, 12 Apr 2018 19:08:09 +0000 (15:08 -0400)]
Add another unfortunate TODO entry.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoAdd some more TODOs for shim 16
Peter Jones [Tue, 10 Apr 2018 16:36:12 +0000 (12:36 -0400)]
Add some more TODOs for shim 16

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoTry to make scan-build.mk work without scan-build installed.
Peter Jones [Mon, 7 Dec 2020 19:30:37 +0000 (14:30 -0500)]
Try to make scan-build.mk work without scan-build installed.

3 years agoTry to make coverity.mk work without cov-build installed.
Peter Jones [Mon, 7 Dec 2020 19:30:37 +0000 (14:30 -0500)]
Try to make coverity.mk work without cov-build installed.

3 years agoWe're not using travis-build.sh any more.
Peter Jones [Fri, 11 Dec 2020 20:32:56 +0000 (15:32 -0500)]
We're not using travis-build.sh any more.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agosbat: make the includes work like everything else.
Peter Jones [Mon, 15 Feb 2021 17:24:33 +0000 (12:24 -0500)]
sbat: make the includes work like everything else.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoadd an ascii strndup() implementation.
Peter Jones [Sat, 13 Feb 2021 18:14:02 +0000 (13:14 -0500)]
add an ascii strndup() implementation.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoget_variable: always allocate a NUL character at the end.
Peter Jones [Sat, 13 Feb 2021 18:02:14 +0000 (13:02 -0500)]
get_variable: always allocate a NUL character at the end.

Sometimes we're loading structures that are parsed in string-like ways,
but can't necessarily be trusted to be zero-terminated.  Solve that by
making sure we always have enough aligned, trailing zero bytes to always
have at least one NUL character, no matter which character type is being
parsed.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoAdd some linked list primitives.
Peter Jones [Sat, 13 Feb 2021 15:36:44 +0000 (10:36 -0500)]
Add some linked list primitives.

This adds basic linked list structures, initializers, and iterators.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoAdd an example SBAT workflow document
Peter Jones [Sat, 13 Feb 2021 00:35:28 +0000 (01:35 +0100)]
Add an example SBAT workflow document

Add a file that contains example workflows for SBAT and better illustrate
what type of content is expected to be present in both the .sbat section
and the SBAT authenticated EFI variable.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoAdd Secure Boot Advanced Targeting (SBAT) specification document
Jan Setje-Eilers [Fri, 12 Feb 2021 23:46:36 +0000 (00:46 +0100)]
Add Secure Boot Advanced Targeting (SBAT) specification document

SBAT is a new Generation Number Based Revocation meant to replace the DBX
Revocation List Files mechanism. It is more flexible and allow to revoke
sets of binaries, instead of having to list all of them as with the DBX.

Metadata that includes the vendor, product family, product, component,
version and generation are added to artifacts in a .sbat section. This
is protected by the digital signature and so it cannot be tampered.

Signed-off-by: Jan Setje-Eilers <jan.setjeeilers@oracle.com>
Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Gary Lin <glin@suse.com>
3 years agoSBAT: parse a copy of the table that's got a NUL at the end
Peter Jones [Wed, 10 Feb 2021 01:02:26 +0000 (20:02 -0500)]
SBAT: parse a copy of the table that's got a NUL at the end

Right now we allocate the PE file's contents in RW memory, but hopefully
that won't always be the case.  Our SBAT parsing, however, very much
expects to be able to edit it.  We also don't actually know that shim's
.sbat section is loaded r/w, so we can't necessarily write there.

This patch copies the SBAT data to its own buffer, plus one NUL byte at
the end, so we can always be sure that will work.

Signed-off-by: Peter Jones <pjones@redhat.com>
3 years agoAdd a function to parse the SBAT metadata from the .sbat section
Javier Martinez Canillas [Wed, 10 Feb 2021 00:26:46 +0000 (01:26 +0100)]
Add a function to parse the SBAT metadata from the .sbat section

Parse the SBAT [0] Version-Based Revocation Metadata that's contained in a
.sbat data section of the loaded PE binary. This information is used along
with data in a SBAT variable to determine if a EFI binary has been revoked.

[0]: https://github.com/rhboot/shim/blob/sbat/SBAT.md

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
3 years agoAdd the beginning of .sbat parsing stuff
Peter Jones [Wed, 2 Dec 2020 05:05:16 +0000 (00:05 -0500)]
Add the beginning of .sbat parsing stuff

Signed-off-by: Peter Jones <pjones@redhat.com>