summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2017-02-27Fix some type errors gcc7 finds in http boot code.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-02-23Make shim_version live in a special aligned section.Peter Jones
This makes it so two builds of the same .deb on different hosts won't have wildly different file offsets. Signed-off-by: Peter Jones <pjones@redhat.com>
2017-02-06Also just check for access denied anyway.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-02-06Ensure all of the SB verification returns the same error code.Peter Jones
Previously we were returning EFI_ACCESS_DENIED at some places and EFI_SECURITY_VIOLATION at others. When we're checking whether to run MokManager, we're checking EFI_SECURITY_VIOLATION, which is more or less analogous with what the spec says StartImage() returns. So we should always have that as the return code. I believe this will fix github issue #44. Signed-off-by: Peter Jones <pjones@redhat.com>
2017-02-06shim/tpm: the EFI_TCG2_BOOT_SERVICE_CAPABILITY structure shouldn't be packedLans Zhang
According to TCG EFI Protocol Specification, this structure is not packed. Signed-off-by: Lans Zhang <jia.zhang@windriver.com>
2017-02-06shim/tpm: correct the definition of the capability structure version 1.0Lans Zhang
EFI TrEE Protocol uses the same protocol GUID as EFI TCG2 protocol, and defines the capability structure version 1.0. Hence, the structure and name are all align the EFI TrEE Protocol. Signed-off-by: Lans Zhang <jia.zhang@windriver.com>
2017-02-06shim: fix the mirroring MokSBState failIvan Hu
Some machines have already embedded MokSBStateRT varaible with EFI_VARIABLE_NON_VOLATILE attribute, and some users might disable shim vailidation manually by creating MokSBStateRT. It causes mirroring MokSBState fail because the variable cannot be set with different attribute again, and gets error massage every time when booting. Fix it with checking the MokSBStateRT existence and deleting it before mirroring it. Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
2017-02-06generate_hash(): make check_size() set an error, and verify SecDir size.Peter Jones
Currently generate_hash() attempts to include any trailing data at the end of the binary in the resulting digest, but it won't include such data if the size computed is wrong because context->SecDir->Size is invalid. In this case the return code is EFI_SUCCESS, and the hash will match any a binary as if the Attribute Certificate Table and anything after it are missing. This is wrong. Signed-off-by: Peter Jones <pjones@redhat.com>
2016-11-30Update the CryptLibGary Lin
Update to the edk2 commit dab62c5ec8a88def3ee99c04d644720cb201de08 Signed-off-by: Gary Lin <glin@suse.com>
2016-11-30Update to openssl 1.0.2jGary Lin
Signed-off-by: Gary Lin <glin@suse.com>
2016-11-30Update the openssl update script to 1.0.2jGary Lin
Signed-off-by: Gary Lin <glin@suse.com>
2016-11-30Cryptlib: Implement memset() to avoid the potential crashGary Lin
Although the prototype of memset() is already defined in OpenSslSupport.h, the function was never implemented. It was fine since a macro was designed to replace all memset() with SetMem() after including OpenSslSupport.h. However, since openssl 1.0.2j, a new function pointer in crypto/mem_clr.c requires the "real" memset() or the program would crash due to the NULL function pointer access. This commit implements memset() (just a wrapper of SetMem()) to avoid the potential crash. Signed-off-by: Gary Lin <glin@suse.com>
2016-11-30shim/tpm: fix trigger failure caused by NULL argumentsLans Zhang
Certain AMI BIOS (Intel NUC5i3MYBE BIOS version 0037) may make the strict check on the last 3 arguments passed to get_event_log() and don't expect NULL pointers are passed. In order to work around this failure (EFI_INVALID_PARAMETER), pass them even though we really don't use it. Signed-off-by: Lans Zhang <jia.zhang@windriver.com>
2016-11-30shim/tpm: print the error status if trigger failsLans Zhang
Signed-off-by: Lans Zhang <jia.zhang@windriver.com>
2016-09-30shim: trigger to record further logs to tcg 2.0 final event log areaLans Zhang
According to TCG EFI Protocol Specification for TPM 2.0 family, all events generated after the invocation of EFI_TCG2_GET_EVENT_LOG shall be stored in an instance of an EFI_CONFIGURATION_TABLE aka EFI TCG 2.0 final events table. Hence, it is necessary to trigger the internal switch through calling get_event_log() in order to allow to retrieve the logs from OS runtime. Signed-off-by: Lans Zhang <jia.zhang@windriver.com>
2016-09-21shim: verify Extended Key Usage flagsMathieu Trudel-Lapierre
For starters; don't allow the "module signing" OID; which ought to only ever be used for signing kernel modules, not signing EFI binaries. Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
2016-09-21MokManager: list Extended Key Usage OIDsMathieu Trudel-Lapierre
Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
2016-09-09MokManager: free new_data after useGary Lin
new_data in write_db() wasn't freed after SetVariable. Signed-off-by: Gary Lin <glin@suse.com>
2016-09-09MokManager: Try APPEND_WRITE firstGary Lin
Try to append the MOK/MOKX list first and then fallback to the normal SetVariable if the firmware doesn't support EFI_VARIABLE_APPEND_WRITE. Signed-off-by: Gary Lin <glin@suse.com>
2016-09-09MokManager: Remove the usage of APPEND_WRITEGary Lin
We got the bug report about the usage of APPEND_WRITE that may cause the failure when writing a variable in Lenovo machines. Although EFI_VARIABLE_APPEND_WRITE already exists in the UEFI spec for years, unfortunately, some vendors just ignore it and never implement the attribute. This commit removes the usage of EFI_VARIABLE_APPEND_WRITE to make MokManager work on those machines. https://github.com/rhinstaller/shim/issues/55 Signed-off-by: Gary Lin <glin@suse.com>
2016-09-09Fix up a merge error in 467878f3e0.Peter Jones
In the branch I wrote the code on, "size" was a thing. On this branch it isn't. Signed-off-by: Peter Jones <pjones@redhat.com>
2016-09-09verify_buffer: check that the value of cert->Hdr.dwLength is reasonablePeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2016-09-06Minor formatting fixPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2016-09-06Use authenticode signature length from WIN_CERTIFICATE structure.Sachin Agrawal
Authenticode Certificate length is available in Certificate Table (inside PE header) and also in signature header(WIN_CERTIFICATE) itself. Code in 'check_backlist()' method uses length from signature header, whereas, AuthenticodeVerify() call inside 'verify_buffer()' method uses the length in signature header. This causes a security vulnerability issue : Good Scenario : Assume shim1.crt is used for signing grub.efi and shim1.crt is embedded inside shim.efi. Also, assume shim1.crt got compromised and therefore it was added in 'dbx' database. Now, when shim.efi will attempt to load grub.efi, it will fail loading with log message "Binary is blacklisted" because 'check_blacklist' call will detect the presence of 'shim1.crt' in 'dbx'. Vulnerable Scenario : Similar as above. Add 'shim1.crt' in dbx database. Also, tamper the earlier signed grub.efi file by placing 0x0000 in the WIN_CERTIFICATE.dwLength. (Open grub.efi/vmlinuz signed binary with hex editor. Go to 0x128 address and read out the address from 0x128 until 0x12B in little Indian order from right to left. Jump to the address from 0x128 address area. First 8bytes are the signature header area which consist of signature size(4bytes), revision(2bytes) and type(2bytes). So tamper the first 4 bytes for signature size and save the binary. ) With this tampered grub.efi, shim.efi loads it successfully because 'check_blacklist()' call fails to detect the presence of shim1.crt in 'dbx' database. Signed-off-by: Sachin Agrawal <sachin.agrawal@intel.com>
2016-09-06Update the CryptLibGary Lin
Update to the edk2 commit 8ff7187cfd998d2b6db43075a4a7908281b6da00 Signed-off-by: Gary Lin <glin@suse.com>
2016-09-06Update to openssl 1.0.2hGary Lin
Signed-off-by: Gary Lin <glin@suse.com>
2016-09-06Update the openssl update script to 1.0.2hGary Lin
Signed-off-by: Gary Lin <glin@suse.com>
2016-09-06Update openssl to 1.0.2gGary Lin
Signed-off-by: Gary Lin <glin@suse.com>
2016-09-06Update the CryptLibGary Lin
Update to the edk2 commit 5e2318dd37a51948aaf845c7d920b11f47cdcfe6 Signed-off-by: Gary Lin <glin@suse.com>
2016-09-06Update the openssl b_print patchGary Lin
Signed-off-by: Gary Lin <glin@suse.com>
2016-09-06Amend the CryptLib update scripts for openssl 1.0.2gGary Lin
Also update the path to the openssl headers. Signed-off-by: Gary Lin <glin@suse.com>
2016-09-06Update to openssl to 1.0.2eGary Lin
Also update Cryptlib to edk2 r19218 - Undefine NO_BUILTIN_VA_FUNCS in Cryptlib/OpenSSL/ for x86_64 to use the gcc builtins and remove all EFIAPI from the functions - Move the most of defines into the headers instead of Makefile - Remove the global variable 'timeval' - Remove the unused code: crypto/pqueue/* and crypto/ts/* - Include bn.h in MokManager.c due to the changes in openssl Signed-off-by: Gary Lin <glin@suse.com>
2016-09-06Don't close file twice in should_use_fallback error pathBenjamin Antin
When fallback.efi is not present, the should_use_fallback error path attempts to close a file that has already been closed, resulting in a hang. This issue only affects certain systems. This is a regression from version 0.8 and was introduced by commit 4794822. Signed-off-by: Benjamin Antin <ben.antin@endlessm.com>
2016-09-06shim: remove unused variableGary Lin
Fix the compilation error from gcc: shim.c: In function ‘handle_image’: shim.c:1121:15: error: unused variable ‘size’ [-Werror=unused-variable] unsigned int size; ^~~~ Signed-off-by: Gary Lin <glin@suse.com>
2016-09-06fix: filter objcopy versionMorris
see comments here: https://github.com/rhinstaller/shim/commit/d9a4c912c0aa72905ca793b555dcb0afb33e3b30
2016-09-06Fix the size of MokDBStateLans Zhang
MokDBState is a 8-bit unsigned integer. Looks like a typo here. Signed-off-by: Lans Zhang <jia.zhang@windriver.com>
2016-09-06Add the optional HTTPBoot supportGary Ching-Pang Lin
This commit adds the basic support for HTTPBoot, i.e. to fetch the next stage loader with the HTTP protocol. It requires gnu-efi >= 3.0.3 to support the URI device path and Ip4Config2 or Ip6Config protocol support in the UEFI implementation. To build shim.efi with HTTPBoot support: make ENABLE_HTTPBOOT=1 shim.efi Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2016-09-06Add HTTP and IpConfig headersGary Ching-Pang Lin
Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2016-09-06Make translate_slashes() publicGary Ching-Pang Lin
Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2016-09-06read_header/handle_image: treat uninitialized file alignment as PAGE_SIZEPeter Jones
2016-09-06Improve BOOT${ARCH}.CSV support.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2016-09-06Make LIB_PATH and EFI_PATH per-arch.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2016-09-06Add some more documentation for how to use fallback.efiPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2016-09-06Make fallback and mokmanager know about multi-arch.Peter Jones
On baytrail, we've got 32-bit firmware, 32-bit efi utilities, and 64-bit kernel. So since most distros will want 32+64 EFI media booting a 64-bit kernel, we have to name them better on the filesystem. Signed-off-by: Peter Jones <pjones@redhat.com>
2016-06-09shim: make the PE loader less overzealous on rejectionsPeter Jones
2016-05-18Work around binutils version string weirdness.Peter Jones
Nick Clifton wrote to me and explained: Subject: SHIM - objcopy version check broken by RHEL 7.3 binutils Hi Peter, We (the tools group) have run across a small problem with the shim package for RHEL 7.3, whilst testing out a new version of the binutils. It complains that it needs a version of objcopy that is >= 2.23, despite the fact that the version is actually 2.25.1. I tracked the problem down to an extraneous space at the end of the version string being produced by objcopy: "GNU objcopy version 2.25.1-8.el7 " The Makefile in the shim package uses this rule to test the version of objcopy: OBJCOPY_GTE224 = $(shell expr `$(OBJCOPY) --version |grep ^"GNU objcopy" | sed 's/^.* //g' | cut -f1-2 -d.` \>= 2.24) But, because of that extra space, the sed expression clips the entire line and so the test fails. The extra space is there because normally the version number would be followed by a date. For example: "GNU objcopy version 2.23.52.0.1-56.el7 20130226" So in this case the sed will extract the date, not the version number, but the test will still pass. I could fix the binutils to remove the space, although it would be a bit messy and it would not fix the problem when a date is appended to the version number. Instead, I would like to propose a small patch to the shim Makefile. If you change the line to: OBJCOPY_GTE224 = $(shell expr `$(OBJCOPY) --version |grep ^"GNU objcopy" | sed 's/^.version //g' | cut -f1-2 -d.` \>= 2.24) then the test will work as intended, with or without an extra space at the end of the version and with or without a date appended. Would it be possible to have this change added to the shim package ? Cheers Signed-off-by: Peter Jones <pjones@redhat.com>
2016-05-11Measure state and second stage into TPMMatthew Garrett
Add support for measuring the MOK database and secure boot state into a TPM, and do the same for the second stage loader. This avoids a hole in TPM measurement between the firmware and the second stage loader.
2016-05-11shim: dealing with only one string on loadoptionIvan Hu
The second stage set is not working after commit 3322257e611e2000f79726d295bb4845bbe449e7 for those which load option only have one string. Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
2016-03-22shim: mirror MokSBState in runtime so the kernel can make use of it.Mathieu Trudel-Lapierre
Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
2015-11-17Don't test for the 0 character on the wrong half of the UCS2-LE char.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>