Commit Graph

41359 Commits

Author SHA1 Message Date
chris
b895aa5ff5 send dhcpv6 release when stopping 2023-01-17 21:26:18 +09:00
Dan Streetman
1200777b21 tpm2: replace magic number 2023-01-17 11:04:37 +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
5039eafb9f Merge pull request #26005 from medhefgo/boot-hypervisor
boot: Detect hypervisors using SMBIOS info
2023-01-17 10:53:23 +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
04959faa63 generators: optionally, measure file systems at boot
If we use gpt-auto-generator, automatically measure root fs and /var.

Otherwise, add x-systemd.measure option to request this.
2023-01-17 09:42:16 +01:00
Lennart Poettering
50072ccf1b units: rework growfs units to be just a regular unit that is instantiated
The systemd-growfs@.service units are currently written in full for each
file system to grow. Which is kinda pointless given that (besides an
optional ordering dep) they contain always the same definition. Let's
fix that and add a static template for this logic, that the generator
simply instantiates (and adds an ordering dep for).

This mimics how systemd-fsck@.service is handled. Similar to the wait
that for root fs there's a special instance systemd-fsck-root.service
we also add a special instance systemd-growfs-root.service for the root
fs, since it has slightly different deps.

Fixes: #20788
See: #10014
2023-01-17 09:42:16 +01:00
Lennart Poettering
0ba07f9077 generator: teach generator_add_symlink() to instantiate specified unit
if we want generators to instantiate a template service, we need to
teach generator_add_symlink() the concept.

Just some preparation for a later commit.

While we are at it, modernize the function around
path_extract_filename() + path_extract_directory()
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
ff386f985b gpt-auto-generator: automatically measure root/var volume keys into PCR 15
let's enable PCR 15 measurements automatically if gpt-auto discovery is
used and systemd-stub is also used.
2023-01-17 09:42:16 +01:00
Lennart Poettering
94c0c85e30 cryptsetup: add tpm2-measure-pcr= and tpm2-measure-bank= crypttab options
These options allow measuring the volume key used for unlocking the
volume to a TPM2 PCR. This is ideally used for the volume key of the
root file system and can then be used to bind other resources to the
root file system volume in a secure way.

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
Yu Watanabe
ab250890c0 Merge pull request #26004 from poettering/cleanuo-erase-moar
tree-wide: use CLEANUP_ERASE() at many places
2023-01-17 14:04:02 +09:00
Yu Watanabe
841dfd3dc0 sd-dhcp-client: gracefully handle invalid ether type client ID
Currently, sd-dhcp-server accepts spurious client IDs, then the leases
exposed by networkd may be invalid. Let's make networkctl gracefully
show such leases.

Fixes #25984.
2023-01-16 20:00:08 +00:00
Lennart Poettering
ec56edf55c busctl: simplify peeking the type
let's peek the type before we enter the variant, not after, so that we
can reuse it as-is, instead having to recombine it later.

Follow-up for: #26049
2023-01-16 20:54:44 +01:00
Yu Watanabe
ea9dbf51c6 sd-dhcp6: always append the default status message generated from status code
Fixes #25988.
2023-01-16 19:46:05 +00:00
Yu Watanabe
303dfa73b3 network: fix memleak
Fixes a bug introduced by af2aea8bb6.

Fixes #25883 and #25891.
2023-01-16 19:42:59 +00:00
Luca Boccassi
37df1221d5 Merge pull request #26071 from yuwata/network-dhcp-quick-ack
network: make TCP quick ACK mode for dynamic routes configurable
2023-01-16 19:41:03 +00:00
Luca Boccassi
36c7dcb7fa Merge pull request #26054 from aplanas/fix_user_creds
creds-util: some fixes related with TPM2 and capabilities
2023-01-16 19:40:05 +00:00
Luca Boccassi
9e6b820e8d Merge pull request #26051 from YHNdnzj/systemctl-list-dependencies-type
systemctl: list-dependencies: support --type= and --state=
2023-01-16 19:38:58 +00: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
Lennart Poettering
5040b2cfab memory-util: add CLEANUP_ERASE_PTR() macro and use it 2023-01-16 16:19:07 +01:00
Lennart Poettering
692597c843 tree-wide: use CLEANUP_ERASE() at various places
Let's use this new macro wherever it makes sense, as it allows us to
shorten or clean-up paths, and makes it less likely to miss a return
path.
2023-01-16 15:44:43 +01:00
Daan De Meyer
7ea3f4ff60 Merge pull request #25999 from DaanDeMeyer/mkosi
ci: Update mkosi action to latest commit
2023-01-16 14:24:04 +01:00
David Tardon
218cfe2335 mount: handle bind mount of file with non-existing target
When the target (Where=) of a mount does not exist, systemd tries to
create it. But previously, it'd always been created as a directory. That
doesn't work if one wants to bind-mount a file to a target that doesn't
exist.

Fixes: #17184
2023-01-16 22:16:49 +09:00
Alberto Planas
e37dfcec52 creds-util: merge the TPM2 detection for initrd
This patch merge the TPM2 detection paths when we are inside and outside
an initrd.

Signed-off-by: Alberto Planas <aplanas@suse.com>
2023-01-16 13:40:40 +01:00
Alberto Planas
e653a194e4 creds-util: do not try TPM2 if there is not support
During the credentials encryption, if systemd it is compiled with TPM2
support, it will try to use it depending on the key flags passed.

The current code only checks if the system has a functional TPM2 if the
case of the INITRD flag.

This patch do a similar check in the case that it is outside initrd (but
still automatic).

Signed-off-by: Alberto Planas <aplanas@suse.com>
2023-01-16 13:31:17 +01:00
Alberto Planas
1615578f27 creds-util: check for CAP_DAC_READ_SEARCH
In make_credential_host_secret, the credential.secret file is generated
first as a temporary anonymous file that is later instantiated with
linkat(2).  This system call requires CAP_DAC_READ_SEARCH capability
when the flag AT_EMPTY_PATH is used.

This patch check if the capability is effective, and if not uses the
alternative codepath for creating named temporary files.

Non-root users can now create per-user credentials with:

  export SYSTEMD_CREDENTIAL_SECRET=$HOME/.config/systemd/credential.secret
  systemd-creds setup

Signed-off-by: Alberto Planas <aplanas@suse.com>
2023-01-16 13:31:17 +01:00
Mike Yuan
3729976944 systemctl: list-dependencies: support --type= and --state=
Closes #25975
2023-01-16 19:46:52 +08:00
Mike Yuan
d708293d43 gpt-auto: harden ESP/XBOOTLDR mounts with "noexec,nosuid,nodev"
When these partitions are probed by gpt-auto,
they will always be hardened with such options.

See also: https://github.com/systemd/systemd/issues/25776#issuecomment-1364115711

Closes #25776
2023-01-16 11:15:07 +01:00
Yu Watanabe
f95fb19922 network: introduce QuickAck= for [DHCPv4] and [IPv6AcceptRA]
Closes #25906.
2023-01-16 14:40:22 +09:00
Daan De Meyer
67b65ac62d ukify: Fix version string
Let's make sure we mimick the version of our other CLI tooling.
2023-01-15 22:17:37 +00: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
Yu Watanabe
2cbb171d20 busctl: fix introspecting DBus properties
Follow-up for f2f7785d7a.

Fixes #26033.
2023-01-15 15:39:46 +00:00
Daan De Meyer
85e2e80699 open-file: Fix user-after-free 2023-01-13 17:14:23 +01:00
Mike Yuan
8e481bd292 systemctl: list-dependencies: pass bool where appropriate 2023-01-13 16:15:32 +08:00
Franck Bui
6d90488acb udev: simplify a bit stack_directory_find_prioritized_devnode()
And make the new format the one we expect as it should replace the old one
pretty quickly.
2023-01-13 12:06:00 +09:00
Franck Bui
e8a54a4e75 udev: return ENODEV if link_directory_read_one() can't find the devnode
That's usually the errno code we return when a device cannot be found because
it's been unplugged.
2023-01-13 11:22:31 +09:00
Franck Bui
72a459adc4 udev: let stack_directory_open() convert a slink into a dirname itself
We likely always want to open the directory via a slink.

There's currently only one caller so it doesn't make any difference in practice
but I think it's still nicer.

No functional change.
2023-01-13 11:16:14 +09:00
Franck Bui
c9032f910c udev: merge link_directory_lock() into link_directory_open()
These 2 operations are inseparable.
2023-01-13 11:16:10 +09:00
Ludwig Nussel
e443cc7c05 bootspec: show efi entry too 2023-01-13 10:50:18 +09:00
Michal Koutný
b7a41491ed cgroup: Do not emit compat message without memory limit
Previously mere MemoryLow= directive would lead to emitting the compat
message 'Applying MemoryMax=18446744073709551615 as MemoryLimit=' even
though it carries little information.
2023-01-13 10:48:03 +09:00
Daan De Meyer
5228c58ebe dissect-image: Notify btrfs when we're done using a loop device
Let's explicitly let btrfs know when we're done using a loop device.
Otherwise, btrfs will keep the device UUID cached which will result
in mount() failures if we ever generate a device or filesystem with
the same UUID again.
2023-01-12 16:36:09 +01:00
Zbigniew Jędrzejewski-Szmek
2c281e6db5 Merge pull request #25661 from yuwata/systemctl-suppress-warning
systemctl: suppress warning about missing /proc/ when --no-warn
2023-01-12 08:41:05 +01:00
Daan De Meyer
a2640646f1 network: Show network and link file dropins in networkctl status
Fixes #24428
2023-01-12 13:44:52 +09:00
Alvin Šipraga
9c5b8d46e5 network: fix race between RTM_NEWLINK and NL82011_CMD_NEW_INTERFACE
When a new wireless network interface is created by the kernel, it emits
both RTM_NEWLINK and NL80211_CMD_NEW_INTERFACE. These events can arrive
in either order and networkd must behave correctly in both cases.

The typical case is that RTM_NEWLINK is handled first, in which case
networkd creates a Link object and starts tracking it. When the
NL80211_CMD_NEW_INTERFACE message is handled, networkd then populates
the Link object with relevant wireless properties such as wireless
interface type (managed, AP, etc.).

In the event that the order is reversed however, networkd will fail to
populate these wireless properties because at the time of processing the
nl80211 message, the link is considered unknown. In that case, a debug
message is emitted:

  systemd-networkd[467]: nl80211: received new_interface(7) message for link '109' we don't know about, ignoring.

This is problematic because after the subsequent RTM_NEWLINK message,
networkd will have an incomplete view of the link. In particular, if a
.network configuration matches on some of the missing wireless
properties, such as WLANInterfaceType=, then it will never match.

The above race can be reproduced by using the mac80211_hwsim driver.
Suppose that there exists a .network configuration:

  [Match]
  WLANInterfaceType=ap
  ...

Now loop the creation/destruction of such an AP interface:

  while true
  do
    iw dev wlan0 interface add uap0 type __ap
    iw dev uap0 del
  done

The above debug message from networkd will then be observed very
quickly. And in that event, the .network file will fail to match.

To address the above race, have the nl80211 message handler store the
interface index in a set in case a Link object is not found on
NL80211_CMD_NEW_INTERFACE. The handler for RTM_NEWLINK can then query
this set, and explicitly request the wireless properties from nl80211
upon the creation of the Link object.
2023-01-12 13:28:36 +09:00
chris
ea57796854 optionally set socket priority on DHCPv4 raw socket 2023-01-12 13:26:47 +09:00