Commit Graph
1537 Commits
Author SHA1 Message Date
Cristian Rodríguez af1a6db58f basic|boot: silence Wunterminated-string-initialization gcc15 warnings
gcc15 has -Wunterminated-string-initialization in -Wextra and
warns about string constants that are not null terminated even though
the functions do do out of bounds access.
Silence the warnings by simply not providing an explicit size.
2024-08-07 00:14:53 +02:00
Yu Watanabe eb8072ee48 boot: fix typo
Follow-up for dcac1e4a9b.
2024-08-03 05:49:53 +09:00
Luca Boccassi 4d6ab7e844 efi: fix link to legacy EFI handover protocol 2024-07-31 01:46:58 +01:00
Luca Boccassi 19812661f1 stub: allocate and zero enough space in legacy x86 handover protocol
A PE image's memory footprint might be larger than its file size due
to uninitialized memory sections. Normally all PE headers should be
parsed to check the actual required size, but the legacy EFI handover
protocol is only used for x86 Linux bzImages, so we know only the last
section will require extra memory. Use SizeOfImage from the PE header
and if it is larger than the file size, allocate and zero extra memory
before using it.

Fixes https://github.com/systemd/systemd/issues/33816
2024-07-31 01:46:25 +01:00
Daniel P. Berrangé 9d7be044ca Fix detection of TDX confidential VM on Azure platform
The original CVM detection logic for TDX assumes that the guest can see
the standard TDX CPUID leaf. This was true in Azure when this code was
originally written, however, current Azure now blocks that leaf in the
paravisor. Instead it is required to use the same Azure specific CPUID
leaf that is used for SEV-SNP detection, which reports the VM isolation
type.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2024-07-30 22:39:20 +02:00
Lennart Poettering 25ff515b39 sd-varlink: make our internal Varlink API public as sd-varlink.[ch]
It's time. sd-json was already done earlier in this cycle, let's now
make sd-varlink public too.

This is mostly just a search/replace job of epical proportions.

I left some functions internal (mostly IDL handling), and I turned some
static inline calls into regular calls.
2024-07-16 11:57:32 +02:00
Lennart Poettering e37164cafc stub: const'ify a few parameters 2024-07-12 09:50:23 +02:00
Lennart Poettering 764faf6040 boot: compare filename suffixes without case
This is VFAT world after all.
2024-07-12 06:29:45 +02:00
Tobias Fleig fc31d929c7 stub: Add support for .ucode EFI addons
This extends #31872 to also load microcode from addon files.
2024-07-08 11:43:40 +02:00
tfg13 34c6d8fe40 stub: mem fixes in devicetree addon handling (#33624)
* stub: mem fixes in devicetree addon handling

Two bugs here: The elements are of size `DevicetreeAddon`, not `size_t`,
and `[]` binds stronger than `*`. This means the first element is ok,
but the second corrupts the stack.

Found this while refactoring #32463
2024-07-04 19:08:55 +01:00
Lennart Poettering 44ec70489f vmm: make sure we can handle smbios objects without variable part
An smbios object with no variable part is a special case, it's just
suffixed with two NUL btes. handle that properly.

This is inspired by a similar fix from https://github.com/systemd/systemd/pull/29726
2024-07-04 20:08:09 +02:00
Daan De Meyer 6a4fcf8cef meson: Fix various versions
Follow up for 8b3b01c4b7

We switch to PROJECT_VERSION instead of PROJECT_VERSION_FULL where
we report our version and which is likely being parsed to avoid
breaking compat. If we didn't, the output would change from systemd
255 to systemd 255.1 which could break various tools.
2024-07-04 19:28:12 +02:00
Luca Boccassi 4ac314a81f Merge pull request #33567 from poettering/boot-fixlets
sd-boot,sd-stub: a variety of smaller fixes
2024-07-04 13:00:56 +02:00
Chen Qi 646ed5af00 src/boot/efi/meson.build: ensure VERSION_TAG exists in case of cross build
The GIT_VERSION is changed to use VERSION_TAG, but in case of cross build
for src/boot/efi, it's not set, causing build error because the compiler cannot
know it's a macro thus treating it as some variable and error out.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
2024-07-04 12:42:35 +02:00
Daan De Meyer 8b3b01c4b7 meson: Deal with potential stable versions
The meson.version file might contain e.g. 256.2~devel in a stable
branch so let's make sure we deal with that.
2024-07-04 12:03:45 +02:00
Lennart Poettering 38faff48e5 boot: don't set OsIndications field if already set correctly 2024-07-03 16:15:04 +02:00
Brenton Simpson 2fda6f5fff boot: cover for hardware keys on phones/tablets
The patch is originally from Brenton Simpson, I (Lennart) just added some
comments and rebased it.

I didn't test this, but the patch looks so obviously right to me, that
I think we should just merge it, instead of delaying this further. In
the worst case noone notices, in the best case this makes sd-boot work
reasonably nicely on devices that only have a hadware power key + volume
rocker.

Fixes: #30598
Replaces: #31135
2024-07-03 16:15:04 +02:00
Lennart Poettering c8bcf7ecf7 measure: drop incomplete support for PCRs != 11
At this point we have a clearer model:

* systemd-measure should be used for measuring UKIs on vendor build
  systems, i.e. only cover stuff predictable by the OS vendor, and
  identical on all systems. And that is pretty much only PCR 11.

* systemd-pcrlock should cover the other PCRs, which carry inherently
  local information, and can only be predicted locally and not already
  on vendor build systems.

Because of that, let's not bother with any PCRs except for 11 in
systemd-measure. This was added at a time where systemd-pcrlock didn't
exist yet, and hence it wasn't clear how this will play out in the end.
2024-07-03 16:15:04 +02:00
Lennart Poettering 759cf7e10a boot: compare auto- prefix case-insensitively 2024-07-03 16:15:04 +02:00
Lennart Poettering 76c8c0b264 boot: split out inner part of config_load_type2_entries()
Let's simplify the code a bit, and parse Type 2 entries in a function of
its own, separate from the directory enumeration.

This closely follows a similar split we did a long time ago for Type 1.

This is just refactoring, no real code change.
2024-07-03 16:15:04 +02:00
Lennart Poettering b8ed6e22f0 boot: indent error code path, but leave main code path unindented 2024-07-03 16:15:04 +02:00
Lennart Poettering 6c741d8f50 efi: don't non-chalantly drop const from memory buffer 2024-07-03 16:15:04 +02:00
Lennart Poettering 1beaaeab2f efi: drop "ret_" prefix from "ret_sections[]" parameter
While we write data to this parameter, it's not really a return
parameter, we after all do not fully set it, we just fill in some
fields. Hence it must be initialized beforehand.

According to our coding style only parameters that are purely used for
returning something should be named "ret_xyz", hence this one should not
be.

(We'll later rely on the current behaviour that it leaves array entries
for which we find no sections untouched, hence leave behaviour as is,
just rename the parameters to something more appropriate).

(Since we are dropping the "ret_" prefix of "ret_sections", let's rename
the old "section" parameter at the same time to "section_names", to make
clearer what it is about).
2024-07-03 16:15:04 +02:00
Lennart Poettering d30b89c7fc efi: fix mangle_stub_cmdline() for empty strings 2024-07-03 16:15:04 +02:00
Lennart Poettering 596731db99 efi: add limit on how large files can be we load into memory at once 2024-07-03 16:15:04 +02:00
Lennart Poettering 31e1edf570 efivars: rename efivar_get_uint_string() → efivar_get_uint64_str16()
Be explicit with the type, and more inline with our other code, that
likes to indicate the string char width in the name.

Also, switch to a fixed size type, since EFI variables should really be
binary exact the same on all archs.
2024-07-02 18:15:35 +02:00
Lennart Poettering 50e8b11e16 efi: rename efivar_(set|get)() → efivar_(set|get)_str16()
These functions after all write EFI UTF-16 strings, i.e. are relatively
high-level, hence give them a specific name indicating the type, to
match our other helpers that have similar type suffixes.
2024-07-02 18:15:32 +02:00
Lennart Poettering 70871dd0a3 efivars: use appropropriate uint8_t type when dealing with "raw" bytes
We don't actually want chars here, but rather raw bytes, in particular
to avoid signedness issues. Hence, let's use uint8_t here.
2024-07-02 18:15:30 +02:00
Lennart Poettering 1d22e23edb efivars: change return parameter of efivar_get_raw() to be void**
This is the "raw", untyped version after all, hence we should return a
void pointer, and let the client cast, if they know more.

Replaces: #30812
2024-07-02 18:15:27 +02:00
Lennart Poettering f84b512290 efi: split out efivars.[ch] from util.[ch]
These are quite a bunch of functions, let's give them their own file.

No code changes, just some trivial refactoring.
2024-07-02 18:15:16 +02:00
Lennart Poettering f829c9f7da stub: move safety check for LoadOptions into if block where we actually use it 2024-06-28 09:58:26 +02:00
Lennart Poettering 558b1600cf stub: don't mangle command line if we got it as array
There are two ways to get the command line: from the EFI shell,
preparsed, already split at whitespace. This we just combine with
spaces, since kernel wants it as one string.

And as one command line blob which is how we are invoked otherwise and
which comes with all kinds of whitespace quite likely.

Let's only strip leading and trailing whitespace in the latter case,
given it's likely the concatenation of whitespace separated strings
generated by shell scripts and such. But let's not strip it we already
received a preparsed array.
2024-06-28 09:58:24 +02:00
Lennart Poettering fc02ea668f stub: make sure we always mangle the cmdlines we read 2024-06-28 09:58:20 +02:00
Lennart Poettering 506ffa0e72 efi: share setting of generic efivars between sd-stub/sd-boot
We have very similar code for setting generic efi vars in sd-stub and
sd-boot. Let's share it.

This changes behaviour in a minor way: if you chainload multiple
versions of an sd-boot you'll see the efi vars of the first one now in
the OS, not of the last one.

But this should not matter, invocation like that should generally not
happen.
2024-06-26 17:09:45 +02:00
Lennart Poettering 75d08dc6e8 measure: normalize error paths
Always put the success path at least indentation, and indent the error
paths.
2024-06-26 17:09:45 +02:00
Lennart Poettering 4a3659c5f4 stub: rework linux handover to take "struct iovec" 2024-06-26 17:09:45 +02:00
Lennart Poettering a729187a19 stub: turn lookup_name() into shorter and more generic function that turns sectin into char* string 2024-06-26 17:09:45 +02:00
Lennart Poettering c36c088a93 stub: add helper that turns PE section into char16_t* string 2024-06-26 17:09:45 +02:00
Lennart Poettering c8af9aca9e stub: reorder variables 2024-06-26 17:09:45 +02:00
Lennart Poettering 4087aa38c5 stub: reorder things a bit, so that initrds are generated/looked up together 2024-06-26 17:09:45 +02:00
Lennart Poettering e864cd91d5 stub: uniformly process "measured" flags
Always pass the pointer through so that the functions combine the flags
directly, instead of doing that in the caller.
2024-06-26 17:09:45 +02:00
Lennart Poettering fe0f6c099c stub: split out function that determines main cmdline 2024-06-26 17:09:45 +02:00
Lennart Poettering 9597320f5c stub: normalize error handling when looking for PE sections 2024-06-26 17:09:45 +02:00
Lennart Poettering 9f3bc7b505 stub: slightly reorder things
Let's do the section measurement first, before we use any data of it.

Let's bring up the boot splash next, so that it covers anything else we
might do.
2024-06-26 17:09:45 +02:00
Lennart Poettering 248b3257a1 stub: split out code that displays boot splash 2024-06-26 17:09:45 +02:00
Lennart Poettering 1489e66f7c stub: split out code that loads all addons from disk into function of its own 2024-06-26 17:09:45 +02:00
Lennart Poettering 16b550d01a stub: merge separate lists for addon cmdlines/devicetrees into one
Instead of keeping the lists for the global and per-UKI addons separate
throughout, just merge them. We apply them in the same order after all.
2024-06-26 17:09:45 +02:00
Lennart Poettering acf3e58eb3 stub: don't make up errors 2024-06-26 17:09:45 +02:00
Lennart Poettering 9e2ed6c78f stub: add DevicetreeAddon structure
Instead of keeping three parallel arrays of dt base, dt size and dt
filename, just introduce a proper structure and use an array of that,
greatly simplifying DT handling.
2024-06-26 17:09:45 +02:00
Lennart Poettering dcac1e4a9b stub: split out call that loads embedded device tree 2024-06-26 17:09:45 +02:00