]> git.proxmox.com Git - efi-boot-shim.git/log
efi-boot-shim.git
5 months agorevert accidentally committed changes proxmox/bookworm
Fabian Grünbichler [Mon, 20 Nov 2023 10:06:51 +0000 (11:06 +0100)]
revert accidentally committed changes

12 months agobump version to 15.7-1+pmx1 proxmox/15.7-1+pmx1
Fabian Grünbichler [Mon, 20 Mar 2023 09:32:56 +0000 (10:32 +0100)]
bump version to 15.7-1+pmx1

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
12 months agod/control: update Maintainer
Fabian Grünbichler [Mon, 20 Mar 2023 09:32:07 +0000 (10:32 +0100)]
d/control: update Maintainer

and Vcs-*

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
12 months agod/control: add empty version pinning package
Fabian Grünbichler [Mon, 20 Mar 2023 09:31:09 +0000 (10:31 +0100)]
d/control: add empty version pinning package

that our meta package can depend on to ensure *our* shim package is installed,
even if Debian at some point ships a higher version..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
12 months agodrop patch inapplicable for Proxmox
Fabian Grünbichler [Mon, 20 Mar 2023 09:26:40 +0000 (10:26 +0100)]
drop patch inapplicable for Proxmox

we never shipped a broken Grub with SBAT 3

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
12 months agoadd Proxmox Uefi Secure Boot CA certificate
Fabian Grünbichler [Thu, 16 Mar 2023 12:44:38 +0000 (13:44 +0100)]
add Proxmox Uefi Secure Boot CA certificate

for embedding in shim as trust anchor for signed EFI binaries. the
corresponding private key was generated on and is stored on a FIPS compliant
HSM.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
12 months agoadd Proxmox file references to packaging
Fabian Grünbichler [Thu, 16 Mar 2023 12:43:54 +0000 (13:43 +0100)]
add Proxmox file references to packaging

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
14 months agoRelease 15.7-1
Steve McIntyre [Tue, 31 Jan 2023 10:18:29 +0000 (10:18 +0000)]
Release 15.7-1

14 months agoSwith to using the upstream "enable NX" patch
Steve McIntyre [Mon, 30 Jan 2023 18:12:20 +0000 (18:12 +0000)]
Swith to using the upstream "enable NX" patch

14 months agoBlock Debian grub binaries with sbat < 4 (see #1024617)
Steve McIntyre [Sun, 29 Jan 2023 23:35:03 +0000 (23:35 +0000)]
Block Debian grub binaries with sbat < 4 (see #1024617)

14 months agoEnable NX support at build time
Steve McIntyre [Tue, 24 Jan 2023 22:37:23 +0000 (22:37 +0000)]
Enable NX support at build time

As required by policy for signing new shim binaries.

15 months agoUpdate upstream commit hash in build
Steve McIntyre [Sun, 22 Jan 2023 15:12:23 +0000 (15:12 +0000)]
Update upstream commit hash in build

We're using 657b2483ca6e9fcf2ad8ac7ee577ff546d24c3aa, which is the
15.7 release plus the one patch we're applying.

15 months agoUpdate to Standards-Version 4.6.2 (no changes needed)
Steve McIntyre [Sun, 22 Jan 2023 14:06:29 +0000 (14:06 +0000)]
Update to Standards-Version 4.6.2 (no changes needed)

15 months agoSwitch to using gcc-12
Steve McIntyre [Sun, 22 Jan 2023 14:02:25 +0000 (14:02 +0000)]
Switch to using gcc-12

Closes: #1022180
15 months agoSwitch to new upstream (15.7)
Steve McIntyre [Sun, 22 Jan 2023 13:14:06 +0000 (13:14 +0000)]
Switch to new upstream (15.7)

Also import patch to deal with buggy binutils

15 months agoUpdate upstream source from tag 'upstream/15.7'
Steve McIntyre [Sun, 22 Jan 2023 13:05:11 +0000 (13:05 +0000)]
Update upstream source from tag 'upstream/15.7'

Update to upstream version '15.7'
with Debian dir f802105ae061241b13ab962854f56388092fc703

15 months agoNew upstream version 15.7
Steve McIntyre [Sun, 22 Jan 2023 13:05:10 +0000 (13:05 +0000)]
New upstream version 15.7

21 months agoRelease 15.6-1
Steve McIntyre [Thu, 21 Jul 2022 12:04:36 +0000 (13:04 +0100)]
Release 15.6-1

22 months agoStart packaging updates for the new 15.6 upstream release
Steve McIntyre [Wed, 22 Jun 2022 23:23:21 +0000 (00:23 +0100)]
Start packaging updates for the new 15.6 upstream release

Remove all our patches, all upstream now

22 months agoNew upstream version 15.6
Steve McIntyre [Wed, 22 Jun 2022 23:16:56 +0000 (00:16 +0100)]
New upstream version 15.6

22 months agoUpdate upstream source from tag 'upstream/15.6'
Steve McIntyre [Wed, 22 Jun 2022 23:16:56 +0000 (00:16 +0100)]
Update upstream source from tag 'upstream/15.6'

Update to upstream version '15.6'
with Debian dir 952ad3d5a92a2003f3496a79d1875a951c255396

23 months agoUpdate the 32-bit format patch after upstream review
Steve McIntyre [Sun, 1 May 2022 18:17:48 +0000 (19:17 +0100)]
Update the 32-bit format patch after upstream review

23 months agoAdd patch headers for our patches now I've pushed PRs
Steve McIntyre [Thu, 28 Apr 2022 11:51:50 +0000 (12:51 +0100)]
Add patch headers for our patches now I've pushed PRs

23 months agoTry again on the string format fix
Steve McIntyre [Wed, 27 Apr 2022 23:53:26 +0000 (00:53 +0100)]
Try again on the string format fix

23 months agoFix format strings for 32-bit builds
Steve McIntyre [Wed, 27 Apr 2022 23:47:27 +0000 (00:47 +0100)]
Fix format strings for 32-bit builds

23 months agoAdd new build-dep on libefivar-dev for tests
Steve McIntyre [Wed, 27 Apr 2022 23:19:27 +0000 (00:19 +0100)]
Add new build-dep on libefivar-dev for tests

23 months agoTry again with includes
Steve McIntyre [Wed, 27 Apr 2022 22:15:28 +0000 (23:15 +0100)]
Try again with includes

23 months agoTweak setup for dh_auto_test so the tests work
Steve McIntyre [Wed, 27 Apr 2022 22:15:28 +0000 (23:15 +0100)]
Tweak setup for dh_auto_test so the tests work

23 months agoStart packaging updates for the new 15.51 upstream release
Steve McIntyre [Wed, 27 Apr 2022 21:50:33 +0000 (22:50 +0100)]
Start packaging updates for the new 15.51 upstream release

Remove all our patches, all upstream now.

23 months agoNew upstream version 15.5
Steve McIntyre [Wed, 27 Apr 2022 21:41:59 +0000 (22:41 +0100)]
New upstream version 15.5

23 months agoUpdate upstream source from tag 'upstream/15.5'
Steve McIntyre [Wed, 27 Apr 2022 21:41:59 +0000 (22:41 +0100)]
Update upstream source from tag 'upstream/15.5'

Update to upstream version '15.5'
with Debian dir 3ac353daa3d32301e3b225b2b6f446200a2c682f

2 years agoTweak how we call grub-install; don't abort on error
Steve McIntyre [Mon, 12 Jul 2021 08:51:50 +0000 (09:51 +0100)]
Tweak how we call grub-install; don't abort on error

Not ideal behaviour either, but don't break upgrades. Copy the
behaviour from the grub packages here. Closes: #990966

2 years agoRelease 15.4-6
Steve McIntyre [Wed, 23 Jun 2021 18:05:01 +0000 (19:05 +0100)]
Release 15.4-6

2 years agoIn insecure mode, don't abort if we can't create the MokListXRT var
Steve McIntyre [Tue, 22 Jun 2021 21:19:08 +0000 (22:19 +0100)]
In insecure mode, don't abort if we can't create the MokListXRT var

Upstream issue #372. Closes: #989962, #990158

2 years agoAdd arm64 patch to tweak section layout and stop crashing problems
Steve McIntyre [Mon, 21 Jun 2021 11:43:33 +0000 (12:43 +0100)]
Add arm64 patch to tweak section layout and stop crashing problems

Upstream issue #371. Closes: #990082, #990190

2 years agoAdd defensive code around calls to db_get
Steve McIntyre [Wed, 5 May 2021 23:40:56 +0000 (00:40 +0100)]
Add defensive code around calls to db_get

Don't fail if they return errors.

2 years agoFix up the template maintainer scripts
Steve McIntyre [Tue, 4 May 2021 13:45:00 +0000 (14:45 +0100)]
Fix up the template maintainer scripts

if we're not running on an EFI system then exit cleanly

2 years agoAdd maintainer scripts to the template packages
Steve McIntyre [Mon, 3 May 2021 19:52:35 +0000 (20:52 +0100)]
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

3 years agoAdd changelog for 15.4-2 with new patches
Steve McIntyre [Tue, 20 Apr 2021 23:25:59 +0000 (00:25 +0100)]
Add changelog for 15.4-2 with new patches

3 years agoDon't call QueryVariableInfo() on EFI 1.10 machines
Steve McIntyre [Tue, 20 Apr 2021 23:25:20 +0000 (00:25 +0100)]
Don't call QueryVariableInfo() on EFI 1.10 machines

New patch from upstream, don't break old Macs

3 years agoFix handling of ignore_db and user_insecure_mode
Steve McIntyre [Tue, 20 Apr 2021 23:24:31 +0000 (00:24 +0100)]
Fix handling of ignore_db and user_insecure_mode

Extra patch from upstream

3 years agoStop hardcoding the release version in the rules file
Steve McIntyre [Sat, 17 Apr 2021 14:57:22 +0000 (15:57 +0100)]
Stop hardcoding the release version in the rules file

We can grab it from the changelog already

3 years agoClean more things
Steve McIntyre [Sat, 17 Apr 2021 14:52:42 +0000 (15:52 +0100)]
Clean more things

3 years agoPrep for releasing based on 15.4
Steve McIntyre [Sat, 17 Apr 2021 14:49:51 +0000 (15:49 +0100)]
Prep for releasing based on 15.4

3 years agoallocate MOK config table as BootServicesData
Steve McIntyre [Wed, 14 Apr 2021 20:42:57 +0000 (21:42 +0100)]
allocate MOK config table as BootServicesData

Another patch from upstream, needed with newer kernels on x86

3 years agoAdd one more patch from upstream to fix i386 binary relocations
Steve McIntyre [Wed, 31 Mar 2021 19:51:26 +0000 (20:51 +0100)]
Add one more patch from upstream to fix i386 binary relocations

3 years agoMove the sha256sum call to the end of the install phase
Steve McIntyre [Wed, 31 Mar 2021 17:52:40 +0000 (18:52 +0100)]
Move the sha256sum call to the end of the install phase

Make the output easier to find

3 years agoOverride dh_auto_build setting INSTALL, cut down on build noise
Steve McIntyre [Wed, 31 Mar 2021 17:42:38 +0000 (18:42 +0100)]
Override dh_auto_build setting INSTALL, cut down on build noise

3 years agoUpdate to the 15.4 release
Steve McIntyre [Wed, 31 Mar 2021 17:27:09 +0000 (18:27 +0100)]
Update to the 15.4 release

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>