Commit Graph

269 Commits

Author SHA1 Message Date
Mario Limonciello
d5d496b62a trivial: uefi: fix dell TPM updates
Adding an extra header makes the firmware reject the GUID in the real
header.
2020-05-29 07:31:15 -05:00
Mario Limonciello
d39bcee29d trivial: detect cpuid.h and also look for host architecture
Fixes cross compilation for arm with clang which provides cpuid.h
but helpfully has this error:
```
 #if !(__x86_64__ || __i386__)
 #error this header is for x86 only
 #endif
```

Fixes: #2131
2020-05-26 15:06:08 -05:00
Richard Hughes
e3091c394b trivial: Move the SecureBoot attr to a runtime issue 2020-05-22 15:15:09 +01:00
Richard Hughes
b246bcaecb Allow client tools to translate the HSI attributes and results
To do this, rely on the AppStream ID to map to a translated string (providing a
fallback for clients that do not care) and switch the free-form result string
into a set of enumerated values that can be translated.

This fixes some of the problems where some things have to be enabled to "pass"
and other attributes have to be some other state. For cases where we want the
user to "do" something, provide a URL to a wiki page that we update out-of-band
of fwupd releases.
2020-05-18 17:03:49 +01:00
Richard Hughes
cae111d1de Save the plugin that created the FwupdSecurityAttr
This is really useful for debugging.
2020-05-15 16:17:27 +01:00
Richard Hughes
c1eda7d516 Add many new plugins to support for the Host Security ID
The HSI specification is currently incomplete and in active development.

Sample output for my Lenovo P50 Laptop:

    Host Security ID: HSI:2+UA!

    HSI-1
    ✔  UEFI dbx: OK
    ✔  TPM: v2.0
    ✔  SPI: Write disabled
    ✔  SPI: Lock enabled
    ✔  SPI: SMM required
    ✔  UEFI Secure Boot: Enabled

    HSI-2
    ✔  TPM Reconstruction: Matched PCR0 reading

    HSI-3
    ✘  Linux Kernel S3 Sleep: Deep sleep available

    HSI-4
    ✘  Intel CET: Unavailable

    Runtime Suffix -U
    ✔  Firmware Updates: Newest release is 8 months old

    Runtime Suffix -A
    ✔  Firmware Attestation: OK

    Runtime Suffix -!
    ✔  fwupd plugins: OK
    ✔  Linux Kernel: OK
    ✔  Linux Kernel: Locked down
    ✘  Linux Swap: Not encrypted
2020-05-12 21:20:18 +01:00
Richard Hughes
0258c12af3 uefi: Manually call fu_device_setup() during coldplug
This forces the daemon to convert the main-system-firmware instance ID to a
GUID, which allows us to find it using fu_device_list_get_by_guid()
2020-05-01 19:26:52 +01:00
Richard Hughes
0d4e2ca4c5 Make tss2-esys conditional
This is not provided in RHEL 8 in the default build root.
2020-04-22 09:36:14 +01:00
Sam Morris
6a161aa1d1 uefi: correctly format firmware version of Dynabook (né Toshiba) X30, X40 and probably others
Fixes #1998
2020-04-15 13:00:26 +01:00
Mario Limonciello
7b866e5f92 uefi: Don't use shim for non-secure boot configurations
Since the entry is dynamically created this removes one area that
can potentially cause failures.
Helps: #1794
2020-03-16 06:55:05 -05:00
Mario Limonciello
6a0f25f649 trivial: uefi: restore uefi.quirk
It was a casualty in 6f8a3da8f0
2020-03-06 12:10:15 +00:00
Richard Hughes
a32034b844 Drop UEFI quirks we now inherit from metadata
Fixes https://github.com/fwupd/fwupd/issues/1843
2020-03-06 12:10:15 +00:00
Mario Limonciello
b87d48a042 When TPM PCR0 measurements fail, query if secure boot is available and enabled
If the measurements are missing but it's a UEFI system, it's a good indication
that the user has secure boot turned off.
Notify the user on the UEFI device through a non-fatal `UpdateMessage`

To accomplish this, move fu-uefi-vars into the plugin library for other plugins to use
2020-03-05 07:54:15 -06:00
Mario Limonciello
be1a555737 trivial: uefi: set vendor ID on dummy device 2020-03-05 07:54:15 -06:00
Richard Hughes
b097603800 Allow server metadata to set the version format on some devices
It appears just choosing 'if Dell then QUAD else TRIPLET' isn't good enough.
2020-02-26 15:45:40 +00:00
Richard Hughes
f50ff2c27e Decouple the version format from the version itself
If we say that the version format should be the same for the `version_lowest`
and the `version_bootloader` then it does not always make sense to set it at
the same time.

Moving the `version_format` to a standalone first-class property also means it
can be typically be set in the custom device `_init()` function, which means we
don't need to worry about *changing* ther version format as set by the USB and
UDev superclass helpers.
2020-02-25 14:00:09 +00:00
Mario Limonciello
c1776c9ad4 Add raw versions for bootloader and lowest
The assumption is that same version format is used for all 3 of these
versions.
2020-02-25 12:20:51 +00:00
Richard Hughes
f43381f4a7 Allow server metadata to set the device name on some devices
This does 'bleed' the metadata contents into areas previously covered by quirks,
but in this case may be pragmatic and more up to date than a build-time
generated quirk file, which increases the user-friendliness of fwupdmgr.
2020-02-24 14:15:34 +00:00
Mario Limonciello
9ee0e63e53 trivial: add some better descriptions for man pages
Since more utilities are now in `bindir`, they should be more descriptive.
2020-02-20 09:34:10 -06:00
Mario Limonciello
21e7faa78b uefi: Move fwupdate into bindir
Intended to be executed by users for debugging purposes, create a man
page as well.
2020-02-20 09:02:11 -06:00
Richard Hughes
334ba7994c trivial: Add helper fu_plugin_get_config_value_boolean() 2020-02-20 14:55:10 +00:00
Richard Hughes
6f8a3da8f0 Generate an additional UEFI quirk file using the stable LVFS metadata
The UEFI ESRT table just gives us a table of GUIDs with some basic flags, and
isn't very useful to end users. This is acceptable for Dell as there is only
typically one ESRT entry, which is for the system firmware. On typical Lenovo
hardware there might be half-a-dozen different 'Device' entries which all look
very similar.

As it's not possible to get a channel-of-data from the ODMs to fwupd, use the
existing LVFS metadata to generate some better names for these devices.
Although this looks like a lot of repeated data, libxmlb helpfully dedupes the
strings for us, making the quirk store only slightly larger.

Also, I've deliberately made this a manual step as we're not going to have
internet access on distro builders, and I'd also like the fwupd tarball output
to be deterministic and repeatable.
2020-02-14 17:14:24 +00:00
Bhaskar Upadhaya
73461ca1b7 uefi: Apply capsule update even with single valid capsule
Currently if there is an invalid boot entry for firmware update, the fwupd
EFI program will not call UpdateCapsule(), even if there is a valid entry.

For example, if the following entries exist the firmware update will fail:

HD(1,GPT,A672BBCA-325E-4D6F-91E1-DD57FAA85A9C)/\EFI\rhel\fw\fwupdate-6cialq.cap ... /*Valid entry*/
HD(1,GPT,E8176B29-6F73-43F2-AE8E-05E09DE20EE5)/\EFI\fedora\fw\fwupd-6dcbd5ed-e82d-4c44-bda1-7194199ad92a.cap ... /*InValid entry*/

Ensure capsule update is happening even if a valid capsule entry exists.

Signed-off-by: Bhaskar Upadhaya <bupadhaya@marvell.com>
2020-02-14 15:37:08 +00:00
Richard Hughes
52cda3db9c uefi: Find the correct lds and crt name when specifying -Defi_ldsdir
This fixes the Flatpak build of fwupd.
2020-02-13 17:56:33 +00:00
Richard Hughes
d2fe61289b uefi: Fix a build regression with Fedora 30
Fixes https://github.com/fwupd/fwupd/issues/1754
2020-02-11 14:53:01 +00:00
Richard Hughes
60373e03fd uefi: Do not remove the 'Linux Firmware Updater' boot entry before update
Deleting boot entries from EFI sometimes triggers problems on some firmware.

We don't actually need to do it from the EFI binary, and it's perfectly safe to
leave it in the boot list. It also means when doing multiple updates over
several months we're not creating, deleting, creating, deleting and can just
re-use the same BootXXXX number each time.

It also makes the EFI binary simpler, which is good.
2020-02-11 13:36:08 +00:00
Richard Hughes
507f24a735 uefi: Do not rewrite BootOrder in the EFI helper
At the moment fwupd creates a BootXXXX for fwupd.efi and marks it BootNext.
It *also* adds it to the end of BootOrder to work around various old firmware
bugs like https://github.com/rhboot/fwupdate/issues/55 which we can perhaps
drop sometime thie century.

Remove the rewriting of BootOrder from the EFI binary; we've accidentally not
been doing it for a long time and nothing broke, and I'd like to make the EFI
binary as small and simple as possible. The user can remove the entry from the
BIOS or using efibootmgr if required, but it's harmless to just leave it.
2020-02-11 13:36:08 +00:00
Mario Limonciello
d5bf8e45f2 Revert "Correctly delete UEFI variables"
This reverts commit 44f55e2ee6.

This behavior caused fwupdx64.efi to loop for a very long time until
either aborting, running out of memory or some other problems.
Fixes: #1756
Fixes: #1751
2020-02-10 12:39:26 -06:00
Mario Limonciello
bcd14de89f uefi: make debugging output more readable 2020-02-10 12:39:26 -06:00
Richard Hughes
7d11d44242 Support the new gnuefi file locations
gnu-efi 3.0.11 moves a few files around, e.g.

    /usr/lib64/gnuefi/elf_x64_efi.lds -> /usr/lib64/gnuefi/x64/efi.lds

...and this causes the UEFI EFI helper to fail to link.

Add support for the 'new' paths and fall back to the old ones.

Fixes https://github.com/fwupd/fwupd/issues/1736
2020-02-05 07:41:35 -06:00
Mario Limonciello
8527405c8d Cleanup ancient fwupdate-* EFI variables too (Fixes: #1739)
It seems that fwupd.efi is picking up both fwupdate-* and fwupd-*
entries that are sitting around in efivarfs.
2020-02-04 11:36:58 -06:00
Ivan Hu
44f55e2ee6 Correctly delete UEFI variables
UEFI runtime service GetVariable with DataSize NULL, will fail and get
EFI_INVALID_PARAMETER returned. Set DataSize 0 and allocate the buffer for
getting attributes for the deleted variable.

Also, fix the real reason Boot#### was never found.
2020-01-30 16:52:41 +00:00
Richard Hughes
0cc22a5ff6 trivial: Document the use of vendor-id in each plugin 2019-12-11 18:10:44 +00:00
Richard Hughes
56700a3db8 uefi: Use the BIOS vendor as the vendor ID
This is only set for non-FMP ESRT entries.
2019-12-11 18:10:44 +00:00
Richard Hughes
f5c6e1d276 Add a new plugin that can parse the TPM event log
Some devices do not have a stable PCR0 for the same firmware version, and I'd
like to collect the TPM event log for affected machines to debug why.
2019-12-06 15:05:16 +00:00
Richard Hughes
10079e6b8c Export the raw device version to the client --verbose output
It turns out this is really useful for debugging UEFI firmware updates which
typically use the 0x-prefixed version numbers without a version format.
2019-12-02 06:51:25 +00:00
Richard Hughes
3ed2ac8315 trivial: Unexport fu_test_get_filename()
We don't actually need either of the things it provides (looking up in source
and built, and converting to an absolute path) so just replace it with
g_build_filename() instead.

This also has the advantage that it does the right thing on Windows.
2019-11-27 12:45:35 +00:00
Mario Limonciello
6b0e66354b Convert libfwupdprivate to a shared library libfwupdplugin 2019-11-27 11:32:43 +00:00
Richard Hughes
5c508de173 trivial: Allow compiling without <fnmatch.h>
This also allows us to add a Win32 implementation if required in the future.
2019-11-26 13:13:31 +00:00
Richard Hughes
56ac823af9 Set the protocol per-device not per-plugin
Some plugins have devices with more than one protocol. Logically the protocol
belongs to the device, not the plugin, and in the future we could use this to
further check firmware that's about to be deployed.

This is also not exported into libfwupd (yet?) as it's remains a debug-feature
only -- protocols are not actually required for devices to be added.
2019-11-25 18:01:54 +00:00
Mario Limonciello
6abe21efbd trivial: stop including fu-hash.h as part of fu-plugin-vfuncs.h
Explicitly include it in all "in-tree" plugins.

If headers are exported out of tree we will likely explicitly not
export this header.
2019-11-25 09:29:46 +00:00
Richard Hughes
668ee21567 trivial: Use prefixes for DATADIR in config.h for portability
DATADIR is an enumerated type in MinGW, and the other names are very generic.
2019-11-24 14:17:38 -06:00
Richard Hughes
01c0badd38 trivial: Allow compiling without getuid() 2019-11-23 17:07:53 +00:00
Richard Hughes
fdb4c4507b uefi: Just use a uint16_t for BootNext processing
This makes everything simpler, at the expense of not being able to create a
`BootFFFF` entry -- but if we get that far something has already gone very
wrong with the firmware...
2019-11-20 16:24:21 +00:00
Richard Hughes
5772e8451c uefi: Use a simpler entries set algorithm
Although slightly wasteful on memory, allocating 64kb is no big deal, and it
means we can simplify creation and reading a lot.
2019-11-20 16:24:21 +00:00
Mario Limonciello
66fcf55f9a trivial: uefi: correct a NULL pointer dereference
This could happen if the machine doesn't have `/etc/os-release`.
2019-11-18 16:22:01 -06:00
Mario Limonciello
e888b58ccd uefi: fall back to ID_LIKE when the path for ID doesn't exist (Fixes:# 1566)
Some derivative distributions re-use bootloader paths from their
upstream.  When this happens the current logic to look for the `ID`
key in `/etc/os-release` doesn't work properly.

Adjust the logic to:
1) Use `ID`
2) Test the path exists.  If so, use it.
3) If it doesn't use `ID_LIKE`.
4) Test if that path exists, if so use it.
5) If that path doesn't exist, return the key from `ID`
6) The plugin will make this path.
2019-11-18 14:55:04 -06:00
Jan Tojnar
34743c5fab uefi: Make generate_binary.sh more robust
command is a shell builtin unlike which, which might not be available.

While at it, let us also make the variables space-safe.
2019-11-18 18:43:40 +00:00
YiFei Zhu
8b044c6cb3 efi: use a wildcard section copy for final EFI generation
The GNU gold linker uses the section name `.rela.dyn` instead of
`.rela` for containing the relocation information. If this section
is not copied the EFI executable can crash.

Fixes #1530
2019-11-14 09:46:50 +00:00
Richard Hughes
f4998a7636 trivial: Fix up some NULL/FALSE confusion 2019-11-01 13:55:32 +00:00