1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-06 13:17:44 +03:00
Commit Graph

656 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
96826c48ad bootctl: do not update sd-boot if it wasn't installed in the first place
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2038289.

(cherry picked from commit 49927ad813)
2022-01-11 20:31:42 +01:00
Zbigniew Jędrzejewski-Szmek
527c9002b5 bootctl: split out the check whether sd-boot is installed
(cherry picked from commit d9f048b5d1)
2022-01-11 20:31:34 +01:00
Jan Janssen
e9a0404b76 boot: Fix readdir_harder() on VirtualBox
Fixes: #22073
(cherry picked from commit ed3abbfbde)
2022-01-11 20:30:40 +01:00
Yu Watanabe
0e29d6ef44 sd-boot: select newest kernel entry matching with the default glob pattern
This fixes a bug introduced by 0c674ce5f2.

Fixes #22004.

(cherry picked from commit e37d30f334)
2022-01-07 15:51:51 +01:00
Jan Janssen
1c4c566d86 boot: Do not warn if an initializing driver returns EFI_ABORTED
Fixes: #21965
(cherry picked from commit 8fb16fee96)
2022-01-04 16:25:33 +01:00
Jan Janssen
2c99c39936 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
(cherry picked from commit 75747c8a39)
2022-01-04 16:24:16 +01:00
Jan Janssen
c926189767 boot: Introduce helper macros for offset checking
This fixes a subtle sizeof overflow on 32bit machines.

(cherry picked from commit aa1d0f2587)
2022-01-04 16:21:14 +01:00
Jan Janssen
d6d97abd78 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
(cherry picked from commit 1cadb35fd6)
2022-01-04 16:21:10 +01:00
ksa678491784
202b1448aa stub: Do not assume having DeviceHandle
(cherry picked from commit 5204355861)
2022-01-04 16:18:09 +01:00
Jan Janssen
630da18817 boot: Fix name length comparison
(cherry picked from commit 2198a77391)
2022-01-04 16:14:18 +01:00
Jan Janssen
a4e4c3377d boot: Fix off-by-one offset sanity checks
(cherry picked from commit c3c5b93a0c)
2022-01-04 16:14:18 +01:00
Jan Janssen
0c7ef2c166 boot: Fix off-by-one NUL-termination
(cherry picked from commit fab8275646)
2022-01-04 16:14:18 +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
Jan Janssen
3af5a8c613 meson: Fix gnu-efi detection for clang
The gnu-efi headers emit some warnings in clang when not compiled with
-ffreestanding. This is normally not an issue for has_header_symbol()
unless meson is run with CFLAGS="-Werror". Note that this differs
from the --werror option, which does not get passed to clang.

Work around this by adding some compile args to the has_header_symbol()
invocation.
2021-12-12 04:31:41 +09:00
Zbigniew Jędrzejewski-Szmek
881ab17ef7
Merge pull request #21570 from AdrianVovk/stub-global-creds
stub: Load credentials from \loader\credentials\*.cred
2021-12-11 15:59:10 +01:00
Jan Janssen
1ad2c76d5d meson: Auto detect efi-ld 2021-12-11 11:29:30 +01:00
Adrian Vovk
f3b6f33387
stub: Load credentials from \loader\credentials\*.cred
Some types of credentials that a user would want to pass
into the initrd do not depend on the specific kernel/initrd
version. For instance, this can include SSH keys, rootfs
encryption keys, dm-integrity keys, and so on. This
introduces a directory where such credentials can be placed
so that any kernel image will load them
2021-12-10 15:56:33 -05:00
Дамјан Георгиевски
12caf72716 bootctl: optionally install .signed efi file
if /usr/lib/systemd/boot/efi/systemd-bootx64.efi.signed exists
install that instead of /usr/lib/systemd/boot/efi/systemd-bootx64.efi

the idea is that SecureBoot tooling can create the efi.signed file
whenever /usr/lib/systemd/boot/efi/systemd-bootx64.efi from the package
is updated.
2021-12-08 22:21:34 +01:00
Adrian Vovk
bf3f4d16d6
stub: Properly null-terminate filenames in pack_cpio_one
Previously, mangle_filename would write the null terminator, but
then wouldn't increment the pointer. Thus, the pad4 call that comes
immediately after mangle_filename would trample over the null
terminator that mangle_filename wrote. Since the padding is all
0s, this happened to work for the filenames it was tested for

However, in some cases, this would cause the pointer to be a different
position than predicted. Basically, the predicted size would be one
byte bigger than the actual size (the missing null terminator). Usually,
this disappeared into the alignment padding at the end of the buffer,
but if the buffer was already unexpectedly aligned (b/c it was a byte
shorter than expected), this would cause assertion failures.

Also, the c_namesize field in the cpio header was incorrect. It
didn't include the null terminator, as required by the spec.
2021-12-08 13:57:01 -05:00
Zbigniew Jędrzejewski-Szmek
3944ef20f5
Merge pull request #21264 from medhefgo/boot-lto
sd-boot: LTO support
2021-12-07 12:58:59 +01:00
Zbigniew Jędrzejewski-Szmek
ed0e6f0f71
Merge pull request #21307 from medhefgo/boot-alloc
sd-boot: Non-failing allocators
2021-12-07 08:20:07 +01:00
Yu Watanabe
a783421498 tree-wide: fix typo 2021-12-02 00:51:02 +09:00
Yu Watanabe
a6f44d610c tree-wide: fix typo 2021-11-30 12:30:07 +00:00
Jan Janssen
0289441e09 sd-boot: Fix assert failure in random-seed.c
Fixes: #21556
2021-11-30 03:10:03 +09:00
Jan Janssen
0a15a824d2 sd-boot: Use non-failing allocators everywhere else 2021-11-29 16:20:45 +01:00
Jan Janssen
ccfbdbdcab sd-boot: Simplify path creation 2021-11-29 16:20:45 +01:00
Jan Janssen
4f94341504 sd-boot: Make stra_to_path/stra_to_str non-failing 2021-11-29 16:20:45 +01:00
Jan Janssen
da76f890aa sd-boot: Use non-failing allocators in boot.c 2021-11-29 16:20:45 +01:00
Jan Janssen
484ddd2926 sd-boot: Add non-failing allocators 2021-11-29 16:20:32 +01:00
Jan Janssen
fd86250c1e sd-boot: Always add TextInputEx to wait queue if available 2021-11-29 14:42:18 +01:00
Jan Janssen
b848b7e166 sd-boot: Add LTO support 2021-11-29 14:41:46 +01:00
Jan Janssen
0e3bcb02d2 sd-boot: Let compiler figure out libgcc location
Since we now let the compiler call the linker for us, we can just
rely on it to find the right (static) libgcc to use.
2021-11-29 14:33:26 +01:00
Jan Janssen
fe330f02df sd-boot: Let the compiler invoke the linker for us
For LTO to work, the linker has to be called with some magic sauce arguments.
And the easiest way to get those is to just let the compiler to the job for us.
2021-11-29 14:24:56 +01:00
Jan Janssen
52ccce6ac5 meson: Rename compile_args to efi_cfalgs
compile_args sounds like it could be used for other targets besides
efi binaries. This also keeps the name in line with efi_ldflags.
2021-11-28 16:22:15 +01:00
Jan Janssen
252b6b1bfd meson: Default to sbat-distro=auto
Any recent shim will refuse starting an image that does not have an sbat section
and will do so with a generic "Security Violation" message. And it is very easy
to forget passing -Dsbat-distro=auto to meson when creating a fresh build dir.

Adding sbat info when shim is not used or secure boot is disabled does not hurt
anyone, so default to auto. This still ensures to not add auto-detected info in
case we are cross building.
2021-11-28 16:20:54 +01:00
Lennart Poettering
ae54abe7fe bootctl: use new red/green check/cross mark helpers at two places 2021-11-23 22:40:15 +01:00
Lennart Poettering
7c248223eb tree-wide: use new RET_NERRNO() helper at various places 2021-11-16 08:04:09 +01:00
Jan Janssen
4cf8a6092e meson: Use fs module
Turns out that meson provides a fs module since 0.53.0, making it unnecessary
to call out to test.
2021-11-14 13:54:27 +09:00