summaryrefslogtreecommitdiffstats
path: root/src/boot/efi/cpio.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-09-20 13:47:32 +0200
committerLennart Poettering <lennart@poettering.net>2021-09-23 17:24:09 +0200
commit845707aae23b3129db635604edb95c4048a5922a (patch)
tree2b7e758f1797ac501c43942882f71161507be70f /src/boot/efi/cpio.h
parentboot: generalize sorting code (diff)
downloadsystemd-845707aae23b3129db635604edb95c4048a5922a.tar.xz
systemd-845707aae23b3129db635604edb95c4048a5922a.zip
stub: when booting a kernel foo.efi then pack foo.efi.extra.d/*.{cred,raw} up as synthetic initrd
This adds support for the EFI stub to look for credential files and sysext files next to the EFI kernel image being loaded, and pack them up in an initrd cpio image, and pass them to the kernel. Specifically, for a kernel image foo.efi it looks for foo.efi.extra.d/*.cred and packs these files up in an initrd, placing it inside a directory /.extra/credentials/. It then looks for foo.efi.extra.d/*.raw and pack these files up in an initrd, placing them inside a directory /.extra/sysexts/. It then concatenates any other initrd with these two initrds, so they are combined. Or in other words auxiliary files placed next to the kernel image are picked up automatically by the EFI stub and be made available in the initrd in the /.extra/ directory. What's the usecase for this? This is supposed to be useful in context of implementing fully trusted initrds, i.e. initrds that are not built locally on the system and unsigned/unmeasured – as we do things currently —, but instead are built by the vendor, and measured to TPM. The idea is that a basic initrd is always linked into the kernel EFI image anyway. This will already be sufficient for many cases. However, in some cases it is necessary to parameterize initrds, or to extend the basic initrds with additional subsystems (e.g. think complex storage, or passing server info/certificates/… to initrds). The idea is that the parameterization is done using the "credentials" logic we already have in systemd, with these credential files (which can optionally be encrypted+authenticated by TPM2) being placed in the ESP next to the kernel image. And the initrd extension via the "sysext" logic we already have in systemd too. Note that the files read by this code are not verified immediately, they are copied *as-is* and placed into /.extra/ in the initrd. In a trusted environment they need to be validated later, but before first use. For the credentials logic this should be done via the TPM2 encryption/authentication logic. For the sysext stuff the idea is that this is done via signed images, as implemented by #20691.
Diffstat (limited to 'src/boot/efi/cpio.h')
-rw-r--r--src/boot/efi/cpio.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/boot/efi/cpio.h b/src/boot/efi/cpio.h
new file mode 100644
index 0000000000..8a6d093122
--- /dev/null
+++ b/src/boot/efi/cpio.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include <efi.h>
+
+EFI_STATUS pack_cpio(
+ EFI_LOADED_IMAGE *loaded_image,
+ const CHAR16 *match_suffix,
+ const CHAR8 *target_dir_prefix,
+ UINT32 dir_mode,
+ UINT32 access_mode,
+ UINTN pcr,
+ const CHAR16 *tpm_description,
+ VOID **ret_buffer,
+ UINTN *ret_buffer_size);