summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2018-04-05Fix get_variable() usage in setup_verbosity()Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-04-05Make setup_console(-1) do GetMode() and call it from setup_verbosity()Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-13console: Fix indentationHans de Goede
The manual merge of the "console: Do not set EFI console to textmode until something is printed" patch has lead to a bunch of tabs being replaced with 7 spaces. This commit fixes this. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-03-12console: Do not set EFI console to textmode until something is printedHans de Goede
Remove the setup_console(1) calls from shim and instead make lib/console.c make that call when necessary. This avoids shim forcing the EFI console to switch to text-mode if nothing is printed. This commit also modifies MokManager to work the same way for consistency, even though MokManager will always print something. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-03-12console: Move setup_console() definition to higher in the fileHans de Goede
This is a preparation patch for making setup_console() private. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-03-12console: Add console_print and console_print_at helpersHans de Goede
This is a preparation commit for removing the setup_console(1) calls from MokManager and shim so that we don't force the EFI console to switch to text-mode. This commit replaces all direct calls to Print / PrintAt with calls to the new helpers (no functional changes) so that we can delay calling setup_console(1) till the first Print call in a follow-up patch. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-03-12Don't use uefi_call_wrapper(), ever.Peter Jones
I'm pretty done with typing uefi_call_wrapper() and counting arguments every time. Instead, just make the compiler error if we don't have ms_abi. Also, make it so nothing can use uefi_call_wrapper() directly. Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12lib/shell.c: minor cleanupPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12lib/simple_file.c: minor cleanupPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12lib: Use EFI_ERROR() instead of comparing to EFI_SUCCESS everywhere.Peter Jones
Also consistently name our status variable "efi_status" unless there's a good reason not to, such as already having another one of those. Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12lib: find_in_variable_esl(): Fix a tiny nitpick clang-analyze has.Peter Jones
clang-analyze believes the following: 311 EFI_STATUS 312 variable_enroll_hash(CHAR16 *var, EFI_GUID owner, 313 UINT8 hash[SHA256_DIGEST_SIZE]) 314 { 315 EFI_STATUS efi_status; 316 317 efi_status = find_in_variable_esl(var, owner, hash, SHA256_DIGEST_SIZE); > Calling 'find_in_variable_esl' → 260 EFI_STATUS 261 find_in_variable_esl(CHAR16* var, EFI_GUID owner, UINT8 *key, UINTN keylen) 262 { 263 UINTN DataSize; 264 UINT8 *Data; > ← 'Data' declared without an initial value → 265 EFI_STATUS efi_status; 266 267 efi_status = get_variable(var, &Data, &DataSize, owner); > ← Calling 'get_variable' → 237 EFI_STATUS 238 get_variable(CHAR16 *var, UINT8 **data, UINTN *len, EFI_GUID owner) 239 { 240 return get_variable_attr(var, data, len, owner, NULL); > ← Calling 'get_variable_attr' → 213 EFI_STATUS 214 get_variable_attr(CHAR16 *var, UINT8 **data, UINTN *len, EFI_GUID owner, 215 UINT32 *attributes) 216 { 217 EFI_STATUS efi_status; 218 219 *len = 0; 220 221 efi_status = GetVariable(var, &owner, NULL, len, NULL); > ← Calling 'GetVariable' → > ← Returning from 'GetVariable' → 222 if (efi_status != EFI_BUFFER_TOO_SMALL) > ← Assuming the condition is true → > ← Taking true branch → 223 return efi_status; 224 225 *data = AllocateZeroPool(*len); 226 if (!*data) 227 return EFI_OUT_OF_RESOURCES; 228 229 efi_status = GetVariable(var, &owner, attributes, len, *data); 230 if (EFI_ERROR(efi_status)) { 231 FreePool(*data); 232 *data = NULL; 233 } 234 return efi_status; 235 } And it can't figure out that the first GetVariable() call will, in fact, always return EFI_BUFFER_TOO_SMALL, and that AllocateZeroPool() will then *correctly* clobber the two variables we never assigned the value from. It also then believes that efi_status might have been returned /without/ being an error, and thinks that means we'll use the uninitialized pointer. This won't happen, but hey, let's make the code better express to the checker what is intended. Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12lib: simple_file_selector(): remove some dead code.Peter Jones
clang-analyzer correctly believes this: 465 int i; 466 467 i = StrLen(name) - 1; ^ Value stored to 'i' is never read 468 469 for (i = StrLen(name); i > 0; --i) { 470 if (name[i] == '\\') 471 break; 472 } And it's right; that's completely dead code. Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12lib: simple_file_selector(): simplify the error path to confuse covscan less.Peter Jones
Because they don't believe code should be defensive against future changes, covscan believes: 520 out_free: 521 FreePool(dmp); CID 182824 (#1 of 1): Dereference before null check (REVERSE_INULL)check_after_deref: Null-checking entries suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 522 if (entries) { 523 free_entries(entries, count); 524 FreePool(entries); 525 } 526 out_free_name: 527 FreePool(name); 528} Which is technically correct, but still kind of dumb. So this patch combines the two error out paths into just being out_free, so that the first path there is before entries is allocated. (It also initializes dmp to NULL and checks that before freeing it.) I also Lindent-ed that function. Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12Use gcc's offsetof() instead of hacking out our own.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12Get rid of all the places we cast to (CHAR16 *[])Peter Jones
Lindent gets confused by these, and they're hard to read anyway. Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12Fix some "if (x < 0)" tests where x is UINTN.Peter Jones
Obviously, these are not correct. Most of them are just useless; one can be changed to a more useful test. Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12Don't have tons of local guid definitions for no reason at all.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12lib/variables.c: reformat CreateTimeBasedPayload()Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12Move includes around to clean the source tree up a bit.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-12-19"in_protocol" is used in more than shim.o; make it not static.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-08-31Add a mechanism to print openssl errorsPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-08-31Make msleep() be a thingPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-07-24Make it possible to build in a subdirectory.Peter Jones
This lets you do: mkdir build-x64 build-ia32 cd build-x64 make TOPDIR=.. -f ../Makefile cd ../build-ia32 setarch i686 -B make ARCH=ia32 TOPDIR=.. -f ../Makefile And not worry about generated sources and headers mixing and matching. Signed-off-by: Peter Jones <pjones@redhat.com>
2017-06-15become more friendly for the cross compilationLans Zhang
Allow to overwrite certain settings from the external. Signed-off-by: Lans Zhang <jia.zhang@windriver.com>
2017-06-15fix compilerer errors in security policyMax Resch
When compiling with -Werror security policy can't be compiled because of type errors. This commit fixes this problem.
2015-06-29More incorrect unsigned vs signed fixups from yours truly.Peter Jones
Woops. Signed-off-by: Peter Jones <pjones@redhat.com>
2015-06-16Fix console_print_box*() parameters.Peter Jones
When we made lib build with the correct CFLAGS, it inherited -Werror=sign-compare, and I fixed up some parameters on console_print_box() and console_print_box_at() to avoid sign comparison errors. The fixups were *completely wrong*, as some behavior relies on negative values. So this fixes them in a completely different way, by casting appropriately to signed types where we're doing comparisons. Signed-off-by: Peter Jones <pjones@redhat.com>
2015-04-13Make lib/ use the right CFLAGS.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2015-04-13Make lib/ build right with the cflags it should be using...Peter Jones
... but isn't. Signed-off-by: Peter Jones <pjones@redhat.com>
2014-12-11Add nostdinc to the CFLAGS for libGary Ching-Pang Lin
We don't need the headers from the standard include path. Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2014-08-12Factor out x86-isms and add cross compile supportArd Biesheuvel
This patch cleans up and refactors the Makefiles to better allow new architectures to be added: - remove unused Makefile definitions - import Makefile definitions from top level rather than redefining - move x86 specific CFLAGS to inside ifeq() blocks - remove x86 inline asm - allow $(FORMAT) to be overridden: this is necessary as there exists no EFI or PE/COFF aware objcopy for ARM Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
2014-06-25Make sure we default to assuming we're locked down.Peter Jones
If "SecureBoot" exists but "SetupMode" does not, assume "SetupMode" says we're not in Setup Mode. Signed-off-by: Peter Jones <pjones@redhat.com>
2014-06-25Check the secure variables with the lib functionsGary Ching-Pang Lin
There are functions defined in lib to check the secure variables. Use the functions to shun the duplicate code. Signed-off-by: Gary Ching-Pang Lin <glin@suse.com> Conflicts: shim.c
2014-06-25Remove the duplicate calls in lib/console.cGary Ching-Pang Lin
Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2014-06-25MokManager: handle the error status from ReadKeyStrokeGary Ching-Pang Lin
On some machines, even though the key event was signaled, ReadKeyStroke still got EFI_NOT_READY. This commit handles the error status to avoid console_get_keystroke from returning unexpected keys. Signed-off-by: Gary Ching-Pang Lin <glin@suse.com> Conflicts: MokManager.c
2013-11-21Error check the right thing in get_variable_attr() when allocating.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-11-21Initialize entries before we pass it to another function.Peter Jones
Coverity scan noticed that entries is uninitialized when we pass its location to another function. Signed-off-by: Peter Jones <pjones@redhat.com>
2013-11-21Fix wrong sizeof().Peter Jones
CHAR16* vs CHAR16**, so the result is the same on all platforms. Detected by coverity. Signed-off-by: Peter Jones <pjones@redhat.com>
2013-11-12allow 32-bit compilation with 64-bit compilerAndrew Boie
Also removed unused LIB_PATH from some Makefiles. Change-Id: I7d28d18f7531b51b6121a2ffb88bcaedec57c467 Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2013-10-04Put SHIM_VERBOSE under shim's guid, not global.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-04Try to actually make debug printing look reasonable.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-03Add ident-like blobs to shim.efi for version checking.Peter Jones
I feel dirty.
2013-10-02CompareMem expects void * and gcc complains.Peter Jones
Sorry about that. Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-01Clean up warnings.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-01Conditionalize overriding the security policy.Peter Jones
Make OVERRIDE_SECURITY_POLICY a build option. Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-01Merge console_control.h and console.hPeter Jones
Since these are topically the same thing, they can live together. Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-01Make verbose stuff use console_notifyPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-09-26integrate security overrideGary Ching-Pang Lin
2013-09-26Merge variable retrieving functionsGary Ching-Pang Lin
2013-09-26Merge signature.h into efiauthenticated.h and guid.hGary Ching-Pang Lin
Conflicts: shim.c