Skip to content

eBPF-based security platform

init: label the run directory so the init record is born sealed

Daniel Borkmann580cf9b52dd0
diff --git a/Documentation/initrd.rst b/Documentation/initrd.rst
index 70b06730..ba618353 100644
--- a/Documentation/initrd.rst
+++ b/Documentation/initrd.rst
@@ -69,9 +69,10 @@ needs nothing from the root file system.
The kernel keyring is kernel state and survives by itself; so do the
TPM's NV index and PCRs. The init record cannot be written to the
root's eventlog while the root is read-only, so it waits under ``/run``
-in the same tmpfs, labelled with the sealing xattr, and the eventlog
-readers treat it as part of this boot's log until the root file
-system's run appends it and removes the file.
+in the same tmpfs, in ``/run/shirudo``, which ``init`` labels with the
+sealing xattr so that the record is sealed from the instant it is
+created, and the eventlog readers treat it as part of this boot's log
+until the root file system's run appends it and removes the file.
The bpffs guards admit the executable recorded at init. From the
initrd the running binary is the initrd's copy, which is gone after
diff --git a/Documentation/requirements.rst b/Documentation/requirements.rst
index bfc75449..d7d27791 100644
--- a/Documentation/requirements.rst
+++ b/Documentation/requirements.rst
@@ -97,8 +97,12 @@ fixture.
provides a software TPM for machines without one.
* - ``CONFIG_EXT4_FS_SECURITY`` (when ``/var/lib/shirudo`` is on ext4)
- Allows ``init`` to store the ``security.bpf.shirudo`` label used by
- the filesystem seal. Other filesystems hosting this state must
- support security xattrs.
+ the filesystem seal, and the seal to write it on a new inode
+ inside the transaction that creates it. Other filesystems hosting
+ this state must support security xattrs, at creation included.
+ * - ``CONFIG_TMPFS_XATTR``
+ - The label on ``/run/shirudo`` and on the init record an initrd
+ run leaves there for the root file system's run.
``CONFIG_PKCS7_WAIVE_AUTHATTRS_REJECTION_FOR_MLDSA`` is not required: it
only relaxes module-signature checks, and BPF signature verification
diff --git a/builtin-init.c b/builtin-init.c
index 29fc2a6b..0a98ad04 100644
--- a/builtin-init.c
+++ b/builtin-init.c
@@ -481,6 +481,10 @@ static int init_bpffs(void)
pr_err("mkdir %s: %s", SHIRUDO_RUN_DIR, strerror(-rc));
return rc;
}
+ /* So that the init record left here is sealed from its creation. */
+ rc = shirudo_seal_label(SHIRUDO_RUN_DIR);
+ if (rc)
+ pr_warn("seal: label %s: %s", SHIRUDO_RUN_DIR, strerror(-rc));
rc = mkdir_p_mode(SHIRUDO_BPFFS_DIR, 0700);
if (rc) {
pr_err("mkdir %s: %s",