Commit Graph
1413 Commits
Author SHA1 Message Date
Yu Watanabe 5b532e14e3 bootctl-uki: several coding style fixlets
Mostly follow-ups for #26082.
2023-01-24 16:32:34 +01:00
Gerd Hoffmann 2d4260482c bootctl: kernel-inspect: print os info 2023-01-24 16:32:16 +01:00
Luca Boccassi 780b9ae133 Merge pull request #26110 from medhefgo/boot-no-gnu-efi
boot: Stop linking against libefi.a
2023-01-23 23:51:49 +00:00
Callum Farmer 9c100c4e70 boot: Use objcopy with arm64
Binutils 2.38 added support for efi-app-aarch64
Still use binary mode if we have an older objcopy
Add check for incompatible gnu-efi crt0 containing the header section
which gets added by objcopy and if used results in duplicate header
and subsequently a broken binary

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-01-23 22:52:07 +00:00
Jan Janssen cd4300f30f meson: Move bootctl sources defintion to its own file
The root meson.build file is already large enough.
2023-01-23 14:41:26 +01:00
Jan Janssen 1d278ad7d4 boot: Stop linking against libefi.a
libefi.a just provided the c helper API that was slowly removed. As we
do not depend on anything provided by it anymore, it is safe to drop
now.

Since the ST/BS/RT pointers are very convenient and needed everywhere,
they are retained and initialized by us.
2023-01-20 21:02:16 +01:00
Jan Janssen 31a131bb32 boot: Introduce DEFINE_EFI_MAIN macro 2023-01-20 21:01:08 +01:00
Jan Janssen 831b6a7fb0 boot: Simplify debug hook 2023-01-20 20:55:11 +01:00
Jan Janssen 19f08504c5 boot: Rework GUID handling
This stops using global GUID variables provided by gnu-efi. The globals
presumably exist to make EFI calls easier. But these GUIDs are just
128bits, so it's cheap to just put them on the stack when needed. C99
compound literals makes this even easier.

This also adds a convenience macro to create GUID pointers and uses it
everywhere. Not forcing a GUID definition to be a compound literal makes
them easier to use when assigning them to variables:
    EFI_GUID before = *SOME_CONST_GUID;
    EFI_GUID after = SOME_GUID;

And MAKE_GUID_PTR() makes it more explicit what is happening. It was
easy to confuse the old code as a cast:
    before(&(EFI_GUID) SOME_GUID);
    after(MAKE_GUID_PTR(SOME));
2023-01-20 20:55:11 +01:00
Jan Janssen 888b678f9f boot: Drop use of ValueToString 2023-01-20 20:55:11 +01:00
Jan Janssen edb73ee742 boot: Drop use of GuidToString 2023-01-20 20:55:11 +01:00
Lennart Poettering e684d2d5f8 bootctl: remove space that should not be there 2023-01-20 18:42:25 +01:00
Lennart Poettering eab7061898 bootctl: split out boot loader spec + boot loader interface commands in --help text
grub (at least on fedora) nowadays implements the boot loader spec, but
not the boot loader interface. Hence let's split out the commands
specific to each in two groups in the --help text. This way the first
group just covers boot lodaer spec stuff (i.e. stuff on disk in the
ESP/XBOOTLDR partition). And the other covers talking to the boot loader
via EFI var.
2023-01-20 18:42:25 +01:00
Lennart Poettering 5bbf72bb9e bootctl: realign column in --help text
for some reason the descriptions of the switches and the commands
weren't aligned, one space off. Fix that.
2023-01-20 18:30:47 +01:00
Lennart Poettering 1e7d6cc072 bootctl: change section title for kernel image commands
Let's call them kernel *images*, not just *kernels*.
2023-01-20 18:30:06 +01:00
Lennart Poettering 2b197967bf bootctl: drop full stop at end of --help texts
We never do that, don't do so here either.
2023-01-20 18:29:15 +01:00
Jan Janssen 4c0a83a434 boot: Properly strip EFI binaries
Removing debugging related sections is apparently not enough to truely
strip a (PE) binary.
Better late than never. It gets rid of this pesky warning from sbsign:
    warning: data remaining[174080 vs 193173]: gaps between PE/COFF sections?
2023-01-20 17:28:35 +01:00
Gerd Hoffmann 24a3b37f12 bootctl: add kernel-inspect to --help text 2023-01-20 14:17:51 +00:00
Yu Watanabe d09df6b94e tree-wide: fix typo 2023-01-20 15:32:16 +09:00
Ludwig Nussel 8702496bfb bootctl: unlink and cleanup functions
The unlink command removes an entry from the ESP including
referenced files that are not referenced in other entries. That is
useful eg to have multiple entries that use the same kernel with
different options.

The cleanup command removes all files that are not referenced by any
entry.
2023-01-19 14:24:43 +01:00
Luca Boccassi 41d125614c Merge pull request #23706 from medhefgo/efi-clang
boot: Add printf functions
2023-01-18 22:24:39 +00:00
Lennart Poettering a56182ddac Merge pull request #26082 from kraxel/uki
bootctl: add is-uki command
2023-01-18 18:10:30 +01:00
Jan Janssen 9220b2c46b boot: Drop use of Print
The custom print helpers have been replaced with explicit checks at the
call site to keep this in line with the way it is done in userspace. Any
calls where the check has been ommited should not need them as the value
is expected to alawys be around.
2023-01-18 17:47:57 +01:00
Jan Janssen 2f3c3b0bee boot: Drop use of xpool_print/SPrint 2023-01-18 17:47:57 +01:00
Jan Janssen 5966c54df4 boot: Add log_trace debugging helper 2023-01-18 16:50:04 +01:00
Jan Janssen 6ac54809de boot: Introduce log_wait
Instead of stalling for every log message as it appears we now wait for
several messages at strategic locations.
2023-01-18 16:50:04 +01:00
Jan Janssen c2c6203556 boot: Use printf for error logging
This also drops the _stall suffix in anticipation of the next commit.
2023-01-18 16:50:04 +01:00
Jan Janssen 7c4536a9af boot: Add printf functions 2023-01-18 16:50:04 +01:00
Gerd Hoffmann a05255981b bootctl: add kernel-inspect command
Takes a kernel image as argument. Prints details about the kernel.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2023-01-18 14:32:14 +01:00
Gerd Hoffmann 53c368d71b bootctl: add kernel-identity command
The command takes a kernel as argument and checks what kind of kernel
the image is.  Returns one of uki, pe or unknown.
2023-01-18 14:32:14 +01:00
Jan Janssen bb4e8820c1 boot: Fix missed argument to Print()
This fixes 3e87a057a7, which passed the
path to the wrong Print() call. Miraculously, this was printing the
correct path during testing and was therefore missed.
2023-01-17 19:44:39 +01:00
Lennart Poettering a45215ed33 Merge pull request #25006 from poettering/pcr15
cryptsetup: measure LUKS volume keys to PCR 15
2023-01-17 11:04:03 +01:00
Lennart Poettering 6c51b49ce0 tpm2: add common helper for checking if we are running on UKI with TPM measurements
Let's introduce a common implementation of a function that checks
whether we are booted on a kernel with systemd-stub that has TPM PCR
measurements enabled. Do our own userspace measurements only if we
detect that.

PCRs are scarce and most likely there are projects which already make
use of them in other ways. Hence, instead of blindly stepping into their
territory let's conditionalize things so that people have to explicitly
buy into our PCR assignments before we start measuring things into them.
Specifically bind everything to an UKI that reported measurements.

This was previously already implemented in systemd-pcrphase, but with
this change we expand this to all tools that process PCR measurement
settings.

The env var to override the check is renamed to SYSTEMD_FORCE_MEASURE,
to make it more generic (since we'll use it at multiple places now).
This is not a compat break, since the original env var for that was not
included in any stable release yet.
2023-01-17 09:42:16 +01:00
Lennart Poettering 17984c5551 pcrphase: make tool more generic, reuse for measuring machine id/fs uuids
See: #24503
2023-01-17 09:42:16 +01:00
Lennart Poettering 9885c8745d tpm2-util: optionally do HMAC in tpm2_extend_bytes() in case we process sensitive data
When measuring data into a PCR we are supposed to hash the data on the
CPU and then pass the hash value over the wire to the TPM2. That's all
good as long as the data we intend to measure is not sensitive.

Let's be extra careful though if we want to measure sensitive data, for
example the root file system volume key. Instead of just hashing that
and passing it over the wire to the TPM2, let's do a HMAC signature
instead. It's also a hash operation, but should protect our secret
reasonably well and not leak direct information about it to wiretappers.
2023-01-17 09:42:16 +01:00
Lennart Poettering 15c591d1e2 tpm2-util: split out code that extends a PCR from pcrphase
This way we can reuse it later outside of pcrphase
2023-01-17 09:42:16 +01:00
Lennart Poettering e4481cc512 tpm2-util: split out code that derives "good" TPM2 banks into an strv from pcrphase and generalize it in tpm2-util.c
That way we can reuse it later from different places.
2023-01-17 09:42:16 +01:00
Jan Janssen 3e87a057a7 boot: Skip soft-brick warning when in a VM
This part of the warning is annoying to look at not really true when
running inside of a VM.
2023-01-16 18:51:28 +01:00
Jan Janssen ba27939274 boot: Detect hypervisors using SMBIOS info
This allows skipping secure boot enrollment wait time on other arches.
2023-01-16 18:51:21 +01:00
Daan De Meyer 1a01473065 boot: Remove -O1 workaround
Now that we have ukify and mkosi has been updated to use it, we
have a solution in place to make sure that PE sections don't overlap
in a UKI so let's drop the workaround to avoid overlapping PE sections.
2023-01-15 20:45:22 +01:00
Lennart Poettering a6edc20fa6 Merge pull request #26003 from keszybz/efi-ifdefs
Fix one compile-time conditional and refactor SD_BOOT definition
2023-01-10 18:28:10 +01:00
Ludwig Nussel 2e76ca79b3 bootctl: honor $KERNEL_INSTALL_CONF_ROOT
Honor $KERNEL_INSTALL_CONF_ROOT for reading config files, as
kernel-install does.
2023-01-10 15:17:07 +01:00
Zbigniew Jędrzejewski-Szmek 493cd5034c meson: use 0|1 for SD_BOOT
We converted to not using #ifdef for most of our defines because the syntax is
nicer and we are protected against typos and can set -Werror=undef. Let's do
the same for SD_BOOT. The define is nicely hidden in build.h for normal builds,
and for EFI builds we were already setting SD_BOOT on the commandline.
2023-01-10 14:25:57 +01:00
Jan Janssen 3f92dc2fd4 boot: Simplify object erasure
This erase_obj() machinery looks like voodoo and creates an awful lot of
noise as soon as we get back to building with -O0. We can do this in a
more simple way by introducing a struct that holds the information we
need on cleanup. When building with optimization enabled, all this gets
inlined and the eraser vanishes.
2023-01-09 18:58:54 +01:00
Lennart Poettering a3310012e8 Merge pull request #25979 from yuwata/coverity-fixes
Coverity fixes
2023-01-09 09:56:04 +01:00
Jan Janssen d84bdadb43 boot: Remove option TPM PCR compat option
It says remove in 2023; happy to oblige.
2023-01-09 09:52:55 +01:00
Yu Watanabe 3d5af17045 bootctl: 'tmp' is always non-NULL
Fixes CID#1502330.
2023-01-09 11:00:56 +09:00
Yu Watanabe a42909e60c bootctl: fix indentation 2023-01-09 10:58:10 +09:00
Ludwig Nussel 8109b2908d bootctl: print entry token as well 2023-01-05 21:45:18 +01:00
Lennart Poettering 54978e3f3b bootctl: split out setting of system token into function of its own
Let's break a huge function in two. No code change, just some
refactoring.
2023-01-04 15:18:10 +01:00