Commit Graph
731 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek d9f048b5d1 bootctl: split out the check whether sd-boot is installed 2022-01-11 10:56:29 +01:00
Jan Janssen ed3abbfbde boot: Fix readdir_harder() on VirtualBox
Fixes: #22073
2022-01-10 21:40:52 +01:00
Jan Janssen 9818ec8ea5 boot: Change boot entry sorting
There are a few undesirable properties to how boot entries are
currently sorted.

First, it sorts by entry file name only, which may not correspond
to the title that is shown (for exmaple because it is prefixed by
machine-id). The file ending will also create unexpected ordering
("arch-lts.conf" would come before "arch.conf").

While the list is sorted alphabetically ascending, it is also
lower version/priority first, which is unintuitive. In particular,
a boot-counted entry that is bad (0 tries left) will be at the very
top.

Additionally, the Windows and Mac loaders should be sorted with
the rest of the loaders.
2022-01-10 21:34:12 +01:00
Jan Janssen 661615a0af boot: Add BitLocker TPM key sealing workaround
Fixes: #21891
2022-01-10 16:40:16 +01:00
Jan Janssen a87e9cd79f boot: Add TPM to status info 2022-01-10 16:26:00 +01:00
Jan Janssen b3c5a7074c meson: Use files() for source lists for boot and fundamental
This fixes build reproducibility as otherwise the full path
of the source files ends up in the output binary.
2022-01-09 18:02:34 +01:00
Jan Janssen ad9962bb7e boot: Simplify line_edit 2022-01-06 14:16:34 +01:00
Jan Janssen 6893c4c553 boot: Switch to insertion sort
We can do a little better than bubble sort without ramping up the
code complexity.
2022-01-06 14:16:34 +01:00
Jan Janssen 163d1ea5dd boot: Do more config handling in config_load_all_entries 2022-01-06 14:16:34 +01:00
Jan Janssen b00e37daa6 boot: Remove no_autoselect 2022-01-06 14:16:34 +01:00
Jan Janssen dd4ddc82e6 boot: Close xbootldr root_dir 2022-01-06 14:16:34 +01:00
Jan Janssen a45d4f3543 boot: Simplify config_entry_add_osx 2022-01-06 14:16:34 +01:00
Zbigniew Jędrzejewski-Szmek a8d50a3575 Merge pull request #21981 from medhefgo/boot-cleanup
boot: Cleanup
2022-01-05 12:55:59 +01:00
Yu Watanabe e37d30f334 sd-boot: select newest kernel entry matching with the default glob pattern
This fixes a bug introduced by 0c674ce5f2.

Fixes #22004.
2022-01-05 12:15:24 +01:00
Jan Janssen 948d085e89 boot: Add gdb support and documentation
This will finally allow debugging issues in systemd without resorting to
Print() calls all over the place.
2022-01-04 17:23:01 +01:00
Zbigniew Jędrzejewski-Szmek 5377ad4ea4 fuzz-bcd: silence warning about always-true comparison
Occurs with gcc-11.2.1-7.fc35.x86_64.
2022-01-04 11:49:45 +00:00
Jan Janssen 8fb16fee96 boot: Do not warn if an initializing driver returns EFI_ABORTED
Fixes: #21965
2022-01-03 19:42:36 +01:00
Jan Janssen 7ffc4f4748 boot: Prevent stub command line editing under secure boot 2022-01-03 11:29:49 +01:00
Jan Janssen fb90100cf0 boot: Unify idx type handling
This replaces several inconsistent use of types and unsound
signed comparisons.
The added max entry count is just for paranoia. Anyone with that
many boot entries deserves a medal.
2022-01-03 10:41:45 +01:00
Jan Janssen 159636cf74 boot: Convert goto into loop 2022-01-03 10:20:23 +01:00
Jan Janssen 0b2281a209 boot: Rename cleanup functions 2022-01-03 10:15:24 +01:00
Jan Janssen 75747c8a39 boot: Use objcopy to align sections
Not aligning these can create gaps in the section table. Some
firmware does not handle this nicely resulting in secure boot
signature fails.
Using objcopy ensures that any new sections in the future will be
properly aligned.

Fixes: #21956
2022-01-02 19:58:56 +01:00
Yu Watanabe 3c80c7bacf Merge pull request #21928 from medhefgo/boot-meson
meson: Boot
2022-01-02 23:40:46 +09:00
Jan Janssen 2f2b072267 meson: Get objcopy location from compiler 2022-01-02 10:18:26 +01:00
Jan Janssen 52adf0e91e meson: Remove efi-cc option
Changing the efi compiler this way doesn't really work. The gnu-efi
header checks as well as supported compiler flag checks use the
regular cc that meson detects. Changing the compiler this way will
end up with bad compiler flags. For the very same reason, this does
not work with a cross-compiler without going through proper meson
cross-compilation steps either.

The proper way to build systemd-boot with a different compiler is to
use a different build folder and then just use the proper ninja build
target to only build the bootloader/stub.
2022-01-02 10:18:26 +01:00
Jan Janssen aa1d0f2587 boot: Introduce helper macros for offset checking
This fixes a subtle sizeof overflow on 32bit machines.
2021-12-29 14:39:54 +01:00
Jan Janssen 1cadb35fd6 boot: Reject unaligned data
The data seems to be properly aligned in real BCD stores, so it
should be fine to just reject bad ones.

Fixes: #21917
2021-12-29 14:39:54 +01:00
Jan Janssen 77fcf28cb8 boot: Build BCD parser only on arches supported by Windows 2021-12-29 14:39:54 +01:00
Evgeny Vereshchagin 4b65fc8725 tests: add fuzz-bcd 2021-12-29 10:39:06 +00:00
ksa678491784 5204355861 stub: Do not assume having DeviceHandle 2021-12-29 11:59:57 +09:00
Jan Janssen 2198a77391 boot: Fix name length comparison 2021-12-27 22:49:02 +01:00
Jan Janssen c3c5b93a0c boot: Fix off-by-one offset sanity checks 2021-12-27 22:46:40 +01:00
Jan Janssen fab8275646 boot: Fix off-by-one NUL-termination 2021-12-27 22:41:50 +01:00
Yu Watanabe 3e7bf8535f tree-wide: fix typo 2021-12-25 18:32:22 +09:00
Zbigniew Jędrzejewski-Szmek e4e44a0107 meson: report SBAT settings 2021-12-23 20:06:17 +01:00
Zbigniew Jędrzejewski-Szmek 3f871f1205 meson: move efi summary() section to src/boot/efi
This way we can add the entries more naturally in the same place where
they are defined.
2021-12-23 13:52:33 +01:00
Zbigniew Jędrzejewski-Szmek 65dcf9f9a0 meson: move efi file lists closer to where they are used
The goal is to have the detection of features and paths done first, and
then the build target constructions second.
2021-12-23 13:52:33 +01:00
Jan Janssen e628944b11 boot: Use correct handle to find TextInputEx protocol
LibLocateProtocol will return the protocol for the first device that
supports it. But it may not actually come from the ConIn device that
we want to use here.

This should be the root cause of what was previously considered just
broken firmware. If you ask the wrong device to return some key, of
course it will never provide one.

This changes the way we handle input yet again in light of this new
knowledge and because using the correct TextInputEx with fallback to
ConIn can actually create double input in some cases.

Since we are now confident that we get the right TextInputEx, we can
use that exclusively, only falling back to ConIn if the console input
device does not support the better interface (the spec is pretty clear
that it must support it, though).

Because some firmware is broken, we still need to provide a fallback
to the previously used TextInputEx thats overrides ConIn/ConInEx if
it is functional.
2021-12-23 12:39:48 +01:00
Yu Watanabe 8f7a0fcbec meson: fix typo 2021-12-23 17:01:55 +09:00
Jan Janssen 2ef28d054d boot: Use -fvisibility=hidden instead of -fwhole-program
It's functionally the same for sd-boot, but using visibilty
is generally preferred over whole-program.
2021-12-23 00:26:25 +09:00
Jan Janssen e67e6691e5 boot: Fix armhf build failure
Fixes: #21842
2021-12-21 16:34:51 +00:00
Zbigniew Jędrzejewski-Szmek 1ff493d5c1 bootctl: deprecate --make-machine-id-directory=auto
Now that kernel-install creates the machine-id directory, we don't need to do
this is 'bootctl install', and in fact it's better not to do this since it
might never be necessary. So let's change the default behaviour to 'no'.

I kept support for 'auto' to maintain backwards compatibility, even though the
default was changed. Previous behaviour can be requested by specifying
--make-machine-id-directory=auto.
2021-12-17 18:48:08 +01:00
Zbigniew Jędrzejewski-Szmek 47fb161e3a bootctl: write KERNEL_INSTALL_LAYOUT=bls and KERNEL_INSTALL_MACHINE_ID=…
This is a natural extension of d6bce6e224: if we are installing sd-boot, we
want to use the sd-boot layout, so let's write the appropriate
KERNEL_INSTALL_LAYOUT setting. Effectively, if we do 'booctl install',
kernel-install will not autodetect the layout anymore.

And 357376d0bb added support for KERNEL_INSTALL_MACHINE_ID. We need to support
it here too. We both read it, so that we create the right directories, and also
write it if it wasn't written yet and we created some directories using it, so
that kernel-install that is executed later knows the machine-id that matches
the directories we crated.

The code is changed in some places to fail if we can't figure out the current
status. When installing the boot loader it's probably better not to guess.
2021-12-17 18:47:53 +01:00
Yu Watanabe 616f51c16d boot: fix typo 2021-12-17 04:11:41 +09:00
Zbigniew Jędrzejewski-Szmek af3b864d76 Define FOREACH_DIRENT through FOREACH_DIRENT_ALL
As in the previous commit, 'de' is used as the iterator variable name.
2021-12-15 22:50:00 +01:00
Jan Janssen db7f5ab68f test: Add BCD unit test 2021-12-11 21:32:29 +01:00
Jan Janssen 986fd3ebc2 boot: Remove unused memmem_safe 2021-12-11 21:32:29 +01:00
Jan Janssen f7bc0fb35b boot: Add BCD store parser
This replaces the memmem-based approach of finding a suitable title
for the windows boot manager with one that actually parses the BCD
store. It's probably faster but more importantly, it's more correct.

The memmem approach may detect stale title strings that are still
in the file but unused due to the way registry hives are updated.
This approach also allows us to detect if the BCD store is multi-boot
so that we can fall back on the generic one instead.
2021-12-11 21:32:23 +01:00
Jan Janssen 7700e9ba15 boot: Make OFFSETOF lowercase
This is more in line with the userspace offsetof.
2021-12-11 20:50:03 +01:00
Jan Janssen 245e9d55ae boot: Add strncasecmpa helper function 2021-12-11 20:50:03 +01:00