Commit graph

58990 commits

Author SHA1 Message Date
Gio 2d2efed2ee
Added DERE DBook D10 (#24173)
* Added DERE DBook D10
2022-08-03 09:26:03 +01:00
Vincent Dagonneau e6b0cfad51 This patch adds support for enrolling secure boot boot keys from sd-boot.
***DANGER*** NOTE ***DANGER***

This feature might result in your device becoming soft-brick as outlined
below, please use this feature carefully.

***DANGER*** NOTE ***DANGER***

If secure-boot-enrollment is set to no, then no action whatsoever is performed,
no matter the files on the ESP.

If secure boot keys are found under $ESP/loader/keys and secure-boot-enrollment
is set to either manual or force then sd-boot will generate enrollment entries
named after the directories they are in. The entries are shown at the very bottom
of the list and can be selected by the user from the menu. If the user selects it,
the user is shown a screen allowing for cancellation before a timeout. The enrollment
proceeds if the action is not cancelled after the timeout.

Additionally, if the secure-boot-enroll option is set to 'force' then the keys
located in the directory named 'auto' are going to be enrolled automatically. The user
is still going to be shown a screen allowing them to cancel the action if they want to,
however the enrollment will proceed automatically after a timeout without
user cancellation.

After keys are enrolled, the system reboots with secure boot enabled therefore, it is
***critical*** to ensure that everything needed for the system to boot is signed
properly (sd-boot itself, kernel, initramfs, PCI option ROMs).

This feature currently only allows loading the most simple set of variables: PK, KEK
and db.

The files need to be prepared with cert-to-efi-sig-list and then signed with
sign-efi-sig-list.

Here is a short example to generate your own keys and the right files for
auto-enrollement.

`
keys="PK KEK DB"
uuid="{$(systemd-id128 new -u)}"
for key in ${keys}; do
	openssl req -new -x509 -subj "/CN=${key}/ -keyout "${key}.key" -out "${key}.crt"
	openssl x509 -outform DER -in "${key}.crt" -out "${key}.cer"
	cert-to-efi-sig-list -g "${uuid}" "${key}.crt" "${key}.esl.nosign"
done

sign-efi-sig-list -c PK.crt -k PK.key PK PK.esl.nosign PK.esl
sign-efi-sig-list -c PK.crt -k PK.key KEK KEK.esl.nosign KEK.esl
sign-efi-sig-list -c KEK.crt -k KEK.key db db.esl.nosign db.esl
`

Once these keys are enrolled, all the files needed for boot ***NEED*** to be signed in
order to run. You can sign the binaries with the sbsign tool, for example:

`
sbsign --key db.key --cert db.crt bzImage --output $ESP/bzImage
`

Example:

Assuming the system has been put in Setup Mode:

`
$ESP/loader/keys/auto/db.esl
$ESP/loader/keys/auto/KEK.esl
$ESP/loader/keys/auto/PK.esl
$ESP/loader/keys/Linux Only/db.esl
$ESP/loader/keys/Linux Only/KEK.esl
$ESP/loader/keys/Linux Only/PK.esl
$ESP/loader/keys/Linux and Windows/db.esl
$ESP/loader/keys/Linux and Windows/KEK.esl
$ESP/loader/keys/Linux and Windows/PK.esl
`

If auto-enroll is set, then the db, KEK and then PK are enrolled from the 'auto'
directory.

If not, three new boot entries are available to the user in order to enroll either the
'Linux Only', 'Linux And Windows' or 'auto' set of keys.
2022-08-03 10:11:08 +02:00
Einsler Lee 9e6e3379ba "auto" is the default LogTarget of user service manager
"auto"  (not console) is the default LogTarget of user service manager.
2022-08-03 09:49:35 +02:00
Einsler Lee 2a646b1d62 main: reopen /dev/console for user service manager
Now the console_fd of user service manager is 2. Even if LogTarget=console is set in /etc/systemd/user.conf,there is no log in the console.
This reopen the /dev/console, so the log of user service can be output in the console.
2022-08-03 09:48:25 +02:00
Frantisek Sumsal d2efca1c12
Merge pull request #24178 from mrc0mmand/libgcc_s
test: install libgcc_s.so.1 explicitly if available
2022-08-03 07:22:19 +00:00
Lennart Poettering 157cb4337b systemctl: clarify that "status" is about the most recent invocation of a service
And point people to "journalctl --unit=" for information of prior runs.

Inspired by: #24159
2022-08-03 09:10:07 +02:00
Lennart Poettering 38f81e9374 repart: when keeping ref to backing inode/devnode, use fd_reopen() rathern than F_DUPFD
Via the "backing_fd" variable we intend to pin the backing inode through
our entire code. So far we typically created the fd via F_DUPFD_CLOEXEC,
and thus any BSD lock taken one the original fd is shared with our
backing_fd reference. And if the origina fd is closed but our backing_fd
is not, we'll keep the BSD lock open, even if we then reopen the block
device through the backing_fd. If hit, this results in a deadlock.

Let's fix that by creating the backing_fd via fd_reopen(), so that the
locks are no longer shared, and if the original fd is closed all BSD
locks on it that are in effect are auto-released.

(Note the deadlock is only triggered if multiple operations on the same
backing inode are executed, i.e. factory reset, resize and applying of
partitions.)

Replaces: #24181
2022-08-03 09:09:04 +02:00
Daan De Meyer a268e7f402 mkosi: Update to latest
Fixed centos stream 8 builds that were hitting a nonexisting mirror
url
2022-08-02 20:19:21 +01:00
Lennart Poettering dec6f61928 update TODO 2022-08-02 20:01:59 +02:00
Lennart Poettering 71c943dc40 mountpoint-util: make fd_is_mountpoint() work reasonably with AT_EMPTYPATH
Inspired by: https://github.com/systemd/systemd/pull/24141

Calling fd_is_mountpoint() with AT_EMPTYPATH and an empty filename can
only work if we have new statx() available. If we do not, we can still
make things work for directories, but not for other inodes (since there
we cannot query information about the parent inode to compare things.)

Hence, let's handle and test this explicitly, to support this to the
level this is possible.
2022-08-02 20:01:59 +02:00
Jacek Migacz ff0a5070d4 resolved: fix single-label resolution over DNS
Fixes: #23494 (when ResolveUnicastSingleLabel=yes)
2022-08-02 19:21:46 +02:00
Frantisek Sumsal 134d4f1b9d test: be a bit more verbose about shared library symlinks
For example:
```
D: Installing /usr/lib64/libz.so.1.2.11
D: Creating symlink /usr/lib64/libz.so.1.2.11 -> /usr/lib64/libz.so.1
D: Creating extra symlink: /lib64/libz.so
D: Installing /usr/lib64/libgcc_s-12-20220507.so.1
D: Creating symlink /usr/lib64/libgcc_s-12-20220507.so.1 -> /usr/lib64/libgcc_s.so.1
```
2022-08-02 18:28:43 +02:00
Frantisek Sumsal 5f347d3160 test: install libgcc_s.so.1 explicitly if available
Since the library is dlopen()ed by libpthread and required during
pthread_exit()/pthread_cancel(), let's install it explicitly if available to
avoid unexpected fails in tests. This also consolidates all related
workarounds for this library across the test scripts.
2022-08-02 18:28:35 +02:00
Luca Boccassi 675a644de2
Merge pull request #24146 from poettering/efi-stub-measure-payload
stub: measure kernel/initrd/parameters into clean PCRs 11/12/13, and add "systemd-measure" tool to be able to pre-calculate values
2022-08-02 14:42:33 +01:00
Lennart Poettering 7f8258b4a3 update TODO 2022-08-02 14:01:37 +02:00
Daan De Meyer 859614439a mkosi: Update to latest commit
With this update, Arch Linux keyring updates will be automatically
pulled in instead of having to update to a new mkosi commit every
time the keyring gets outdated.
2022-08-02 12:58:31 +02:00
Lennart Poettering c0a74f6286 update TODO 2022-08-02 10:29:04 +02:00
Lennart Poettering 984638cde7 test: add trivial test for systemd-measure 2022-08-02 10:28:49 +02:00
Lennart Poettering ca1092dc15 measure: add new tool to precalculate PCR values for a kernel image
For now, this simply outputs the PCR hash values expected for a kernel
image, if it's measured like sd-stub would do it.

(Later on, we can extend the tool, to optionally sign these
pre-calculated measurements, in order to implement signed PCR policies
for disk encryption.)
2022-08-02 10:28:49 +02:00
Lennart Poettering 51470e1e56 bootctl: suppress "Boot Loaders Listed in EFI Variables" section header if section empty
Some more cosmetics.
2022-08-02 10:28:49 +02:00
Lennart Poettering 84be9b63eb bootctl: prettify tree output of discovered boot loaders a bit
Previously, the tree output of discovered boot laoders in the ESP would
look like this:

Available Boot Loaders on ESP:
          ESP: /efi (/dev/disk/by-partuuid/0c6f41ed-2573-4723-8c84-23681f9d1c28)
         File: └─/EFI/systemd/systemd-bootx64.efi (systemd-boot v250.7-1.fc36)
         File: └─/EFI/BOOT/BOOTX64.EFI (systemd-boot v250.7-1.fc36)

With this change the tree branches are corrected to look like this:

Available Boot Loaders on ESP:
          ESP: /efi (/dev/disk/by-partuuid/0c6f41ed-2573-4723-8c84-23681f9d1c28)
         File: ├─/EFI/systemd/systemd-bootx64.efi (systemd-boot v250.7-1.fc36)
               └─/EFI/BOOT/BOOTX64.EFI (systemd-boot v250.7-1.fc36)

Ahhh! So much nicer. This incorrect tree drawing has been bugging me for
so long. Finally I can sleep at night again!
2022-08-02 10:28:49 +02:00
Lennart Poettering cb180369f1 bootctl: underline sections in status output
Let's give the output a bit more structure, inspired by the way our
newer --help texts use underlining to separate out sections a bit.
2022-08-02 10:28:49 +02:00
Lennart Poettering 257bc3ef60 boot: add hexdump helper call
This is not actually used (or even supposed to be used) in clean
codepaths, but is tremendously useful when verifying things work
correctly, as a debugging tool.
2022-08-02 10:28:49 +02:00
Lennart Poettering a67f22c4a7 boot: add three new boot loader feature flags
Report whether the devicetree + sort-key boot loader spec type #1
fields are supported, and whether the "@saved" pseudo-entry is
supported.

Strictly speaking, thes features have been added in versions that are
already released (250+), so by adding this those version even though
they support the features will be considered not supporting them, but
that should be OK (the opposite would be a problem though, i.e. if we'd
assume a boot loader had a feature it actually does not).

These three features are features relevant to userspace, as it allows
userspace to tweak/genereate BLS entries or set EFI vars correctly.
Other features (i.e. that have no impliciations to userspace) are not
reported.
2022-08-02 10:28:49 +02:00
Lennart Poettering 6977ea9975 bootctl: show stub feature set in status output 2022-08-02 10:28:49 +02:00
Lennart Poettering 03d5449f3a stub: clean up kernel command line when converting to ASCII
Let's be a bit more careful when converting the UTF-16 cmdline to ASCII.
Let's convert all characters out of the printable ASCII range to spaces,
instead of blindly relying on C's downcasting behaviour.
2022-08-02 10:28:49 +02:00
Lennart Poettering 46d336722d stub: introduce StubFeatures, similar to LoaderFeatures
systemd-boot reports its features via the LoaderFeatures EFI variable.
Let's add something similar for stub features, given they have been
growing.

For starters only define four feature flags. One is a baseline feature
we pretty much always supported (see comment in code), two are features
added in one of the most recently released systemd version, and the
final one, is a feature we added a few commits ago.

This is useful for userspace to figure out what is supported and what
not.
2022-08-02 10:28:49 +02:00
Lennart Poettering 6017eee9ce boot: move unified kernel PE section definitions into 'fundamental' code
Le's share this code between userspace and uefispace. This is useful
later when pre-measuring expected PCRs from userspace.
2022-08-02 10:28:49 +02:00
Lennart Poettering aa323c0907 boot: split out TPM PCR defines into header file we can share between userspace and kernel space 2022-08-02 10:28:49 +02:00
Lennart Poettering de7ad6d4f4 sd-stub: measure sysext images picked up by sd-stub into PCR 13
Let's grab another so far unused PCR, and measure all sysext images into
it that we load from the ESP. Note that this is possibly partly redundant,
since sysext images should have dm-verity enabled, and that is hooked up
to IMA. However, measuring this explicitly has the benefit that we can
measure filenames too, easily, and that all without need for IMA or
anything like that.

This means: when booting a unified sd-stub kernel through sd-boot we'll
now have:

1. PCR 11: unified kernel image payload (i.e. kernel, initrd, boot
   splash, dtb, osrelease)

2. PCR 12: kernel command line (i.e. the one embedded in the image, plus
   optionally an overriden one) + any credential files picked up by
   sd-stub

3. PCR 13: sysext images picked up by sd-stub

And each of these three PCRs should carry just the above, and start from
zero, thus be pre-calculatable.

Thus, all components and parameters of the OS boot process (i.e.
everything after the boot loader) is now nicely pre-calculable.

NOTE: this actually replaces previous measuring of the syext images into
PCR 4. I added this back in 845707aae2,
following the train of thought, that sysext images for the initrd should
be measured like the initrd itself they are for, and according to my
thinking that would be a unified kernel which is measured by firmware
into PCR 4 like any other UEFI executables.

However, I think we should depart from that idea. First and foremost
that makes it harder to pre-calculate PCR 4 (since we actually measured
quite incompatible records to the TPM event log), but also I think
there's great value in being able to write policies that bind to the
used sysexts independently of the earlier boot chain (i.e. shim, boot
loader, unified kernel), hence a separate PCR makes more sense.

Strictly speaking, this is a compatibility break, but I think one we can
get away with, simply because the initrd sysext images are currently not
picked up by systemd-sysext yet in the initrd, and because of that we
can be reasonably sure noone uses this yet, and hence relies on the PCR
register used. Hence, let's clean this up before people actually do
start relying on this.
2022-08-02 10:28:49 +02:00
Lennart Poettering 16700cb85a stub: measure PE sections in a defined order, and include all sections 2022-08-02 10:28:49 +02:00
Lennart Poettering 72c97c19c3 efi: from the stub measure the ELF kernel + built-in initrd and so on into PCR 11
Here we grab a new – on Linux so far unused (by my Googling skills, that
is) – and measure all static components of the PE kernel image into.
This is useful since for the first time we'll have a PCR that contains
only a PCR of the booted kernel, nothing else. That allows putting
together TPM policies that bind to a specific kernel (+ builtin initrd),
without having to have booted that kernel first. PCRs can be
pre-calculated. Yay!

You might wonder, why we measure just the discovered PE sections we are
about to use, instead of the whole PE image. That's because of the next
step I have in mind: PE images should also be able to carry an
additional section that contains a signature for its own expected,
pre-calculated PCR values. This signature data should then be passed
into the booted kernel and can be used there in TPM policies. Benefit:
TPM policies can now be bound to *signatures* of PCRs, instead of the
raw hash values themselves. This makes update management a *lot* easier,
as policies don't need to be updated whenever a kernel is updated, as
long as the signature is available. Now, if the PCR signature is
embedded in the kernel PE image it cannot be of a PCR hash of the kernel
PE image itself, because that would be a chicken-and-egg problem. Hence,
by only measuring the relavent payload sections (and that means
excluding the future section that will contain the PCR hash signature)
we avoid this problem, naturally.
2022-08-02 10:28:49 +02:00
Lennart Poettering 599fe002a1 efi: tell userspace where the stub measured the kernel command line/credentials into
This is useful for userspace to know, so that policies can be put
together safely, matching what the stub actually measured.
2022-08-02 10:28:49 +02:00
Lennart Poettering 8d5e4d59f2 efi: optionally report when measuring to TPM whether we actually did
the measurement calls can succeed either when they actually measured
something, or when they skipped measurement because the local system
didn't support TPMs.

Let's optionally return a boolean saying which case it is. This is later
useful to tell userspace how and if we measured something.
2022-08-02 10:28:49 +02:00
Lennart Poettering c794e280e9 update TODO 2022-08-02 10:28:15 +02:00
Yu Watanabe ee5cde205c
Merge pull request #24174 from yuwata/network-link-local-address
network: fix link local address handling
2022-08-02 12:56:01 +09:00
Yu Watanabe e4e0b239f6 test-network: add test case for #23197 2022-08-02 03:43:04 +09:00
Yu Watanabe bd7e0a3f1c network: make link_may_have_ipv6ll() optionally check Multicast= setting
Fixes the IPv6LL issue in #23197.
2022-08-02 03:35:00 +09:00
Yu Watanabe 5fb5fae933 network: fix possible NULL-pointer dereference 2022-08-02 03:32:55 +09:00
Yu Watanabe e0c0cd49e5 network: do not try to start ipv4acd on non-supported interfaces
Fixes IPv4LL issue reported in #23197.
2022-08-02 03:06:21 +09:00
Yu Watanabe 29104ded1c network: split link_ipv4ll_enabled() into two
And move it from networkd-link.[ch] to relevant files.
2022-08-02 03:02:48 +09:00
Yu Watanabe 2d3d0e8f7d network: drop doubled semicolon 2022-08-02 02:44:37 +09:00
Yu Watanabe 5162b2a1c4 tree-wide: fix typo 2022-08-02 02:43:38 +09:00
dependabot[bot] bc4b9a7117 build(deps): bump meson from 0.62.2 to 0.63.0 in /.github/workflows
Bumps [meson](https://github.com/mesonbuild/meson) from 0.62.2 to 0.63.0.
- [Release notes](https://github.com/mesonbuild/meson/releases)
- [Commits](https://github.com/mesonbuild/meson/compare/0.62.2...0.63.0)

---
updated-dependencies:
- dependency-name: meson
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-01 14:06:32 +00:00
James Hilliard 6e8b2a71c7 bpf: set gcc std and compile flags
This should make gcc bpf compilation more reliable.
2022-08-01 21:35:44 +09:00
dependabot[bot] c3ebbcf7cb build(deps): bump github/codeql-action from 2.1.15 to 2.1.17
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.1.15 to 2.1.17.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](3f62b754e2...0c670bbf04)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-01 11:17:18 +00:00
dependabot[bot] cc7f5ac478 build(deps): bump github/super-linter from 4.9.4 to 4.9.5
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.9.4 to 4.9.5.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](a320804d31...2d64ac1c06)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-01 11:10:08 +00:00
dependabot[bot] fdf38c0f1f build(deps): bump actions/setup-node from 3.3.0 to 3.4.1
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3.3.0 to 3.4.1.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](eeb10cff27...2fddd8803e)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-01 10:06:54 +00:00
Cristian Rodríguez 91375fb9cf
gcrypt: switch to system rng before gcry_check_version (#24162)
Current docs claim this must be done before gcry_check_version.
2022-08-01 14:04:27 +09:00
Joaquín Ignacio Aramendía e18569cc72 Add ACCEL_MOUNT_MATRIX for OXP Mini 2022-07-31 13:50:27 +09:00