Commit Graph

954 Commits

Author SHA1 Message Date
Richard Hughes
84a27ea8b9 Fix a fuzzing crash when parsing malicious FDT data 2022-09-12 13:48:45 +01:00
Richard Hughes
e358cc7bde Set the firmware contents even when subclassing ->parse() 2022-09-10 09:16:05 +01:00
Richard Hughes
ee57012df2 trivial: Work around a clang checker false-positive 2022-09-09 19:23:29 +01:00
Richard Hughes
01994a993a trivial: Fix impossible crash when the firmware search path is NULL
PVS: The 'contents' pointer was used unsafely after it was verified against nullptr.
2022-09-09 19:23:29 +01:00
Richard Hughes
9ab03d586e Fix aligning up addresses greater than 4GB
PVS: The size of the bit mask is less than the size of the first operand.
2022-09-09 19:23:29 +01:00
Richard Hughes
aa71485cc5 trivial: Fix a few theoretical memory leaks that can't happen in reality
PVS: The function was exited without releasing the 'str' pointer.
2022-09-09 19:23:29 +01:00
Richard Hughes
c3851c82c8 trivial: Remove duplicate line
PVS: Two identical blocks of text were found.
2022-09-09 19:23:29 +01:00
Richard Hughes
890a48045e trivial: Remove a duplicate line
The conditional expressions of the 'if' statements situated alongside each other are identical.
2022-09-09 19:23:29 +01:00
Richard Hughes
5014c87a2a trivial: Remove a condition that can never be non-valid
PVS: A part of conditional expression is always true: priv->children->len > 0.
2022-09-09 19:23:29 +01:00
Richard Hughes
d88e6b4a1e trivial: Relax the requirement that fu_firmware_set_bytes() can only be called once
PVS: Expression 'priv->bytes != NULL' is always false.
2022-09-09 19:23:29 +01:00
Richard Hughes
6a5eda0a44 trivial: Use G_GSSIZE_FORMAT in more places 2022-09-09 19:23:29 +01:00
Richard Hughes
80608dcac9 Allow setting the FuFirmware size when building firmware 2022-09-08 08:55:51 -05:00
Mario Limonciello
684c663dee trivial: add goshen ridge nvm version parsing 2022-09-08 09:56:33 +01:00
Richard Hughes
c43b981d63 Fix parsing uSWID uncompressed metadata
The magic offset is not required as we're working on a pre-offset GBytes.
2022-09-07 16:02:27 +01:00
Richard Hughes
9e3bd17c70 Fix parsing the coSWID firmware ID when encoded as a UUID 2022-09-07 16:02:27 +01:00
Richard Hughes
1d308b2361 trivial: Export fu_device_set_quirk_kv() for future use
This seems like a useful thing regardless.
2022-09-07 14:43:08 +01:00
Mario Limonciello
aebf33c4f6 trivial: libfwupdplugin: fix an error return string 2022-09-07 08:24:10 -05:00
Richard Hughes
89c16bfb2a Only parse the ARC_PARAMS section of the NVM if provided
The thunderbolt plugin reads in 0x80 bytes if we just want to know if a
firmware is native, and 0x224 if we just want the DIGITAL section. The reason
we do this is that reading the entire NVM is really slow.

If we can see the firmware is smaller than the ARC section, read all the
expected data and return success without adding a payload.
2022-09-06 20:45:38 +01:00
Richard Hughes
1faac75aa5 Ensure the context is set for all backends
This isn't required right now, but new functionality is much easier to add if
we know the context has always been set.
2022-09-06 20:30:21 +01:00
Richard Hughes
709af2a269 Add shared functionality to get the parsed kernel cmdline 2022-09-02 14:35:48 +01:00
Mario Limonciello
ad461d504d bios-settings: Fix plugin functionality
By moving the attribute loading into udev it was loading too late
and plugins couldn't use it.  Move the loading to earlier in the
daemon and ignore add events if we already have attributes loaded.

Fixes: #4979
2022-08-31 09:21:07 -05:00
Richard Hughes
bdfe66a16e trivial: Fix an integer overflow issue when parsing oprom images
Fixes https://oss-fuzz.com/testcase-detail/4524947132776448
2022-08-30 17:34:33 +01:00
Richard Hughes
16b463334e Export the generic Intel Thunderbolt firmware format
This is being used for other products, e.g. USB4 docks.

If non-Intel firmware is being used (e.g. ASMedia) then the explicit
calls to `fu_intel_thunderbolt_nvm_new()` can be changed to something
like `fu_firmware_new_from_gtypes()` with all the formats listed.
2022-08-30 14:20:14 +01:00
Richard Hughes
eec6de6985 Fix applying the latest DBX update on machines with 20200729.x64 installed
Use a hardcoded list of last-set dbx checksums to fix the reported version
when required.
2022-08-26 16:29:28 +01:00
Mario Limonciello
506730879d trivial: fix a minor logic error in sb/3rd party commit 2022-08-25 20:25:17 -05:00
Mario Limonciello
22b477bff5 trivial: don't allow turning on secure boot if 3rd party CA is off
Turning on UEFI secure boot on Lenovo systems with 3rd party CA
turned off will cause a boot loop.
2022-08-25 16:28:38 -05:00
Mario Limonciello
afd661963b trivial: move the FwupdBiosSetting read only map into a hashtable
This is probably going to grow in the future, so make it more efficient.
2022-08-25 14:05:24 -05:00
Mario Limonciello
df07318f36 Move FwupdBiosSetting description database into libfwupdplugin
This needs to be handled by the daemon so that all GUI clients will
be able to load translations as well.

The translations will be distributed with fwupd, and any GUI client
should look up the translations.
2022-08-25 14:05:24 -05:00
Richard Hughes
a5397c6836 Add a new vfunc to check if two firmwares are compatible
For future use.
2022-08-25 15:30:07 +01:00
Mario Limonciello
04c2186edc Add support for loading default BIOS settings policy
A user can place a JSON file in /etc/fwupd/bios-settings.d/ with
the default desired policy for the machine.

fwupd will load this policy on startup to ensure BIOS settings
are set as desired by the system administrator.
2022-08-24 12:59:42 -05:00
Mario Limonciello
2f9cb74c59 trivial: don't assume we know about pending_reboot
The `pending_reboot` variable is tracked by the kernel, make sure
that it is updated from the kernel when BIOS settings are changed.
2022-08-24 12:59:42 -05:00
Richard Hughes
fa2df1eed6 Use ID_VENDOR_ID and ID_MODEL_ID fallbacks
Some udev subsystems run probers to populate the values, rather than
just the kernel providing the sysfs files. Support reading these too.
2022-08-24 15:54:58 +01:00
Mario Limonciello
b7b0ce533d trivial: Unify ambiguity between bios-attrs and bios-settings
These are currently used interchangeably since there was indecisiveness
which to use as the feature was being developed.

As outward facing it will be named with "settings", change all uses
in the code to match this.
2022-08-24 07:20:01 -05:00
Richard Hughes
c886fb8f71 Include vfat in the list of possible BDP partition types
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2119436
2022-08-24 09:41:46 +01:00
Mario Limonciello
2045578d20 trivial: add a debugging statement to indicate BIOS settings work 2022-08-22 09:29:08 -05:00
Mario Limonciello
01d120efda trivial: Make BIOS setting parsing errors less verbose by default
The `--verbose` output for getting BIOS setting info is very noisy
on Lenovo systems due to a mismatch for the driver behavior and
kernel API.

Hide most of it behind an optional environment variable
`FWUPD_BIOS_SETTING_VERBOSE`.
2022-08-22 09:29:08 -05:00
Mario Limonciello
82e2d613aa Add GUIDs using MODALIAS as well
This will allow targeting the same thing that kernel drivers use to load the hardware
2022-08-22 06:03:19 -05:00
Mario Limonciello
2536bf462c Allow running get-bios-settings without root or PK
The only information that is secret is the `current_value`.
Augment the d-bus call to determine whether the caller needs this
information.

* If `fwupdmgr` is launched as root it will be provided.
* If `fwupdmgr` is launched with `--authenticate` it will be requested
  and PK will be engaged.
2022-08-11 09:52:26 -05:00
Mario Limonciello
7ddbe5e0b3 trivial: don't let people try to turn off UEFI secure boot
The firmware from both Dell and Lenovo actually blocks this, but the
error message is pretty confusing.

```
$ sudo fwupdtool set-bios-setting SecureBoot Disable
17:39:40:0249 FuBiosAttrs          KERNEL BUG: thinklmi doesn't export a 'type' attribute
Loading…                 [-                                      ]
failed to write 7 bytes to 17: Invalid argument
```
2022-08-10 11:09:31 -05:00
Mario Limonciello
5f0bb3dc8f Add support for translation for the sample Dell BIOS setting strings 2022-08-10 10:17:25 -05:00
Mario Limonciello
3e5fce5ffa trivial: ignore strings files in directory with drivers not attributes 2022-08-10 10:17:25 -05:00
Mario Limonciello
d51364a8b1 trivial: don't set target BIOS attribute for read only attributes
If an attribute is read only, then we'll have a failure trying to
set it.  So don't offer a target value so clients won't try to set
an attribute.x
2022-08-10 08:20:49 -05:00
Mario Limonciello
fdfdaed911 trivial: bios-attrs: fix a logic bug in lenovo string extraction
Several enumeration attributes were missing their final values
2022-08-05 14:39:48 -05:00
Mario Limonciello
04fd943abd trivial: fix a documentation comment mistake 2022-08-01 12:39:19 -05:00
Richard Hughes
0beed2f138 Store the current BIOS value in a security attribute
We can't very-well ask the user to 'change it back' if we do not tell
them what it is set to already.
2022-08-01 15:45:43 +01:00
Richard Hughes
934002553a Allow loading BIOS attributes for host emulation 2022-08-01 13:32:12 +01:00
Richard Hughes
77006b75eb Set the target value on the security attribute
Semantically it is the desire of the security attribute, not the bios
attribute, i.e. you could imagine that a specific attribute would have
to be *foo or bar or baz* for HSI-1 and *only foo* for HSI-2

Also make it easier to add possible BIOS attribute target values in
plugin code.
2022-08-01 07:12:18 +01:00
Mario Limonciello
7660222240 Add a unique identifier to all BIOSAttr objects
This identifier can be used by plugins or the daemon to disambiguate
behavior between two different drivers.

Set it up so that plugins don't NEED to use it, but optionally can
find attributes by either name or ID
2022-07-29 11:31:50 -05:00
Richard Hughes
93266d36be Fix a crash when parsing an empty BIOS attribute 2022-07-29 12:57:35 +01:00
Richard Hughes
4a78fed13c trivial: Check input parameters to fu_strsplit() 2022-07-29 12:57:35 +01:00