Commit Graph

1100 Commits

Author SHA1 Message Date
Richard Hughes
ae80ba6d16 Fix SMBIOS struct parsing when there are three NULs in a row
We need to be careful detecting the end of a string section when the struct
ends with NUL NUL NUL.

Fixes https://github.com/fwupd/fwupd/issues/5509
2023-02-10 13:11:25 +00:00
Richard Hughes
7c10fb0e12 Ensure composite devices all share the same acquiesce delay
We go to great pains to set the parent to the MAX of the child delays, but we
don't actually set the children to have the new parent value.

This means if you update the child device without the parent in the transaction
we don't always wait for all the USB devices to come back -- which is what the
acquiesce delay is designed to do.

Fixes an intermittant device test for the Wacom USB tablet.
2023-02-09 13:29:59 +00:00
Richard Hughes
fa72578666 trivial: Ignore device requests when emulated 2023-02-09 09:17:16 +00:00
Richard Hughes
4edf2c5079 Use the correct range check when parsing SMBIOS
The SMBIOS specification says:

    Maximum size of SMBIOS Structure Table, pointed to by the
    Structure Table Address, in bytes. The actual size is guaranteed
    to be less or equal to the maximum size.

So, the firmware is actually allowed to return a DMI blob smaller than the
specified size.

Fixes https://github.com/fwupd/fwupd/issues/5486
2023-02-04 12:55:22 +00:00
Valentin David
5ce5080844 Allow overriding lock directory with an environment variable 2023-02-01 20:44:56 -06:00
Richard Hughes
99df74f0c2 Add API to wait for a device
This allows us to ignore all the delays when the device is emulated, with the
idea being to do dozens of device emulations in the CI tests.

Also, do not call fu_progress_sleep() when the device is emulated.
2023-02-01 09:42:08 +00:00
Richard Hughes
654dd756b7 Do not invalidate the probe for emulated devices
If the device does not replug, and we change the GUsbDevice because the phase
changed we don't want reprobe the hardware.

If we reprobe then the emulated device will request extra data compared to the
real device, which will cause emulation to fail.
2023-01-31 16:58:31 +00:00
Richard Hughes
32d6c7f8dd Use indexes when building the quirk prepared queries
This can save 250us on each query (of which we do a *lot*), and reduces the
number of queries by about half if the user is using a libxmlb version that can
convert from `_BOUND_TEXT` to `_BOUND_INDEX_TEXT`.

The more devices detected, the bigger the difference, and without this patch
fixing libxmlb would break fwupd as we'e been searching with an index, but not
actually providing one.
2023-01-30 14:47:56 +00:00
Richard Hughes
6e34a90a12 trivial: Add FuProgress to fu_context_load_hwinfo()
TIL: fu_bios_settings_setup() takes over 50ms (10%!) at startup.
2023-01-30 14:47:44 +00:00
Richard Hughes
c1ffebae48 Remove unused API for setting backend tags
It turns out we do not want to know the current phase of the device, and we can
achieve the same thing tagging the GUsbDevice manually and clearing the events
at exactly the correct time.
2023-01-30 13:32:48 +00:00
Richard Hughes
047b093904 Copy some flags from the proxy to the logical device 2023-01-30 12:00:04 +00:00
Frédéric Danis
3dcf24cae0 Propagate device tag to parent device 2023-01-26 15:37:35 +01:00
Richard Hughes
83229af12a trivial: Correctly compress zip files in FuArchive 2023-01-26 14:36:57 +00:00
Richard Hughes
f3f951d3a7 trivial: Add fu_device_has_problem() to be consistent and hide details 2023-01-26 12:35:08 +00:00
Richard Hughes
110ef12cc7 Add a device problem for 'update-in-progress'
We already had this as an inhibit, but this was not translated client-side.

We also need to propagate the problem to the bootloader device if the device
replugs during firmware update.
2023-01-26 09:01:26 +00:00
Richard Hughes
575871f505 Add fu_device_remove_backend_tag() for future use 2023-01-24 14:54:23 +00:00
Richard Hughes
90e5a58736 Do not make any of the HWIDs setup failures fatal
It's perfectly okay to have no HWIDs defined.

Should help with https://github.com/fwupd/fwupd/issues/5402
2023-01-24 12:45:36 +00:00
Richard Hughes
296fe5fb46 trivial: Add a device flag specifying it is emulated 2023-01-24 09:51:04 +00:00
Richard Hughes
a6deceda32 Allow desktop software to inhibit the system to prevent all updates
On edge hardware a process may want to disable firmware updates as it might be
a bad time to allow an upgrade.
2023-01-23 13:14:23 +00:00
Richard Hughes
fd08eaefee trivial: Fix bitwise operators in last commit 2023-01-22 08:29:20 +00:00
Richard Hughes
5d6cb83d1c Add fu_context_remove_flag() for future use 2023-01-22 07:35:48 +00:00
Richard Hughes
c647d0d0f6 Parse the DT chassis-type when parsing the FDT 2023-01-18 18:20:35 +00:00
Richard Hughes
eb30233b35 Improve FDT parsing compatibility
Newer versions of dtc agressively pack the string table, using *any* matching
suffix rather than whole strings. This is specification compliant, but breaks
if you use the offset as a hash key as a [premature] optimization.

Just use the string table as a flat block of memory rather than pre-parsing it.

This fixes reading the system FDT on new OpenBMC builds.
2023-01-18 07:59:45 +00:00
Richard Hughes
2b0f92506b Refactor the hwids functionality
This refactors the code as it was getting very confusing; before FuSmbios was
reading both SMBIOS and the kernel-provided DT -- and various things were
injecting overrides in three different place. To properly support FDT remove
one layer of indirection.

This also lets us use the compatible strings to enable plugins specifying the
flag _REQUIRE_HWID -- which means we only load the plugin if it's got a chance
of working. e.g.

    [aspeed,ast2500]
2023-01-18 07:04:44 +00:00
Richard Hughes
72f5c1e01e trivial: Make the installed-tests redfish.conf secure to avoid a warning
Also, don't attempt to change the permissions if the correct one is already
set.
2023-01-17 19:29:39 +00:00
Richard Hughes
4057edb24b trivial: Add FU_PATH_KIND_SYSFSDIR_DMI for future use 2023-01-16 20:23:28 +00:00
Richard Hughes
0efc1bebce trivial: Add fu_context_get_hwids() for future use 2023-01-16 17:49:57 +00:00
Richard Hughes
2737b05cf8 trivial: Add fu_context_get_smbios() for future use 2023-01-16 17:49:57 +00:00
Richard Hughes
0e381a8666 trivial: Store the chassis kind in the context 2023-01-16 17:49:57 +00:00
Richard Hughes
8af1943142 trivial: Add FuContextHwidFlags for future usage 2023-01-16 17:49:57 +00:00
Richard Hughes
c95355b498 trivial: Add a GError parameter to fu_context_get_smbios_string()
This matches the behaviour of fu_smbios_get_string() and was probably accidental.
2023-01-16 14:05:48 +00:00
Mario Limonciello
5a24472fb4 Respect user requested paths for ESP even if they aren't volumes
These paths may be used for bind mounts, which we can't accurately
discover. Leave a message in the logs accordingly, but allow these
paths.

fixes: #5185
2023-01-11 16:26:07 +00:00
Richard Hughes
cf4f34572b Add fu_context_get_fdt() to get the Flat Device Tree
This is needed because multiple plugins will soon be consuming the system FDT,
and we don't want to either parse this multiple times, or duplicate the loading
logic.
2023-01-11 16:25:26 +00:00
Richard Hughes
37a0124b62 trivial: Create the parent directories when using fu_firmware_write_file() 2023-01-11 16:25:26 +00:00
Mario Limonciello
c2a494e871 trivial: install dmi data into installed-tests
fixes: #5402
2023-01-11 07:45:58 -06:00
Richard Hughes
91bf84f7a0 trivial: Reduce runtime RSS requirement for each device subclass
Remove the FuDeviceClass padding, as this library now loaded using an rpath
rather than a shared library with a static API. This matches what we did for
the FuFirmwareClass objects a while ago.
2023-01-10 20:43:31 +00:00
Richard Hughes
9f3a54488e trivial: Set the backend ID when added
This matches what the plugin does and means there's no critical warning when
adding to the hash table.
2023-01-10 20:34:52 +00:00
Richard Hughes
1ca3cdd4d9 Add a pefile firmware parser
This will eventually allow us to reconstruct a SBoM using a UEFI file volume.

This can be used like this `fwupdtool firmware-parse efi/fwupdx64.efi pefile`
to produce:

    <firmware gtype="FuPefileFirmware">
      <data size="0xef59">MZ.</data>
      <firmware>
        <id>.text</id>
        <offset>0x2d0</offset>
        <size>0x7bab</size>
        <data size="0x7bab">H...QRH.=....H.5</data>
      </firmware>
      ...
      <firmware gtype="FuCoswidFirmware">
        <id>fwupd-efi:fwupdx64</id>
        <idx>0x7</idx>
        <version>1.4</version>
        <offset>0xc4e0</offset>
        <size>0xce</size>
        <data size="0xce">..een-US</data>
        <version_scheme>semver</version_scheme>
        <product>fwupdx64</product>
        <summary>EFI helpers to install system firmware</summary>
        <colloquial_version>1.3-7-g881a508</colloquial_version>
        <link>
          <href>https://spdx.org/licenses/LGPL-2.0.html</href>
          <rel>license</rel>
        </link>
        <entity>
          <name>Richard Hughes</name>
          <regid>hughsie.com</regid>
          <role>maintainer</role>
          <role>tag-creator</role>
        </entity>
      </firmware>
    </firmware>
2023-01-06 17:32:59 +00:00
Richard Hughes
10e8f0559b Always search for uSWID data in the image 2023-01-06 14:23:13 +00:00
Richard Hughes
e73f7d019c Do not allow LZX compressed cabinet archives
The GCab decompression code is *scary* low level C that has not had any security
auditing other than by the fuzzer (which found plenty of memory-safety bugs).

Supporting LZX is useless at best, and could be a security exploit at worst.
2023-01-04 16:06:00 +00:00
Josh Soref
67deecde31
Lots of spelling fixes
Fixes:

* activate
* active
* additional
* and
* approaches
* attestation
* bootloader
* calculate
* capability
* children
* close
* compatible
* continuous
* convenience
* critical
* data
* delivery
* disabled
* disambiguate
* documented
* elapse
* emergency
* erasable
* expectations
* filesystem
* from
* haptic
* ignorable
* images
* infinity
* information
* information
* inhibited
* insufficient
* interrupt
* into
* limited
* management
* manifest
* maximum
* memory
* metadata
* mismatch
* model
* nonexistent
* not
* objects
* offset
* omissions
* ota
* past
* perform
* peripherals
* predictable
* product
* quarterly
* quirk
* quirks
* recognize
* release
* requests
* revocation
* sanitized
* sector
* status
* the
* the update
* timeout
* transfer
* transfers
* typically
* unspecified
* upgrade
* which
* will
* wireless
2022-12-29 13:57:31 +00:00
Richard Hughes
de5b2adaab Never allow using SHA-1 for checksum validation 2022-12-29 10:55:08 +00:00
Richard Hughes
427e5cec7a trivial: Add new convenience API to make plugins simpler 2022-12-20 20:54:12 +00:00
Mario Limonciello
2e7355955a trivial: add missing colon in function docs 2022-12-17 07:23:09 -06:00
Richard Hughes
069fa56f1a Add fu_archive_firmware_get_image_fnmatch() for future use
It's useful to get images from archives by a specific filename extension.
2022-12-17 07:44:27 +00:00
Richard Hughes
08e3eaafe0 uefi-dbx: Ignore failure to mount the ESP if unsupported
I think this is only possible when a raw partition with no filesystem has the
ESP or BDP UEFI GUID set in the partition table.
2022-12-16 14:58:03 +00:00
Richard Hughes
ce340e549d trivial: Do not use a GError for a critical problem 2022-12-15 17:27:22 +00:00
Richard Hughes
23cc1ba495 trivial: Fix reading from garbage when getting the pending reboot
Fix the confusion by using a tmp variable.
2022-12-15 17:27:22 +00:00
Richard Hughes
2c5ee07340 trivial: Fix debugging with FU_HID_DEVICE_VERBOSE 2022-12-15 16:41:55 +00:00
Richard Hughes
87ffda474b Allow getting the ESP when there is a block device with no filesystem
Fixes https://github.com/fwupd/fwupd/issues/5313
2022-12-15 08:38:25 +00:00