Commit Graph
87438 Commits
Author SHA1 Message Date
Lennart Poettering 96bb950ffa pcrlock: deal with firmwares which understand TPM but where no TPM is available
This is a potentially common case in VMs: firmwares might know the
concept of TPMs, but the hardware is not enabled in the specific VM.
Let's handle this case nicely.
2026-03-26 16:11:34 +01:00
Lennart Poettering 1494cb04ea pcrlock: don't fail if firmware measurements aren't available
With swtpm in place we now commonly have systems where TPM is available
during runtime, but not in the firmware. Handle that nicely.
2026-03-26 16:11:34 +01:00
Lennart Poettering cd911bec6e core: introduce ConditionSecurity=measured-os
So far we always conditioned our TPM magic on the UKI having detected
TPM support in the firmware. This is a bit limiting when we want to
support a software TPM that is not visible to the firmware. Hence let's
split this up, and add a separate control that can be set via the kernel
command line.  However, as before, let's by default inherit the firmare
TPM discovery state into it, to retain the current behaviour unless
overriden.

With this in place, boot with "systemd.tpm2_measured_os=1
systemd.tpm2_software_fallback=1" on the kernel cmdline to get the swtpm
fallback and then a measured OS based on it.
2026-03-26 16:11:34 +01:00
Lennart Poettering ca03d178a0 tree-wide: relax TPM available checks for many cases
In many cases it's essential to know if the firmware supports a TPM, but
in others we should accept it if the firmware doesn't have TPM support,
in particular if we want to run the OS with a software TPM.

Hence, add tpm2_is_mostly_supported() as function similar to
tpm2_is_fully_supported(), with the only difference that the former
doesn't insist on a firmware supported TPM. Then, change a number of
users over to this (but not all).
2026-03-26 16:11:34 +01:00
Lennart Poettering 750795d103 tpm2-generator: if requested run things with an swtpm
We want to start the software TPM fallback only if no real hw is
evailable and if the user opts-in to this behaviour. Add a generator
that drives all this, based on kernel command line configuration.
2026-03-26 16:11:34 +01:00
Lennart Poettering 056c21aaeb tpm2: add "systemd-tpm2-swtpm" wrapper for "swtpm"
For TPM-less systems it's sometimes valuable to have a fill-in software
TPM running from early boot on, so that TPM-based functionality can
"just work" and rely on TPM semantics, even if it's at a substantially
weaker security level.

This adds a wrapper around swtpm. It's a binary that chainloads swtpm
but does a few preparatory steps and integrates into systemd's logic
otherwise.

All this is then exposed as systemd-tpm2-swtpm.service.

The service is not hooked into much yet, that is added in later commits.
2026-03-26 16:11:34 +01:00
Lennart Poettering 6718ba1769 gpt-auto-generator: generate an initrd ESP mount if it makes sense
We need to store state persistently for the software TPM (i.e. the root
key). But given that TPMs are generally used to unlock the rootfs, this
storage cannot be on the rootfs. Hence let's use the ESP instead, as the
next best thing, that is guaranteed to exist during early boot, given we
just were booted from it.

This defines automatic logic for this, but does not cause the ESP mount
job to be enqueued (since typically we don't actually want that
mounted), this is left for the actual services that needs to be done.

Note that the mount here is set up quite differently from the one from
the host: since initrds are short-lived anyway, it seemed pointless to
use autofs. Moreover this uses a fixed place to mount the ESP, inspired
by the /sysroot/ + /sysusr/ mount naming. All that to simplify things a
bit for the consumers (which is mostly swtpm)
2026-03-26 14:34:56 +01:00
Lennart Poettering 23b4c833a4 fileio: add WRITE_DATA_FILE_MODE_0400 mode 2026-03-26 14:34:56 +01:00
Cynthia 0c2747e789 kernel-install(uki): filter comments from cmdline
This change aligns the behaviour of UKI generation with the behaviour
of BLS. The latter filters out lines starting with a #, allowing users
to add comments and/or temporarily remove some flags from the kernel
command line.

The kernel-install test have been adjusted to use a multiline cmdline
with a comment in it. Without this patch, the test fails.
2026-03-26 14:28:22 +01:00
Zbigniew Jędrzejewski-Szmek 1cf9e4e25e Basic IMDS support (#40980)
This adds a new cloud IMDS client, that can cover AWS, Azure, GCP,
Hetzner imds to varying degrees. Each cloud has this and it's very basic
functionality, hence I think it makes sense to add this to systemd.

Since the clouds are all different this tries hard to do the abstract
common logic in code, but encode the endpoint details, and well-known
keys in hwdb, attached to the DMI id device.

Why all this?

* Efficiency: we can schedule this in the initrd, at the earliest points
possible, without unnecessary delays
* Robustness: imds is typically slow and/or heavily rate-limited:
systemd-imdsd as single entrypoint can deal with that, and provide a
reliable, cached interface
* Security: the idea is that systemd-imdsd is the only service behing
able to access the IMDS HTTP, and the host carries a blackhole route for
it otherwise. That way sensitive info can be kept away from clients, and
requires polkit auth for access
* Simplicity: extraction of systemd's system credentials from IMDS
userdata happens with systemd's own infra, and for many usecases that
should already be enough.
* Measurements: before accepting the IDMS userdata, it can be measured
into a PCR, as any other configuration input for the system

Fixes: #40763
2026-03-26 14:12:31 +01:00
Daan De Meyer 437278abd5 ci: Support multi-line review comments in claude-review
Pass side, start_line, and start_side through to createReviewComment()
when present, enabling multi-line review comments. Update the prompt to
document all positioning fields using JSON Schema and make line required.
2026-03-26 13:46:08 +01:00
Daan De Meyer f9363bc5da Revert "ci: Add subject_type to createReviewComment()"
This reverts commit 211cd6e9a3.

They document it here:
https://octokit.github.io/rest.js/v22/#pulls-create-review-comment
but apparently that's out of date and this doesn't work anymore.
2026-03-26 13:46:08 +01:00
Luca Boccassi 186032e1ed boot: add checks for invalid splash images in UKI
A malformed bmp with 8bits depth but smaller color
map would cause out of bounds reads. This is not a real
problem as the image is signed, but better to be safe.

Reported on yeswehack.com as:
YWH-PGM9780-135

Follow-up for 0fa2cac4f0
2026-03-26 11:52:23 +01:00
Luca Boccassi 82d96837db boot: fix typo in function name
Follow-up for dde03dd2a8
2026-03-26 11:52:23 +01:00
Daan De Meyer c78ba976e1 mkosi: Install clang-tidy package instead of clang-tools
clang-tools surprisingly enough doesn't provide clang-tidy
2026-03-26 10:14:09 +00:00
Lennart Poettering 29f45d1342 update TODO 2026-03-26 10:54:15 +01:00
Lennart Poettering 41dc0dc7b6 test: add simple integration test for systemd-imdsd 2026-03-26 10:54:15 +01:00
Lennart Poettering 168a7f7770 imds: add generator that hooks in IMDS logic on cloud guests
The infrastructure added in the previous commits added support for IMDS
client functionality, but didn't really to enable the logic by default
on suitable hosts.

This commit adds a generator that automatically hooks the IMDS
functionality into the boot process if it detects that the system is
running on a compliant cloud system. it enables both the imds daemon and
the client.
2026-03-26 10:54:15 +01:00
Lennart Poettering 19a783f4dd imds: add TPM measurements to imds tool
This automatically measures the IMDS 'userdata' into PCR 12, i.e. where
we measure the other owner-supplied configuration, such as confexts and
credentials and similar.

(Why 12? It's really about who owns the data and what it is for.
PCRs/NvPCRs are scarce hence there's a strong incentive to not go
overboard with new allocations, and IMDS userdata in purpose and owner
is very very similar to confexts and credentials, hence let's reuse the
PCR for this purpose.)
2026-03-26 10:54:15 +01:00
Lennart Poettering 1228660400 imds: add "systemd-imds" tool that is a simple client to "systemd-imdsd"
This is a client tool to the systemd-imdsd@.service added in the
previous commit. It's mostly just a 1:1 IPC client via Varlink. It can
be used to query any IMDS key, but it's primary usecase is to acquire
the "userdata" from IMDS. Moreover, if invoked with the --import switch
it will check if the userdata contains a list of system credentials. If
so, it will import them into the local credstore. If the userdata does
not look like a list of system credentials no operation is executed,
under the assumption the data is intended for cloud-init instead.

It also imports a couple of other fields, if available and recogniuzed,
such as SSH keys and the hostname.
2026-03-26 10:54:15 +01:00
Lennart Poettering eb6e5b07f1 imds: add new systemd-imdsd.service that makes IMDS data accessible locally
This service's job is to talk to a VM associated IMDS service provided
by the local Cloud. It tries to abstract the protocol differences
various IMDS implementations implement, but does *not* really try to
abstract more than a few basic fields of the actual IMDS metadata.

IMDS access is wrapped in a Varlink API that local clients can talk to.

If possible this makes use of the IMDS endpoint information that has
been added to hwdb in the preceeding commit. However, endpoint info can
also be provided via kernel command line and credentials. For debugging
purposes we also accept them via environment variables and command line
arguments.

This adds a concept of early-boot networking, just enough to be able to
talk to the IMDS service. It is minimally configurable via a kernel
cmdline option (and a build-time option): the user may choose between
"locked" and "unlocked" mode. In the former mode direct access to IMDS via
HTTPS is blocked via a prohibit route (and thus all IMDS communication
has to be done via systemd-imdsd@.service). In the latter case no such
lockdown takes place, and IMDS may be acquired both via this new service
and directly. The latter is typically a good idea for compatibility with
current systems, the former is preferable for secure installations.

Access to IMDS fields is controlled via PK.
2026-03-26 10:54:15 +01:00
Lennart Poettering f3eac272e6 hwdb: add database for basic IMDS properties
This adds a hardware database that contains information about IDMS
functionality of various clouds, keyed off the SMBIOS identification of
each. Currently this contains information about 6 major clouds, but the
idea is that this grows to include more and more major clouds.

Nothing uses this data yet, that's added in a later commit.
2026-03-26 10:54:15 +01:00
Daan De Meyer 211cd6e9a3 ci: Add subject_type to createReviewComment()
Apparently this is required by the createReviewComment() API.
2026-03-26 10:18:13 +01:00
Daan De Meyer db3ace5da5 ci: Use path instead of file in claude-review prompt as JSON key
In https://github.com/systemd/systemd/pull/40980 claude hallucinated
and used "path" instead of "file" as the JSON key. Since "path" is
arguably more correct than "file" anyway, let's switch to that.
2026-03-26 10:18:13 +01:00
Luan Vitor Simião Oliveira 7d320c3a99 hwdb: Add PXN HB S handbrake
otherwise, it is not classified.
reports 2 axes and 2 buttons although only 1 is actually used.
2026-03-26 08:35:33 +01:00
Lennart Poettering b45068d45a two small resolved fixups (#41337) 2026-03-26 08:33:49 +01:00
Patrick Wicki 6c7e5b81ac tpm2-util: fix PCR bank guessing without EFI
Since 7643e4a89 efi_get_active_pcr_banks() is used to determine the
active PCR banks. Without EFI support, this returns -EOPNOTSUPP. This in
turns leads to cryptenroll and cryptsetup attach failures unless the PCR
bank is explicitly set, i.e.

$ systemd-cryptenroll $LUKS_PART --tpm2-device=auto --tpm2-pcrs='7'
[...]
Could not read pcr values: Operation not supported

But it works fine with --tpm2-pcrs='7:sha256'.

Similarly, unsealing during cryptsetup attach also fails if the bank
needs to be determined:

Failed to unseal secret using TPM2: Operation not supported

Catch the -EOPNOTSUPP and fallback to the guessing strategy.

Signed-off-by: Patrick Wicki <patrick.wicki@subset.ch>
2026-03-25 23:18:58 +01:00
Massii Aqvayli 91af485544 po: Translated using Weblate (Kabyle)
Currently translated at 36.4% (97 of 266 strings)

Co-authored-by: Massii Aqvayli <massiin@proton.me>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/kab/
Translation: systemd/main
2026-03-25 22:18:04 +00:00
Lennart Poettering b734340596 resolved: move resetting of {etc_hosts|static_records}_last to manager_dispatch_reload_signal()
This addresses
https://github.com/systemd/systemd/pull/41213#pullrequestreview-4002247053
which I somehow missed earlier.

Claude found a real issue for the case of manager_etc_hosts_flush().
We'll do the equivalent change in manager_static_records_flush() too,
even though it's not really necessary there, simply to keep things
nicely mirrored.
2026-03-25 23:06:03 +01:00
Lennart Poettering 7863f6ba85 resolved: fix typo in comment 2026-03-25 23:06:03 +01:00
Daan De Meyer 8ff77aac13 vmspawn: Use qemu config files
Let's avoid generating giant qemu command lines by using qemu config
files instead.
2026-03-25 22:12:54 +01:00
Daan De Meyer f83371324d vmspawn: Create journal parent directories if needed 2026-03-25 21:55:19 +01:00
Daan De Meyer 5442fbfb07 vmspawn: Fix --tpm-state= parsing
path_startswith() considers "no" and "./no" equal. Use startswith()
to avoid that.
2026-03-25 21:54:51 +01:00
Mike Yuan aa71035a20 meson: detect availability of attributes using cc.has_function_attribute()
Alternative to fabc22f599

As suggested in https://github.com/systemd/systemd/pull/41174#discussion_r2966411375
2026-03-25 21:54:21 +01:00
Mike Yuan f3d385da2a memory-util: avoid passing invalid pointer to memcmp() when length == 16
If length is exactly 16, the loop would finish with length == 0,
but we'd carry on to the memcmp() check, where the 'p + 16' passed
would be invalid memory. memcmp() demands valid pointers even if
size is specified to 0, hence let's catch this ourselves.
2026-03-25 21:49:04 +01:00
Daan De Meyer 247ef81b6f swtpm: Properly configure state directory (#41322) 2026-03-25 20:21:16 +01:00
Daan De Meyer e2cfdfff15 AGENTS: Tell agents to not use mkosi box
It's easier to run the AI tool within mkosi box rather than telling
it to use mkosi box and forgetting to use it half the time.
2026-03-25 18:26:09 +01:00
Lennart Poettering 7a3f18d41d sd-stub: support for a "boot secret" stored in a EFI variable, as a fallback for TPM-less systems (#41217)
Split out of #41016
2026-03-25 18:24:07 +01:00
Lennart Poettering dcad61c74d stub: introduce "boot secret" stored in an EFI variable inaccessible to the OS 2026-03-25 16:19:27 +01:00
Lennart Poettering 6dc6b48ec9 random-seed: when we have a reasonable RNG then create random seed file if missing
Previously we'd never write the ESP random seed file (or initialize the
random seed EFI table) if it didn't already exist. Let's adjust this a
bit, and also create it fresh if we have a "good" random source, i.e. if
the EFI table already existed or if the RNG protocol is implemented by
EFI.

This is useful as it increases the chance the random seed table is
valid, and we can use it as source for randomness in later stages.
2026-03-25 16:19:24 +01:00
Daan De Meyer 82d69529cb swtpm-util: Write our own CA options rather than using the distro ones 2026-03-25 15:34:58 +01:00
Daan De Meyer 901024eea1 swtpm: Properly configure state directory
Otherwise it will unconditionally try to use /var/lib/xxx which won't
work when running unprivileged.
2026-03-25 15:22:57 +01:00
Lennart Poettering 9b15ddd9cf random-seed: move seed efi table definitions to header 2026-03-25 14:50:19 +01:00
Lennart Poettering c678b0b060 efi: add efivar_get_raw_full() flavour that returns the variable attributes too 2026-03-25 14:50:19 +01:00
Lennart Poettering e7b3a7bb24 memory-util: move memeqbyte() & friends to src/fundamental/ 2026-03-25 14:50:19 +01:00
Luca Boccassi 7e37e01768 two small prep commits from the imds PR (#41316)
They are not directly IMDS stuff, and should be easy to merge ahead.
2026-03-25 12:54:23 +00:00
Hadi Chokr 21bfad87e4 Add condition for mutable extensions directory
Signed-off-by: Hadi Chokr <hadichokr@icloud.com>
2026-03-25 12:36:44 +01:00
Michael Vogt 9f691ad3c0 varlink: comment that "more" flag IDL comment is API
External tools that use the systemd varlink ecosystem require
to know if a specific varlink method supports/requires the
"more" flag from the IDL. This is tracked upstream in
https://github.com/varlink/varlink.github.io/issues/26

As an intermediate step systemd adds the (very nice) comments
```
 # [Requires 'more' flag]
or
 # [Supports 'more' flag]
```
to the various methods.

This commit extends the comment around the code that adds the
comment to clarify that this should be considered API and that
the comment should not be changed as external tools (like e.g.
the varlink-http-bridge) rely on it.
2026-03-25 12:27:50 +01:00
Lennart Poettering 588c22b04d macro.h: move DEFER_VOID_CALL() to cleanup-util.h
For some reason the IMDS PR for the first time triggers an issue with
the DEFER_VOID_CALL() logic relying on assert() and being places in
macro.h, let's hence move this elsewhere.
2026-03-25 11:52:33 +01:00
Lennart Poettering 16a3857dcf test-iovec: add unit test for IOVEC_MAKE_BYTE()
As requested here: https://github.com/systemd/systemd/pull/40980#discussion_r2964650885
2026-03-25 11:52:33 +01:00