Commit Graph

1438 Commits

Author SHA1 Message Date
Peter Jones
ff890cf452 mok: minor cleanups
Signed-off-by: Peter Jones <pjones@redhat.com>
Upstream-commit-id: 617b9007668
2020-07-23 20:52:12 -04:00
Gary Lin
3d62232feb mok: also mirror the build cert to MokListRT
If the build cert is enabled, we should also mirror it to MokListRT.

Signed-off-by: Gary Lin <glin@suse.com>
Upstream-commit-id: aecbe1f99b6
2020-07-23 20:52:12 -04:00
Gary Lin
7a3638173e shim: only include shim_cert.h in shim.c
The shim_cert array was declared as a static array, and every user of
shim_cert.h would create a shim_cert array for its own and grow the file
size. To remove the unnecessary duplicate shim_cert arrays, this commit
declares shim_cert in shim.c while other users still can access the
array through the external variables: build_cert and build_cert_size.

Signed-off-by: Gary Lin <glin@suse.com>
Upstream-commit-id: 4e2d62f0f4e
2020-07-23 20:52:12 -04:00
Peter Jones
ff6e5cda13 mok: consolidate mirroring code in a helper instead of using goto
There's no reason to complicate the logic with a goto here, instead just
pull the logic we're jumping to out to a helper function.

Signed-off-by: Peter Jones <pjones@redhat.com>
Upstream-commit-id: 29c11483101
2020-07-23 20:52:12 -04:00
Gary Lin
f748139695 mok: fix the mirroring of RT variables
When there is no key in MokList, import_mok_state() just skipped MokList
even though it should always mirror the vendor cert. Besides, the faulty
check of 'present' and 'addend' invalidates the mirroring of MokListXRT,
MokSBStateRT, and MokIgnoreDB.

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

Signed-off-by: Gary Lin <glin@suse.com>
Upstream-commit-id: 4b27ae034ba
2020-07-23 20:52:12 -04:00
Patrick Uiterwijk
ac0400b202 Make sure that MOK variables always get mirrored
Without this, if a Mok variable doesn't exist in Boot Services, it will also
not be copied to Runtime, even if we have data to be added to it (vendor cert).
This patch makes sure that if we have extra data to append, we still mirror
the variable.

Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>
Upstream-commit-id: 9ab0d796bdc
2020-07-23 20:52:12 -04:00
Peter Korsgaard
ee832f21c6 Cryptlib: fix build on 32bit ARM
Pass MDE_CPU_ARM, similar to how it is done for the other supported
architectures, otherwise the build fails in:

Cryptlib/Include/OpenSslSupport.h:55:2: error:
 #error Unknown target architecture

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Upstream-commit-id: cb83c14628b
2020-07-23 20:52:12 -04:00
Peter Korsgaard
7f080b30f3 Make.default: use correct flags to disable unaligned access for 32 bit ARM
The GCC flag to disable unaligned access on 32bit ARM is
-mno-unaligned-access, not -mstrict-align (which is used on aarch64):

https://lkml.org/lkml/2018/8/3/294

Otherwise build dies with:
arm-linux-gnueabihf-gcc: error: unrecognized command line option
   ‘-mstrict-align’; did you mean ‘-Wstrict-aliasing’?

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Upstream-commit-id: 41b93358e8c
2020-07-23 20:52:12 -04:00
Luca Boccassi
8544018093 Makefile: do not run git on clean if there's no .git directory
When building in minimal chroot on build workers, like in Debian (where
make clean is called at the beginning of the build process), git will
not be available. Skip the git clean.

Signed-off-by: Luca Boccassi <bluca@debian.org>
Upstream-commit-id: be352762a01
2020-07-23 20:52:12 -04:00
dann frazier
d5b72b322d Fix apparent typo in ARM 32-on-64 code
The architecture is aarch64, not arch64.

Fixes: 750584c207 ("Make 64-on-32 maybe work on x86_64.")
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Upstream-commit-id: e9f67aaa75a
2020-07-23 20:52:12 -04:00
Maran Wilson
3d04aef8d8 Fix for "Section 0 has negative size" error when loading fbaa64.efi
The current code is incorrectly failing to load the fbaa64.efi image found
in Arm servers even though the UEFI shell code is able to properly load
and execute the same image.

The problem is due to the presence of a section header that has zero size
and address and marked "discardable" in the fbaa64.efi image.

Although there is already a check further down in the code to look for
the discardable bit and skip further verification checks if set, we never
get to that point due to the "end < base" check at the start of the loop.

Here is a dump of the fbaa64.efi image as compiled on an Arm machine
from the latest code in this repo:

% # First I used hexedit to change header byte from 'AA' to '86'
% # so that objdump was able to correctly parse the file:
% objdump -x -m aarch64 fbaa64.efi

fbaa64.efi:     file format pei-x86-64
fbaa64.efi
architecture: i386:x86-64, flags 0x00000103:
HAS_RELOC, EXEC_P, D_PAGED
start address 0x0000000000000148

Characteristics 0x20e
        executable
        line numbers stripped
        symbols stripped
        debugging information removed

Time/Date               Wed Dec 31 16:00:00 1969
Magic                   020b    (PE32+)
MajorLinkerVersion      2
MinorLinkerVersion      20
SizeOfCode              000b15d0
SizeOfInitializedData   00000000
SizeOfUninitializedData 00000000
AddressOfEntryPoint     0000000000000148
BaseOfCode              0000000000000148
ImageBase               0000000000000000
SectionAlignment        0000000000000020
FileAlignment           0000000000000008
MajorOSystemVersion     0
MinorOSystemVersion     0
MajorImageVersion       0
MinorImageVersion       0
MajorSubsystemVersion   0
MinorSubsystemVersion   0
Win32Version            00000000
SizeOfImage             000b1718
SizeOfHeaders           00000148
CheckSum                00000000
Subsystem               0000000a        (EFI application)
DllCharacteristics      00000000
SizeOfStackReserve      0000000000000000
SizeOfStackCommit       0000000000000000
SizeOfHeapReserve       0000000000000000
SizeOfHeapCommit        0000000000000000
LoaderFlags             00000000
NumberOfRvaAndSizes     00000006

The Data Directory
Entry 0 0000000000000000 00000000 Export Directory [.edata (or where ever we found it)]
Entry 1 0000000000000000 00000000 Import Directory [parts of .idata]
Entry 2 0000000000000000 00000000 Resource Directory [.rsrc]
Entry 3 0000000000000000 00000000 Exception Directory [.pdata]
Entry 4 0000000000000000 00000000 Security Directory
Entry 5 0000000000000000 00000000 Base Relocation Directory [.reloc]
Entry 6 0000000000000000 00000000 Debug Directory
Entry 7 0000000000000000 00000000 Description Directory
Entry 8 0000000000000000 00000000 Special Directory
Entry 9 0000000000000000 00000000 Thread Storage Directory [.tls]
Entry a 0000000000000000 00000000 Load Configuration Directory
Entry b 0000000000000000 00000000 Bound Import Directory
Entry c 0000000000000000 00000000 Import Address Table Directory
Entry d 0000000000000000 00000000 Delay Import Directory
Entry e 0000000000000000 00000000 CLR Runtime Header
Entry f 0000000000000000 00000000 Reserved

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .reloc        00000000  0000000000000000  0000000000000000  00000000  2**0
                  ALLOC, LOAD, READONLY, DATA
  1 .text         000b15d0  0000000000000148  0000000000000148  00000148  2**4
                  CONTENTS, ALLOC, LOAD, CODE
SYMBOL TABLE:
no symbols

Signed-off-by: Maran Wilson <maran.wilson@oracle.com>
Reviewed-by: Aaron Young <aaron.young@oracle.com>
Reviewed-by: Jack Schwartz <jack.schwartz@oracle.com>
Upstream-commit-id: 6df7a8f5609
2020-07-23 20:52:12 -04:00
Javier Martinez Canillas
818a0dbd24 shim: Prevent shim to set itself as a second stage loader
When shim is invoked from a relative path (e.g: from the UEFI shell), the
Loaded Image handle LoadOptions can be set to the binary relative path.

But the is_our_path() function only checks if LoadOptions is set to the
absolute path of shim to ignore it. So if a relative path is there, shim
would set itself as the secondary loader and invoke itself in a loop.

To prevent that, use the path in LoadOptions to calculate the absolute
path and compare it with the one in the Loader Image handle FilePath.

Resolves: bz#1622485

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Maran Wilson maran.wilson@oracle.com
Tested-by: Maran Wilson maran.wilson@oracle.com
Upstream-commit-id: e563bc3dcd1
2020-07-23 20:52:12 -04:00
Javier Martinez Canillas
79be2af526 shim: Properly generate absolute paths from relative image paths
The generate_path_from_image_path() doesn't properly handle the case when
shim is invoked using a relative path (e.g: from the EFI shell). In that
function, always the last component is stripped from absolute file path
to calculate the dirname, and this is concatenated with the image path.

But if the path is a relative one, the function will wrongly concatenate
the dirname with the relative image path, i.e:

 Shell> FS0:
 FS0:\> cd EFI
 FS0:\EFI\> BOOT\BOOTX64.EFI
 Failed to open \EFI\BOOT\BOOT\BOOTX64.EFI - Not found
 Failed to load image \EFI\BOOT\BOOT\BOOTX64.EFI: Not found
 start_image() returned Not found

Calculate the image path basename and concatenate that with the dirname.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Maran Wilson maran.wilson@oracle.com
Tested-by: Maran Wilson maran.wilson@oracle.com
Upstream-commit-id: a625fa5096c
2020-07-23 20:52:12 -04:00
TanMing
c4e3516e30 Fix the compile error of mkdir wrong directory.
In Ubuntu 14.04, the following code in old Makefile:
  mkdir -p Cryptlib/{Hash,Hmac,Cipher,Rand,Pk,Pem,SysCall}
will create a directory named "{Hash,Hmac,Cipher,Rand,Pk,Pem,SysCall}".

Signed-off-by: Ming Tan <ming.tan@intel.com>
Upstream-commit-id: 39b83455d68
2020-07-23 20:52:12 -04:00
Peter Jones
bd97e72f04 Add GRUB's PCR Usage to README.tpm
This didn't seem to get documented anywhere, and this is as good a place as any.
Upstream-commit-id: 4fab7281a8c
2020-07-23 20:51:49 -04:00
Paul Menzel
956717e2b3 shim: Extend invalid reloc size warning message
Knowing the value of the reloc directory size is helpful for debugging,
cf. issue #131 [1],

[1]: https://github.com/rhboot/shim/issues/131

Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
Upstream-commit-id: dd3230d07f3
2020-07-23 20:51:18 -04:00
Gary Lin
85c837d67f MokManager: Stop using EFI_VARIABLE_APPEND_WRITE
When writing MokList with EFI_VARIABLE_APPEND_WRITE, some HP laptops
may just return EFI_SUCCESS without writing the content into the flash,
so we have no way to detect if MokList is updated or not. Now we always
read MokList first and write it back with the new content.

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

Signed-off-by: Gary Lin <glin@suse.com>
Upstream-commit-id: f442c8424b4
2020-07-23 20:51:18 -04:00
Gary Lin
409b59af29 Fix typo in debug path in shim.h
Signed-off-by: Gary Lin <glin@suse.com>
Upstream-commit-id: a98c20bbdbb
2020-07-23 20:51:18 -04:00
Gary Lin
c2f645c7cd httpboot: show the error message for the ChildHandle
Signed-off-by: Gary Lin <glin@suse.com>
Upstream-commit-id: 0fd3c7e8518
2020-07-23 20:51:18 -04:00
Gary Lin
80e52895f2 httpboot: allow the IPv4 gateway to be empty
The gateway is not mandatory.

Signed-off-by: Gary Lin <glin@suse.com>
Upstream-commit-id: 69089e9c678
2020-07-23 20:51:18 -04:00
Gary Lin
0ba6c87bdf httpboot: print more messages when it fails to set IP
We previously only print the return status and it may not be clear
enough in some situations. Print the IP address and the gateway to help
the user to identify the possible errors.

Signed-off-by: Gary Lin <glin@suse.com>
Upstream-commit-id: 3abe94516c7
2020-07-23 20:51:18 -04:00
Gary Lin
8a66f5571b httpboot: return EFI_NOT_FOUND when it fails to find the NIC handle
httpboot_fetch_buffer() should return EFI_NOT_FOUND to reflect the error
status when get_nic_handle() returns NULL.

Signed-off-by: Gary Lin <glin@suse.com>
Upstream-commit-id: 2be5c7dc4b0
2020-07-23 20:51:18 -04:00
Mathieu Trudel-Lapierre
7471867794 Let MokManager follow a MokTimeout var for timeout length for the prompt
This timeout can have the values [-1,0..0x7fff]; where -1 means "no timeout",
with MokManager going directly to the menu, and is capped to 0x7fff to avoid
unecessary long timeouts. The default remains 10, which will be used whenever
the MokTimeout variable isn't set.

Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
Upstream-commit-id: 93708c11083
2020-07-23 20:51:18 -04:00
Peter Jones
32f7122538 Makefiles: ensure -m32 gets propogated to our gcc parameter queries
'gcc -print-file-name=include' and 'gcc -print-libgcc-file-name' both
need -m32 when we're building 32-on-64 on some distros, so ensure that
gets propogated correctly.

Signed-off-by: Peter Jones <pjones@redhat.com>
Upstream-commit-id: 104d6e54ac7
2020-07-23 20:51:18 -04:00
Peter Jones
1d50318f44 Make some things dprint() instead of console_print()
Signed-off-by: Peter Jones <pjones@redhat.com>
Upstream-commit-id: dad59f8c0f36
2020-07-23 20:51:12 -04:00
Steve McIntyre
379f0954e0 Prepare 15+1533136590.3beb971-10 upload 2020-07-24 01:34:03 +01:00
Steve McIntyre
07cb34b4c3 Minimal-change upload to pick up rotated Debian signing keys 2020-07-24 01:32:38 +01:00
Steve McIntyre
8d7a0a5ce1 Use sort and uniq - minimise the size of the list here
We may end up with duplicates, let's not include hashes twice in the
shim binary blacklist
2020-07-24 01:28:51 +01:00
Steve McIntyre
c161c40d1e Typo fix 2020-07-24 01:28:51 +01:00
Mario Limonciello
eff62a79f3 Merge branch 'lintian-fixes' into 'master'
Fix some issues reported by lintian

See merge request efi-team/shim!5
2020-06-12 18:45:50 +00:00
Debian Janitor
434300fcc7
Update standards version to 4.4.1, no changes needed.
Fixes: lintian: out-of-date-standards-version
See-also: https://lintian.debian.org/tags/out-of-date-standards-version.html
2020-04-01 06:41:16 +00:00
Debian Janitor
90f64daec9
Set upstream metadata fields: Bug-Database, Bug-Submit.
Fixes: lintian: upstream-metadata-file-is-missing
See-also: https://lintian.debian.org/tags/upstream-metadata-file-is-missing.html
2020-04-01 06:40:47 +00:00
Debian Janitor
7d69650c4c
Set debhelper-compat version in Build-Depends.
Fixes: lintian: uses-debhelper-compat-file
See-also: https://lintian.debian.org/tags/uses-debhelper-compat-file.html
2020-04-01 06:40:13 +00:00
Debian Janitor
6ce7b6e059
Bump debhelper from old 11 to 12.
Fixes: lintian: package-uses-old-debhelper-compat-version
See-also: https://lintian.debian.org/tags/package-uses-old-debhelper-compat-version.html
2020-04-01 06:39:44 +00:00
Debian Janitor
e1df2a1d87
debian/copyright: use spaces rather than tabs to start continuation lines.
Fixes: lintian: tab-in-license-text
See-also: https://lintian.debian.org/tags/tab-in-license-text.html
2020-04-01 06:39:14 +00:00
Debian Janitor
1a8bb34c7e
Use secure copyright file specification URI.
Fixes: lintian: insecure-copyright-format-uri
See-also: https://lintian.debian.org/tags/insecure-copyright-format-uri.html
2020-04-01 06:38:44 +00:00
Debian Janitor
69a55e2416
Trim trailing whitespace.
Fixes: lintian: file-contains-trailing-whitespace
See-also: https://lintian.debian.org/tags/file-contains-trailing-whitespace.html
2020-04-01 06:38:15 +00:00
Steve McIntyre
a7788a2134 Tweak the version dependency of the -helpers-ARCH-signed packages
Change the version dependency on shim-unsigned to be >= and not =.
This will allow for installation to still work in the window while we
wait for the template package to do its second trip through the
archive. Closes: #955356
2020-03-30 15:22:35 +01:00
Steve McIntyre
c90bfe2dfd Ignore debian/files 2020-03-30 15:05:57 +01:00
Steve McIntyre
8e0de2bdaf Prepare Debian release 15+1533136590.3beb971-8 2020-03-24 17:49:45 +00:00
Steve McIntyre
f320bcacd5 Update debhelper compat level to 11 2020-03-24 17:47:56 +00:00
Steve McIntyre
10b051f346 Switch to using gcc-9 for builds. Closes: #925826
Pull upstream commit aaa09b35e73c4a35fc119d225e5241199d7cf5aa to fix
an FTBFS.
2020-03-24 17:38:57 +00:00
Steve McIntyre
3a1cdbfd4c Use --padding when calling pesign to generate hashes
for the dbx list, as recommended by Peter Jones. No actual changes
needed in our list of hashes at this point - they work out the same
either way.
2019-05-08 16:49:11 +01:00
Steve McIntyre
ee2d7bb94f Prepare Debian release 15+1533136590.3beb971-7 2019-05-08 02:06:02 +01:00
Steve McIntyre
ea8f00b9bf Remove the hash for Sledge's test arm64 grub binary
Not needed now.
2019-05-08 02:03:37 +01:00
Steve McIntyre
28e8f71ef2 Add an empty list of hashes for the Ubuntu build
so they'll get an empty dbs list rather than breaking the build
2019-05-07 11:05:48 +01:00
dann frazier
81dc204854 Output efisiglist commands to the build log
It wouldn't hurt to keep a record of them.
2019-05-06 13:56:20 -06:00
dann frazier
a42739719f Require dbx hashes
While it maybe convenient for a developer to be able to do a build
w/o any dbx hashes, it prevents the $(DBX_LIST) target from having
a proper dependency on the $(DBX_HASHES) file. If a developer were
to add a new hash in a built tree, make would not detect that on
a subsequent build and would not update the $(DBX_LIST) file.

Continue to support a NULL $(DBX_LIST) build by touching the
$(DBX_LIST) file in case no efisiglist commands ran. Developers
can now create an empty $(DBX_HASHES) file to get that.
2019-05-06 13:50:24 -06:00
dann frazier
99990d2175 Use $@ instead of referencing ${DBX_LIST} in multiple places 2019-05-06 13:33:20 -06:00
dann frazier
cdceb0fb38 'set -e' the code that generates the dbx list
Without this we would silently ignore an efisiglist command error.
2019-05-06 13:30:17 -06:00