Commit Graph
1329 Commits
Author SHA1 Message Date
Joerg Behrmann 7227dd816f treewide: fix typos
- mostly: usecase -> use case
- continously -> continuously
- single typos in docs/FILE_DESCRIPTOR_STORE.md
2023-09-19 10:05:38 +02:00
Zbigniew Jędrzejewski-Szmek eb98074b5c bootctl: use pager in help
The output is more than one page, let's enable the pager.
2023-09-14 22:32:20 +02:00
Lennart Poettering fea82394bc Merge pull request #29071 from YHNdnzj/loop-write-full
io-util: introduce loop_write_full and use it where appropriate
2023-09-08 10:24:39 +02:00
Jan Janssen b7801869d7 efi: Add some more paranoia asserts 2023-09-07 20:41:12 +01:00
Mike Yuan e22c60a9d5 io-util: introduce loop_write_full that takes a timeout
Also drop do_poll as the use case is covered
by timeout.
2023-09-07 20:30:44 +08:00
Lennart Poettering ef65c0f6cc openssl-util: add common implementation of digest+sign 2023-09-06 18:34:21 +01:00
Lennart Poettering cb19bdaebf tpm2: whenever we measure, also write a tpm log record
Previously we only logged our measurements to the journal. This is not a
great solution though, since regular logs are subject to rotation, which
is something we really cannot have for measurements (as it means we can
never reproduce the PCR values from the data). Hence, let's maintain an
explicit log.

Ideally, we'd just use the TCG Canonical Event Log format 1:1
(https://trustedcomputinggroup.org/resource/canonical-event-log-format/).
However it's not a perfect fit fo us, for various reasons. But let's
follow it (in its JSON incantation) as closely at it makes sense, so
that it can easily be converted to the full format by programs consuming
it.

Code comments explain where we deviate from the TCG CEL-JSON, and what
to do about it when reading the data.
2023-08-30 12:59:34 +02:00
Luca Boccassi cd4ed8579b Merge pull request #28948 from poettering/tpm2-duplicate-pcr-names
tpm2: unify tpm2 PCR symbolic identifiers
2023-08-28 17:43:10 +01:00
Zbigniew Jędrzejewski-Szmek 56a0b9065e meson: restore specifications of dependency on version_h
This partially reverts 3c1eee5bed.
I thought that it is not necessary, but
https://mesonbuild.com/Reference-manual_functions.html#vcs_tag says:

> This method returns a custom_tgt should be used to signal dependencies if
> other targets use the file outputted by this.
>
> For example, if you generate a header with this and want to use that in a
> build target, you must add the return value to the sources of that build
> target. Without that, Meson will not know the order in which to build the
> targets.

We can use version_h directly, since we already have it.

Hopefully fixes https://github.com/systemd/systemd/issues/28994.
2023-08-28 14:06:23 +01:00
Lennart Poettering 73f0eedf9b boot: don't pass kernel cmdline option to UKIs which have the very same line built-in
There's really no point in first extracting a command line from an UKI
to just pass it unmodified to the UKI. In particular as this is
systematically ignored in SecureBoot is enabled.

Let's drop this, so that unless the user actually edits the cmdline we
pass nothing to the invoked kernel.

Note that this low-key is a compat break, since the passed cmdline gets
measured. However, in the interest of minimized the difference between
systems with and without sd-boot to behave the same i think we should
suppress the command line anyway.
2023-08-28 11:24:53 +01:00
Zbigniew Jędrzejewski-Szmek 3c1eee5bed meson: drop "versiondep" object
It was added to make sure that the version tag was built early
enough. Now that we use vcs_tag, meson should take care of building
it early enough.
2023-08-26 17:16:59 +02:00
Jan Janssen c78b611e48 meson: Bring back use of vcs_tag
The use of vcs_tag was dropped in #28567, which results in builds having
stale version information once new commit are made.

This also fixes a case where CI builds would have no version information
because they are checked out without any tags for git-describe to use.

Additionally, use `--git-dir` now, as that particular issues seems to
have been fixed by now.
2023-08-26 13:53:42 +09:00
Lennart Poettering e0e1f4f7a2 fundamental: rename tpm-pcr.h → tpm2-pcr.h
I always found it confusing that most of our TPM related definitions are
in tpm2-util.h, but the PCR names in tpm-pcr.h, without the "2". Let's
fix that and make this systematic, in particular as the definitions in
the file all start with TPM2_ already.

No code flow changes, just some renaming.
2023-08-24 13:40:37 +02:00
Lennart Poettering 46c5a1383a fundemental: split out UKI defines into its own header
The UKI sections have little to do with the PCRs, hence give them their
own header.
2023-08-24 13:40:37 +02:00
Lennart Poettering 2099cd6289 tpm2: unify symbolic name infra for PCRs
We so far maintained two places for symboic names for PCRs. One in
tpm2-util.h and one in tpm-pcr.h.

Let's unify this into one, i.e. move the full list from tpm2-util.h into
tpm-pcr.h, replacing the short list placed so far there.

Systematically prefix the definitions with TPM2_ or tpm2_, to follow how
we do this for all other defines in this context.

No change in behaviour, just unification of tables.
2023-08-24 13:40:37 +02:00
Lennart Poettering c91f581c47 tree-wide: use json_variant_append_arrayb() at many places 2023-08-24 13:19:52 +02:00
Lennart Poettering ba091282e5 utf8: automatically determine length of string if SIZE_MAX is specified
Let's make utf8_to_utf16() and utf16_to_utf8() a bit nicer to use by
adding shortcuts for common cases.

This is particularly relevant for utf16_to_utf8() since the
multiplication with 2 is easy to forget.
2023-08-24 13:19:12 +02:00
Jan Janssen 2d7c857d9c meson: Simplify efi test/fuzz definitions 2023-08-23 14:58:04 +02:00
Jan Janssen 40e9c4e45d meson: Convert options to meson features (require)
These options use requre() to conveniently express their dependency
requirements.
2023-08-23 14:45:02 +02:00
Lennart Poettering 1b9af63f55 boot: add control-less alias for Ctrl-l hotkey
I couldn't get ctrl work properly over serial line/qemu. Hence, let's
add an alias for Ctrl-l: a simple Shift-l (i.e. uppercase L)

(Note that lowercase L will result in selection of the first Linux
entry, hence we stay away from that)
2023-08-22 11:29:36 +02:00
Lennart Poettering f6531b11d2 boot: add hotkeys for rebooting/powering off the system from the boot menu
In a an environment with a serial console it's just too useful to
directly reboot/power off the machine without any further tooling.
2023-08-22 11:29:36 +02:00
Lennart Poettering 90dab2b01e boot: modernize mangle_stub_cmdline() a bit + drop leading whitespace
Let's modernize the function a bit, and make it return the string passed
in, as we usually do.

Most importanly though: also drop leading whitespace, not just trailing
whitespace.
2023-08-22 10:53:25 +02:00
Lennart Poettering c4d281fa1a boot: explain why we refuse to edit kernel cmdline when we do so 2023-08-22 10:46:34 +02:00
Lennart Poettering b022ea0476 efi: add comment clarifying we should not use EV_IPL anymore 2023-08-21 23:18:28 +02:00
Lennart Poettering cf1ab844a9 tree-wide: drop "static inline" use in .c files
"static inline" makes sense in .h files. But in .c files it's useless
decoration, the compiler should just make its own decisions there, and
it can do that.

hence, replace all remaining uses of "static line" by a simple" static"
in all .c files (but keep them in .h files, where they make sense)
2023-08-21 23:15:12 +02:00
Emanuele Giuseppe Esposito fab0eeb72b systemd-stub: ignore EFI shell unauthenticated kernel command line if we are in confidential vms 2023-08-17 11:31:43 +02:00
Zbigniew Jędrzejewski-Szmek bb44fd0734 various: use _NEG_ macros to reduce indentation
No functional change intended.
2023-08-16 12:52:56 +02:00
Zbigniew Jędrzejewski-Szmek d66ad6ff85 sd-id128: introduce ERRNO_IS_NEG_MACHINE_ID_UNSET 2023-08-16 12:52:56 +02:00
Lennart Poettering 490b4486a7 file-io: let's use offsetof() rather than sizeof() for determining EFI_FILE_INFO prefix size
The gnu-efi definition of the struct uses [1], our local one [0] to size
the filename array. Let's avoid an ambiguity and use offsetof() so that
this difference doesn't matter. Also, doing it this way makes very clear
to the read what happens here: it's a structure with a variable size
suffix.
2023-08-11 04:11:05 +09:00
Lennart Poettering 0de0ed6e89 bootctl: don't advertise systemd-efi-options in --help/man anymore
The command is deprecated, as per NEWS of 254. Let's go one step further
and remove it from the help text and man page, so that people are not
inspired to use it at this time anymore.

This is how we usually have done this before: remove it from visibility,
but support it for a while still.
2023-08-09 14:25:46 +02:00
Dan Streetman 53b91e1981 tpm2: add TPM2B_*_MAKE(), TPM2B_*_CHECK_SIZE() macros
The tpm2-tss library has many structs with only an array and size; these macros
make it easy to assign to these structs.
2023-08-04 10:57:07 -04:00
Dan Streetman 6e8fb3ad5f tpm2: change tpm2_calculate_policy_pcr(), tpm2_calculate_sealing_policy() to use Tpm2PCRValue array
An array of Tpm2PCRValue objects effectively replaces a TPML_PCR_SELECTION
object combined with an array of (properly ordered) TPM2B_DIGEST objects.

Also update tpm2_calculate_sealing_policy() pin parameter to boolean use_pin,
since the function does not need to know the pin value, only if a pin is being
used.
2023-08-04 10:57:07 -04:00
Yu Watanabe cbc55c4cce meson: also merge declarations of fuzzers with other executables 2023-08-03 20:37:16 +09:00
Yu Watanabe 130c87b16a meson: merge declarations of normal and test executables 2023-08-03 20:37:16 +09:00
Jan Janssen e80037b10f boot: Make file info size a constant 2023-08-02 16:22:42 +02:00
Jan Janssen 66fd078ba8 boot: Fix boot counting for XBOOTLDR entries
We were passing the dir handle for the ESP to
config_entry_bump_counters(), which will obviously fail if the entry
actually resides on the XBOOTLDR partition.

Fixes: #28637
2023-08-02 16:06:57 +02:00
Jan Janssen 8f30a066ff bless-boot: Actually return successfully
$ journalctl -u systemd-bless-boot.service
systemd[1]: Starting Mark the Current Boot Loader Entry as Good...
systemd-bless-boot[536]: Marked boot as 'good'. (Boot attempt counter is at 2.)
systemd-bless-boot[536]: Can't find boot counter source file for '/loader/entries/arch.conf': Device or resource busy
systemd[1]: Finished Mark the Current Boot Loader Entry as Good.
2023-08-02 15:16:33 +02:00
Yu Watanabe bd31a348bf meson: move declarations of bootctl and friends
This also drops unnecessary dependency on libblkid from
systemd-boot-check-no-failures.
2023-08-01 02:31:36 +09:00
Luca Boccassi fcd71b62be Merge pull request #28595 from medhefgo/elf2efi-fixes
elf2efi: Fixes
2023-07-31 00:07:28 +01:00
Luca Boccassi 6c0ac118d2 Merge pull request #28567 from yuwata/meson-versiondep
meson:  cleanups for version dependency
2023-07-30 23:40:51 +01:00
Jan Janssen d0bbe32485 stub: Also reserve sections for EFI stub
The stub image may not have enough sections to cause enough PE header
space to be free for later expansion. Given that the stub is guaranteed
to be expanded we should always reserve enough sections for it.

This also bumps the reservation to 15. It doesn't add more space
compared to current builds but it more closely reflects the amount of
sections that a UKI could have in total if all optional sections are
used.

Fixes: #28593
2023-07-30 21:31:38 +02:00
Luca Boccassi 167338529b Merge pull request #28428 from ldv-alt/ERRNO_IS
treewide: cleanup use of ERRNO_IS_*(r)
2023-07-30 16:31:16 +01:00
Yu Watanabe 0c491d0f34 meson: use kwargs to declare efi binaries
No functional change, just refactoring.
2023-07-30 08:57:55 +09:00
Yu Watanabe 4122d68682 boot: always set SBAT_DISTRO_VERSION 2023-07-30 04:54:47 +09:00
Daan De Meyer 7ccb171c4c Merge pull request #28359 from keszybz/ret-gather
Add RET_GATHER macro to make continue-but-remember-first-error functions easier
2023-07-28 14:28:35 +02:00
Dmitry V. Levin 3dadc118aa bootctl: cleanup use of ERRNO_IS_NOT_SUPPORTED()
Given that ERRNO_IS_NOT_SUPPORTED() also matches positive values,
make sure this macro is not called with arguments that do not have
errno semantics.

In this case the argument passed to ERRNO_IS_NOT_SUPPORTED() is the
value returned by efi_loader_get_entries() which is not expected to
return any positive values, but let's be consistent anyway and move
the ERRNO_IS_NOT_SUPPORTED() invocation to the branch where
the return value is known to be negative.
2023-07-28 12:28:35 +00:00
Luca Boccassi 80256e8c54 Merge pull request #28527 from medhefgo/boot-stack-guard
boot: Fall back to using image load address for stack guard
2023-07-28 09:56:41 +01:00
Luca Boccassi 46021aaaa6 Merge pull request #28417 from bluca/coverity
Some coverity fixes
2023-07-28 09:56:08 +01:00
Luca Boccassi eff91e2f38 efi: link with -z nopack-relative-relocs
elf2efi.py cannot handle DT_RELR relocations, so disable it
if we can

Fixes https://github.com/systemd/systemd/issues/28520
2023-07-26 18:47:53 +01:00
Jan Janssen bc32a9fdfd boot: Fall back to using image load address for stack guard
If we cannot get random data from the RNG protocol we can still use our
load address to make the stack guard a little less static.
2023-07-26 15:11:08 +02:00