Commit Graph

984 Commits

Author SHA1 Message Date
Richard Hughes
a8e56396d5 Prevent a partial fuzzing DoS when loading corrupt SREC files
The SREC parser attempts to fill 1Mb of data when parsing corrupt data sections
-- which in the static fuzz targets takes a long time. Correctly check that the
data exists to mitigate.

Fixes https://oss-fuzz.com/testcase-detail/6102934106013696
2022-09-29 12:32:35 +01:00
Mario Limonciello
d5585728a2 trivial: don't refer to plugindir in the build system anymore 2022-09-28 15:12:10 -05:00
Richard Hughes
99002a7a18 Build many more plugins as builtin
This reduces the plugin directory size by 2.2Mb
2022-09-28 17:01:23 +01:00
Richard Hughes
439c364f46 trivial: Fold FuPluginVfuncs into FuPluginClass
This adds 7 pointer-size blocks of wasted space for each modular plugin, and
three pointers for builtin plugins, but allows us to use the exact same vfuncs
when building plugins in either mode.

This will allow us to convert nearly all the plugins to being builtin.
2022-09-28 14:42:04 +01:00
Richard Hughes
f8400ffaae trivial: Rename the FuPluginClass signals callbacks
The aim is to fold FuPluginVfuncs into this, and the names clash.
2022-09-28 14:42:04 +01:00
Richard Hughes
2a5f7766a4 trivial: Remove the deprecated fu_plugin_set_secure_config_value() 2022-09-28 14:42:04 +01:00
Richard Hughes
3dbf5fa8a4 trivial: Remove the deprecated fu_volume_new_esp_default() 2022-09-28 14:42:04 +01:00
Richard Hughes
d629240a83 trivial: Remove the padding from FuXxxClass structs
The library is now tied to the current fwupd version, so we can break API.
2022-09-28 14:42:04 +01:00
Richard Hughes
99e9e5d523 Allow compiling plugin as built-in GObjects
Allow plugins to be built into libfwupdpluginbuiltin.so and created via GType.
2022-09-28 12:52:00 +01:00
Mario Limonciello
ec0496b47a Make libfwupdplugin an internal library instead
This drops the requirement on us being so strict on a particular ABI version,
and also more strongly discourages out of tree plugin development.

We should still strive to keep API stable, and as such keep a symbol map still.

Use rpath instead for the static plugins, and set the plugin install directory
to just fwupd-$ABI$ as we're storing more than just plugins here now.
2022-09-28 10:04:12 +01:00
Richard Hughes
3fa2df2ab3 trivial: Remove unused build includes
It was amazing this ever worked, as the file was being generated in src/
2022-09-27 14:18:01 +01:00
Richard Hughes
c4b7f42e43 Only compress one version of the builtin-quirks
Saving the quirks in the GResource section worked well, but it made the build
system very complicated and also meant the .data section was duplicated in
both `fwupd` and `fwupdtool` -- negating a lot of the hard-fought savings.

Simplify this feature so that we just `cat` all the quirk files together, then
gzip them into a single file. This means that at startup fwupd only needs to
check the mtime of one file, and weirdly it's actually faster to load a smaller
compressed file from disk that it is to load multiple uncompressed files.
2022-09-27 12:44:04 +01:00
Richard Hughes
24db10ac1c trivial: Add fu_plugin_set_context() for future use 2022-09-26 22:24:41 +01:00
Richard Hughes
0415db6f67 Revert "trivial: Use files() rather than current_source_dir()"
This reverts commit b581fa5670 as it breaks
`ninja dist` with `-Dgresource_quirks=enabled`.
2022-09-25 10:31:14 +01:00
Richard Hughes
b581fa5670 trivial: Use files() rather than current_source_dir() 2022-09-24 09:12:14 -05:00
Richard Hughes
b50ef90aa6 trivial: Fix up some internal docs to reflect reality 2022-09-23 16:39:21 +01:00
Richard Hughes
c73a55faa1 Remove a potential foot-gun when saving config values
If a specific plugin calls fu_plugin_set_secure_config_value() and then
fu_plugin_set_config_value() then we'll save the file with the world-readable
permissions.

Set a plugin flag to say that 'this plugin is storing sensitive details' which
allows us to use the same entrypoint and also fix up any files at startup that
do not have the correct permissions.
2022-09-22 14:47:12 +01:00
Richard Hughes
ea676855f2 Never save the Redfish passwords to a file readable by users
When the redfish plugin automatically creates an OPERATOR user account on the
BMC we save the autogenerated password to /etc/fwupd/redfish.conf, ensuring it
is chmod'ed to 0660 before writing the file with g_key_file_save_to_file().

Under the covers, g_key_file_save_to_file() calls g_file_set_contents() with
the keyfile string data.
I was under the impression that G_FILE_CREATE_REPLACE_DESTINATION was being
used to copy permissions, but alas not.

GLib instead calls g_file_set_contents_full() with the mode hardcoded to 0666,
which undoes the previous chmod().

Use g_file_set_contents_full() with the correct mode for newer GLib versions,
and provide a fallback with the same semantics for older versions.
2022-09-22 14:46:44 +01:00
Richard Hughes
be2311c6c3 trivial: Fix gtk-doc markup issue 2022-09-22 14:34:10 +01:00
Richard Hughes
5d38e0aeea Move the getting the ESP to the context
We now have two plugins getting the ESP values, and we only allow hardcoding
the ESP in uefi_capsule.conf.

Make all this a lot simpler by moving the ESP+BDP code to `FuContext`, which
also means we can handle the override (via the config file) in the engine,
and the override (in the command line tools) using the same mechanism.

Also, automate the migration of the `OverrideESPMountPoint` -> `EspLocation`
when loading the engine.

Fixes https://github.com/fwupd/fwupd/issues/5042
2022-09-22 14:31:06 +01:00
Richard Hughes
1c27131fc6 trivial: Style nit
Co-authored-by: Mario Limonciello <mario.limonciello@amd.com>
2022-09-22 14:24:50 +01:00
Richard Hughes
b71968d348 trivial: Fix -Wunused-but-set-variable warning 2022-09-22 14:24:50 +01:00
Richard Hughes
7fd8aa6a38 Ignore missing NUL when parsing DS20 quirk data 2022-09-22 14:23:20 +01:00
Richard Hughes
096364199b trivial: Fix self tests when using -Dgresource_quirks=enabled
We want to also skip the compiled-in GResource quirks if loading the context
with _NO_CACHE.
2022-09-21 12:59:44 +01:00
Richard Hughes
0d60fa319f trivial: Fix two gi-docgen issues 2022-09-20 10:16:55 +01:00
Richard Hughes
b4f2d10562 trivial: Add some links to the BDP and ESP defines 2022-09-17 13:43:22 +01:00
Richard Hughes
e72ed08b56 Always check the BDP partitions when getting all the possible ESPs
Fixes https://github.com/fwupd/fwupd/issues/5035
2022-09-17 13:41:36 +01:00
Richard Hughes
48beb87faf Copy backend tags to the GUsbDevice when possible.
This allows the backend to identify the specific device for a specific phase.

For instance, there might be a pre-update runtime, a bootloader and a
post-update runtime and allowing tags to be saved to the backend object allows
us to identify each version of the same physical device.

This takes us one step closer to emulating a complete byte-perfect end-to-end
update without actual hardware installed.
2022-09-14 16:54:55 +01:00
Richard Hughes
139188a5b0 Allow adding backend tags to devices
This allows the backend to identify the specific device for a specific phase.

For instance, there might be a pre-update runtime, a bootloader and a
post-update runtime and allowing tags to be saved to the backend object allows
us to identify each version of the same physical device.

This takes us one step closer to emulating a complete byte-perfect end-to-end
update without actual hardware installed.
2022-09-14 16:54:55 +01:00
Richard Hughes
bfebede490 Add support for platform capability descriptors so devices can set quirks
This feature adds support for platform capability BOS descriptors which allows
the device itself to ship quirk data.

Use `sudo fwupdtool get-devices --save-backends=FILENAME` to save fake backend
devices to a file. This allows easy creation of self tests that do not require
physical hardware.
2022-09-13 12:07:35 +01:00
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