1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-24 06:04:05 +03:00

53270 Commits

Author SHA1 Message Date
Benjamin Herrenschmidt
f90eea7d18 virt: Improve detection of EC2 metal instances
The current detection code relies on /sys/firmware/dmi/entries/0-0/raw
to disambiguate Amazon EC2 virtualized from metal instances.

Unfortunately this file is root only. Thus on a c6g.metal instance
(aarch64), we observe something like this:

$ systemd-detect-virt
amazon
$ sudo systemd-detect-virt
none

Only the latter is correct.

The right long term fix is to extend the kernel to expose the SMBIOS BIOS
Characteristics properly via /sys/class/dmi, but until this happens (and
for backwards compatibility when it does), we need a plan B.

This change implements such a workaround by falling back to using the
instance type from DMI and looking at the ".metal" string present on
metal instances.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2021-09-14 01:44:20 +09:00
Lennart Poettering
c116f23394
Merge pull request #20716 from poettering/tpm2-primary-rsa
tpm2: be smarter when picking primary key algorithm and PCR bank
2021-09-13 17:12:20 +02:00
Lennart Poettering
f4529c4d97 update TODO 2021-09-13 15:02:57 +02:00
Lennart Poettering
d38466bae6 tpm2: log about invalid PCRs on each unsealing
Let's log every time we use uninitialized PCRs when unsealing a secret
via TPM2. This indicates a firmware issue usually, and is something we
shouldn't just show when enrolling but also show every time we unseal,
so that the fact that the selected PCR policy is pretty much pointless
is repeatedly shown.
2021-09-13 15:02:53 +02:00
Lennart Poettering
321a9d9ee5 tpm2: check if PCR values make sense before using them
Fixes: #20684
2021-09-13 15:02:53 +02:00
Lennart Poettering
2b92a67261 tpm2: support RSA primary keys as fallback if TPM2 devices don't support ECC
Previously, we hardcoded use of ECC as primary keys, since they are much
faster (i.e. saving multiple seconds) to do TPM2 operations with. Alas,
not all TPM2 chips appear to support ECC. Bummer.

Let's hence add a fallback logic: if we can't create an ECC primary key,
use an RSA key, and store that fact away.

AFIU the security guarantees should be roughly the same, it's just that
RSA primary keys is so much slower to work with than ECC.

The primary key algorithm is used is stored in the JSON header of LUKS
disks, in a new field. If the field is absent we assume to use ECC, to
provide full compatibility with old systemd versions.

The primary key algorithm is stored in a new field in the credentials
file format (in fact, a previously unused zero space is used), too.

Hopefully, this should ensure that TPM2 support will "just work" on more
systems.

Fixes: #20361
2021-09-13 14:48:23 +02:00
Lennart Poettering
3f9992d82e memory-util: replace memeqzero() by a more generic memeqbyte()
The new helper can check for any byte, no just zeroes. The old name is
then converted into a macro that wraps our new version of the helper.
2021-09-13 12:48:27 +02:00
Luca Boccassi
503994bada
Merge pull request #20701 from yuwata/network-address-cleanups
network: several address_update() related cleanups
2021-09-13 11:12:43 +01:00
Yu Watanabe
2d3af41f0e udev-watch: retry to save watch handle with random delay
Also, remove the watch handle if we cannot save it.
2021-09-13 18:53:00 +09:00
Yu Watanabe
20ec7d9ed5 sd-device: do not recreate the same symlinks which store watch handle 2021-09-13 11:54:56 +09:00
Yu Watanabe
d7950621d2
Merge pull request #20715 from yuwata/udev-node-follow-ups
udev-node: several follow-ups
2021-09-13 11:51:55 +09:00
Yu Watanabe
cc8d67af54
Merge pull request #20672 from mrc0mmand/more-storage-tests
test: more storage-related tests
2021-09-13 11:50:51 +09:00
Frantisek Sumsal
35497c7c33 test: coverage for #19946 2021-09-12 18:55:58 +02:00
Frantisek Sumsal
d430e451c9 test: make sure all symlinks under /dev/disk/ are valid 2021-09-12 18:52:56 +02:00
Frantisek Sumsal
d0cbad16c5 test: add a basic multipath test + failover 2021-09-12 18:38:42 +02:00
Frantisek Sumsal
9e7c3bd48c test: add a multipath helper 2021-09-12 18:38:42 +02:00
Frantisek Sumsal
e205ae0d9c test: use one call to install necessary modules 2021-09-12 18:38:42 +02:00
Luca Boccassi
54966b7cee
Merge pull request #20705 from yuwata/test-oomd-util
test: skip oomd test on a unified container on a hybrid host
2021-09-12 12:56:46 +01:00
Anita Zhang
7417f06187 test: tweak parameters for TEST-55-OOMD
Pressure remains > 1% after a kill for some time and could cause
testchill to get killed. Bumping the limit from 1% to 20% should help
with this.

Fixes #20118
2021-09-12 19:16:18 +09:00
Yu Watanabe
0706cdf4ec udev-node: do not ignore unexpected errors on removing symlink in stack directory
Only acceptable error here is -ENOENT.
2021-09-12 16:14:44 +09:00
Yu Watanabe
3df566a667 udev-node: simplify the example of race 2021-09-12 16:05:51 +09:00
Yu Watanabe
ca589b1b41 unit: systemd-oomd.service requires cgroup memory controller 2021-09-12 10:29:29 +09:00
Yu Watanabe
8b2e22579a test-oomd-util: skip tests if cgroup memory controller is not available
Fixes #20593 and #20655.
2021-09-12 10:29:25 +09:00
Yu Watanabe
28fb998615 oomd: refuse to start if cgroup memory controller is not available 2021-09-12 10:28:24 +09:00
Jan Janssen
de829ff593 sd-boot: Fix assertion fail
The UEFI Platform Initialization Specification says that both
parameters may be NULL.
2021-09-11 23:33:17 +09:00
Yu Watanabe
594c383554 cgroup-util: use string_hash_ops_free 2021-09-11 20:29:34 +09:00
Yu Watanabe
dccdbf9b35 cgroup-util: use _cleanup_free_ attribute 2021-09-11 20:26:58 +09:00
Anatol Pomozov
d2bf22fb8d tpm-util: fix TPM parameter handling
cryptenroll allows to specify a custom TPM driver separated from
parameters with colon e.g. `systemd-cryptenroll --tpm2-device=swtpm:`
tells to load swtpm tss driver and use it as a device.

Unfortunately it does not work, swtpm driver init() fails with

```
debug:tcti:src/tss2-tcti/tcti-swtpm.c:570:Tss2_Tcti_Swtpm_Init() Dup'd conf string to: 0x562f91cbc000
debug:tcti:src/util/key-value-parse.c:85:parse_key_value_string() parsing key/value: swtpm:
WARNING:tcti:src/util/key-value-parse.c:50:parse_key_value() key / value string is invalid
Failed to initialize TCTI context: tcti:A parameter has a bad value
```

It turns out that cryptenroll suppose to use the driver name internally
and strip it before passing the rest of parameters to init() function.
Without doing it swtpm receives incorrect key-value property and gets
confused.

Fix it by passing the correct parameter (without driver name) to the
init() function.

Fixes #20708
2021-09-11 15:32:17 +09:00
Yu Watanabe
ecedc48b19 network: do not drop IPv6LL address in link_drop_addresses() 2021-09-11 10:49:11 +09:00
Yu Watanabe
981fab5d0a network: always call address ready callback if address is ready
The address ready callback is used for cleaning up old addresses or
routes acquired by e.g. DHCP. However, the callback was called only
when the address was previously not ready. So, maybe, unnecessary
addresses or routes may not be cleared.

Also, this makes the callback is called slightly earlier. As it may
remove several addresses or routes, and possibly changes the link state.
2021-09-11 10:49:11 +09:00
Yu Watanabe
18d8a33a37 network: define Address earlier
As the type is used in defining address_ready_callback_t.
2021-09-11 10:49:11 +09:00
Yu Watanabe
7657ec3eb8 network: store IPv6LL address even if link is in failed state
Otherwise, if IPv6LL is received when the link is in failed state,
we may fail to reconfigure the link.
2021-09-11 10:49:11 +09:00
Yu Watanabe
7a8685ffef network: enable IP masquerade when address is assigned
Previously, IP masquerade is enabled when configuring the address. But,
the request of assigning the address may be refused by kernel.
2021-09-11 10:49:11 +09:00
Yu Watanabe
2c40a8895e network: simplify code a bit 2021-09-11 10:49:11 +09:00
Luca Boccassi
c54e851acb
Merge pull request #20699 from yuwata/network-drop-foreign
network: do not drop foreign configs when carrier of unmanaged interface is lost
2021-09-10 21:10:58 +01:00
Luca Boccassi
992fccd411
Merge pull request #20702 from yuwata/network-trivial-cleanups
network: several trivial cleanups
2021-09-10 21:10:40 +01:00
Yu Watanabe
160203e974 network: fix handling of network interface renaming
Fixes #20657.
2021-09-10 20:49:05 +02:00
Lennart Poettering
034d45d021
Merge pull request #20703 from poettering/gpt-dissect-tweaks
dissect: various small tweaks/tougher checks/refactoring of GPT dissection code
2021-09-10 20:48:31 +02:00
Daan De Meyer
a4303b4096 core: Parse log environment settings again after applying manager environment
Currently, SYSTEMD_LOG_LEVEL set in the ManagerEnvironment property in system.conf
or user.conf doesn't affect the manager's logging level. Parsing the logging environment
variables again after pushing the manager environment into the process environment
block makes sure any new environment changes also get taken into account for logging.
2021-09-10 14:03:55 +01:00
Lennart Poettering
f9e0bb6167 dissect-image: replace redundant if check by assert()
We know that the designator can only be USR or ROOT (or negative), hence
let's test that with an assert here, instead of doing an if check.
2021-09-10 14:16:00 +02:00
Lennart Poettering
1903defc2d dissect-image: insist that if a verity partition designator is specified the partition exists
Let's tighten our checks further.
2021-09-10 14:15:55 +02:00
Lennart Poettering
7b32164f3c dissect-image: tighten checks on root + /usr/ combinations
Our code logic doesn't support images with two verity partitions at the
moment, hence refuse this early (with ENOTUNIQ)

Also, go even further and refuse any combinations of verity enabled root
with verity-less /usr, simplify because that is unsafe and defeats the
point of verity. (i.e. we want to give the guarantee that for
auto-discovered verity magic we guarantee that the data afterwards
available in /usr is safe).
2021-09-10 14:15:50 +02:00
Lennart Poettering
ab5b2787fb dissect-image: drop redundant check
We already check whether we discovered a /usr verity partition without a
/usr partition when initially mangling the partitions, a bunch of lines
further up, no need to repeat this here.
2021-09-10 14:15:46 +02:00
Lennart Poettering
00a8b34fa7 dissect-image: don't do generic root partition fallback if verity is requested for /usr 2021-09-10 14:15:41 +02:00
Lennart Poettering
cb241a69e3 dissect-image: insist that the architecture matches if both root and /usr partitions are found 2021-09-10 14:15:36 +02:00
Lennart Poettering
4ab51780c3 dissect-image: mangle discovered /usr/ partition data, even if we found a root partition
Previously, we'd clean up discovered /usr/ partition data only if we did
not find a root partition. Given that we allow combinations of root and
/usr partitions clean things up in both cases however.
2021-09-10 14:15:32 +02:00
Lennart Poettering
0903fd2683 dissect-image: refuse external verity data in partitioned mode
Our code doesn't support setting up verity with an external verity data
file unless we operate in non-partitioned mode. Let's refuse this
clearly and early if attempted anyway.
2021-09-10 14:15:27 +02:00
Lennart Poettering
e0d53d5291 dissect-image: also derive read-only mode from fstype in non-partitioned mode
For the GPT partitioned logic we also consult the fstype to determine whether
a partition is read-only (i.e. squashfs is already read-only). For the
non-partitioned mode we didn't do that so far. Fix that.
2021-09-10 14:15:22 +02:00
Lennart Poettering
a0bff7ea4c dissect-image: tighten assertion checks on verity data 2021-09-10 14:15:18 +02:00
Lennart Poettering
495367666b dissect-image: rename dissected_image_has_verity()/_can_do_verity()
Let's also pick more precise names for these helpers that are used for
the tabular output: one checks whether a partition is candidate for
verity at all, and the other checks if it is ready to be used for it.
Let's make this clearer in the name.
2021-09-10 14:15:00 +02:00