Commit Graph

1510 Commits

Author SHA1 Message Date
Steve McIntyre
29f231fd04 Add maintainer scripts to the template packages
Manage installing and removing fbXXX.efi and mmXXX.efi when we
install/remove the shim-helpers-$arch-signed packages. Closes: #966845
2021-05-03 20:24:52 +00:00
Steve McIntyre
11e0f1dafd Add changelog for 15.4-2 with new patches 2021-04-21 00:25:59 +01:00
Steve McIntyre
260b35a29f Don't call QueryVariableInfo() on EFI 1.10 machines
New patch from upstream, don't break old Macs
2021-04-21 00:25:20 +01:00
Steve McIntyre
cf870e72b0 Fix handling of ignore_db and user_insecure_mode
Extra patch from upstream
2021-04-21 00:24:31 +01:00
Steve McIntyre
ae8c2e79ef Stop hardcoding the release version in the rules file
We can grab it from the changelog already
2021-04-17 15:57:22 +01:00
Steve McIntyre
e4bcc019f9 Clean more things 2021-04-17 15:52:42 +01:00
Steve McIntyre
9af3bbb2c6 Prep for releasing based on 15.4 2021-04-17 15:49:51 +01:00
Steve McIntyre
8d2bea5ad9 allocate MOK config table as BootServicesData
Another patch from upstream, needed with newer kernels on x86
2021-04-14 21:46:16 +01:00
Steve McIntyre
f81081d61b Add one more patch from upstream to fix i386 binary relocations 2021-03-31 20:51:26 +01:00
Steve McIntyre
a42e843a73 Move the sha256sum call to the end of the install phase
Make the output easier to find
2021-03-31 18:52:40 +01:00
Steve McIntyre
d6b0fa523d Override dh_auto_build setting INSTALL, cut down on build noise 2021-03-31 17:51:15 +00:00
Steve McIntyre
2f7c6c8d0c Update to the 15.4 release 2021-03-31 18:27:09 +01:00
Steve McIntyre
ec10b2569d Update upstream source from tag 'upstream/15.4'
Update to upstream version '15.4'
with Debian dir 9316008066
2021-03-31 18:24:30 +01:00
Steve McIntyre
8119f7183f New upstream version 15.4 2021-03-31 18:24:24 +01:00
Steve McIntyre
b43a60b292 Print sha256 checksums of the EFI binaries when the build is done 2021-03-24 16:34:14 +00:00
Steve McIntyre
90ce8849b7 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.
2021-03-24 13:25:16 +00:00
Steve McIntyre
f1d23e7293 Add missing build-dep on xxd for build-time unit tests 2021-03-24 02:21:53 +00:00
Steve McIntyre
031e5cce38 New upstream version 15.3 2021-03-23 23:49:46 +00:00
Steve McIntyre
1251a7ba86 Update upstream source from tag 'upstream/15.3'
Update to upstream version '15.3'
with Debian dir 1b484f1c1a
2021-03-23 23:49:46 +00:00
Steve McIntyre
85b409232c Switch to using the 15.3 release from upstream 2021-03-23 23:43:27 +00:00
Steve McIntyre
f43e9abcc5 Remove all out outstanding patches
* cast-CHAR8-string-handling.patch no longer needed
 * fix-Make.coverity-bashisms.patch went upstream
2021-03-23 23:38:30 +00:00
Steve McIntyre
e6b19d2db7 Update copyright file
Update a couple of top-level changes, copy in gnu-efi information from
the gnu-efi package
2021-03-23 23:34:12 +00:00
Steve McIntyre
57e2a32bef 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
2021-03-23 23:33:13 +00:00
Steve McIntyre
de3def7f53 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.
2021-03-23 23:33:04 +00:00
Steve McIntyre
3139bb3585 Tweak the gnu-efi tarball code 2021-03-23 23:32:57 +00:00
Steve McIntyre
9b014236c8 Add an extra rule to generate the extra gnu-efi tarball
Thanks to Dmitri John Ledkov for help
2021-03-23 23:32:52 +00:00
Steve McIntyre
2e0a83e1f2 Add Debian SBAT data to the shim build
Add a Debian SBAT template, and rules to use it
Adds a build-dep on dos2unix
2021-03-23 23:32:45 +00:00
Steve McIntyre
58195ca37e Add dbx entries for all our existing grub binaries
They're insecure, let's break the chainloading hole
2021-03-23 23:32:38 +00:00
Steve McIntyre
3dbe6c0c26 Change changelog to shut lintian up 2021-02-21 17:06:12 +00:00
Steve McIntyre
bcc26d6dfb Remove artifacts that upstream installs that we don't use
... to keep debhelper from complaining
2021-02-21 16:34:28 +00:00
Steve McIntyre
aacee4356e 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
2021-02-21 16:34:28 +00:00
Steve McIntyre
168d42d09d Trivial change to remove bashisms in Make.coverity 2021-02-21 16:34:28 +00:00
Steve McIntyre
e105392d54 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
2021-02-21 16:33:31 +00:00
Steve McIntyre
334e9afa91 Switch to using gcc-10 rather than gcc-9. Closes: #978521 2021-02-21 13:53:17 +00:00
Steve McIntyre
371ed906c5 Switch to newer upstream "release" 15+1613861442.888f5b5
Many many updates, but caring mainly about SBAT support
2021-02-21 13:50:33 +00:00
Steve McIntyre
2a55644555 Update upstream source from tag 'upstream/15+1613861442.888f5b5'
Update to upstream version '15+1613861442.888f5b5'
with Debian dir 15b0853a73
2021-02-21 13:46:16 +00:00
Jan Setje-Eilers
888f5b544b Add --set-section-alignment '.sbat=512' to objcopy command line 2021-02-20 17:50:42 -05:00
Chris Coulson
d74eb44aac 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]
2021-02-20 17:48:22 -05:00
Chris Coulson
aaa7b427a5 build: Pass the correct paths to sbsign
Signed-off-by: Chris Coulson <chris.coulson@canonical.com>
2021-02-19 16:06:40 -05:00
Peter Jones
9bef30f529 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>
2021-02-19 14:28:10 -05:00
Javier Martinez Canillas
8e34030ba5 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>
2021-02-19 14:28:10 -05:00
Javier Martinez Canillas
1919b566b0 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>
2021-02-19 14:28:10 -05:00
Javier Martinez Canillas
4c9654fb68 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>
2021-02-19 14:28:10 -05:00
Peter Jones
496ca920ec 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>
2021-02-19 14:28:10 -05:00
Javier Martinez Canillas
ea1c872418 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>
2021-02-19 14:28:10 -05:00
Peter Jones
1e78d701ac parse_sbat: handle the realloc failure leak and batch allocations.
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-19 14:28:10 -05:00
Alex Burmashev
31e1aa7aca 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>
2021-02-19 14:28:10 -05:00
Peter Jones
f1feb3ac04 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>
2021-02-19 14:28:10 -05:00
Peter Jones
146f9d8e8d 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>
2021-02-19 14:28:10 -05:00
Hai Huang
e3325f8100 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
2021-02-19 11:11:31 -05:00