Skip to content

fix(os/mkosi): mask systemd's TPM SRK setup units - #1411

Merged
kvinwang merged 1 commit into
nextfrom
fix/mkosi-mask-tpm2-setup
Sep 26, 2026
Merged

kvinwang merged 1 commit into
nextfrom
fix/mkosi-mask-tpm2-setup

Conversation

@kvinwang

Copy link
Copy Markdown
Collaborator

Problem

On GCP (measured-UKI boot), systemd-tpm2-setup.service fails with Failed to open SRK public key file '/var/lib/systemd/tpm2-srk-public-key.pem' for writing: Read-only file system, which leaves the system degraded. The unit runs before sysinit.target, but the writable /var overlays come from dstack-volatile-binds.service, and the unit is not ordered after that service.

Fix

Mask systemd-tpm2-setup.service and systemd-tpm2-setup-early.service in the image skeleton, the same way the sleep targets and debug shell are already masked. The static acceptance test now checks both masks.

Masking is better than giving the unit a writable path:

  • Nothing in dstack uses systemd's SRK. The TPM key provider creates its own primary key at 0x81000100 through tpm2-tss, and no image component uses systemd-creds or systemd-cryptenroll with a TPM.
  • The Yocto image builds systemd without the tpm2 PACKAGECONFIG, so these units never existed there.
  • A writable path would only keep an unused SRK persisted in the vTPM.

Verification

On a measured-UKI boot (GCP), systemd-tpm2-setup.service tries to write
the SRK public key to /var/lib/systemd/tpm2-srk-public-key.pem. It runs
before sysinit.target, but the writable /var overlays come from
dstack-volatile-binds.service, which the unit does not order after, so
it hits the read-only root, fails, and leaves the system degraded.

Nothing in dstack uses systemd's SRK: the TPM key provider creates its
own primary key at 0x81000100 through tpm2-tss, and no image component
uses systemd-creds or systemd-cryptenroll with a TPM. The Yocto image
builds systemd without TPM support, so these units never existed there.
Mask both SRK units instead of giving them a writable path, which would
only keep an unused object persisted in the vTPM.

Signed-off-by: Kevin Wang <wy721@qq.com>
@kvinwang
kvinwang merged commit ba5a3f9 into next Sep 26, 2026
8 checks passed
@kvinwang
kvinwang deleted the fix/mkosi-mask-tpm2-setup branch September 26, 2026 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant