diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-09-26 21:25:53 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-09-29 19:36:04 +0200 |
commit | 2e64cb71b9c0160c335d8e52954149e078bba2fb (patch) | |
tree | 6009b2b90b9f5a7e88c65d2a8ff3084b634ea26c /units | |
parent | Merge pull request #29234 from ddstreet/tpm2_marshal_serialize_handle_index (diff) | |
download | systemd-2e64cb71b9c0160c335d8e52954149e078bba2fb.tar.xz systemd-2e64cb71b9c0160c335d8e52954149e078bba2fb.zip |
tpm2-setup: add new early boot tool for initializing the SRK
This adds an explicit service for initializing the TPM2 SRK. This is
implicitly also done by systemd-cryptsetup, hence strictly speaking
redundant, but doing this early has the benefit that we can parallelize
this in a nicer way. This also write a copy of the SRK public key in PEM
format to /run/ + /var/lib/, thus pinning the disk image to the TPM.
Making the SRK public key is also useful for allowing easy offline
encryption for a specific TPM.
Sooner or later we should probably grow what this service does, the
above is just the first step. For example, the service should probably
offer the ability to reset the TPM (clear the owner hierarchy?) on a
factory reset, if such a policy is needed. And we might want to install
some default AK (?).
Fixes: #27986
Also see: #22637
Diffstat (limited to 'units')
-rw-r--r-- | units/meson.build | 10 | ||||
-rw-r--r-- | units/systemd-tpm2-setup-early.service.in | 22 | ||||
-rw-r--r-- | units/systemd-tpm2-setup.service.in | 24 |
3 files changed, 56 insertions, 0 deletions
diff --git a/units/meson.build b/units/meson.build index 2fb87934b8..e1de2b4a6d 100644 --- a/units/meson.build +++ b/units/meson.build @@ -459,6 +459,16 @@ units = [ 'symlinks' : ['sysinit.target.wants/'], }, { + 'file' : 'systemd-tpm2-setup.service.in', + 'conditions' : ['ENABLE_BOOTLOADER', 'HAVE_OPENSSL', 'HAVE_TPM2'], + 'symlinks' : ['sysinit.target.wants/'], + }, + { + 'file' : 'systemd-tpm2-setup-early.service.in', + 'conditions' : ['ENABLE_BOOTLOADER', 'HAVE_OPENSSL', 'HAVE_TPM2'], + 'symlinks' : ['sysinit.target.wants/'], + }, + { 'file' : 'systemd-portabled.service.in', 'conditions' : ['ENABLE_PORTABLED'], 'symlinks' : ['dbus-org.freedesktop.portable1.service'], diff --git a/units/systemd-tpm2-setup-early.service.in b/units/systemd-tpm2-setup-early.service.in new file mode 100644 index 0000000000..c1597ea3f9 --- /dev/null +++ b/units/systemd-tpm2-setup-early.service.in @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +[Unit] +Description=TPM2 SRK Setup (Early) +Documentation=man:systemd-tpm2-setup.service(8) +DefaultDependencies=no +Conflicts=shutdown.target +Before=sysinit.target shutdown.target +ConditionSecurity=measured-uki +ConditionPathExists=!/run/systemd/tpm2-srk-public-key.pem + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart={{LIBEXECDIR}}/systemd-tpm2-setup --early=yes diff --git a/units/systemd-tpm2-setup.service.in b/units/systemd-tpm2-setup.service.in new file mode 100644 index 0000000000..6c99f3af0a --- /dev/null +++ b/units/systemd-tpm2-setup.service.in @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +[Unit] +Description=TPM2 SRK Setup +Documentation=man:systemd-tpm2-setup.service(8) +DefaultDependencies=no +Conflicts=shutdown.target +After=systemd-tpm2-setup-early.service systemd-remount-fs.service +Before=sysinit.target shutdown.target +RequiresMountsFor=/var/lib/systemd/tpm2-srk-public-key.pem +ConditionSecurity=measured-uki +ConditionPathExists=!/etc/initrd-release + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart={{LIBEXECDIR}}/systemd-tpm2-setup |