Skip to content

eBPF-based security platform

upatch: undo a load whose archive copy fails

Daniel Borkmannd72042276c82
diff --git a/Documentation/architecture.rst b/Documentation/architecture.rst
index a3fc7c13..ea2099e7 100644
--- a/Documentation/architecture.rst
+++ b/Documentation/architecture.rst
@@ -187,8 +187,9 @@ Load. ``shirudo upatch load fix.upatch`` on the target:
6. copies the artifact to ``/var/lib/shirudo/upatches/`` for
boot-restore;
7. extends the register with ``SHA256("shirudo-upatch\0" ||
- payload_sha256 || name)`` and appends the event to the eventlog; a
- register that refuses the event undoes the load, pins and archive.
+ payload_sha256 || name)`` and appends the event to the eventlog; an
+ archive copy that fails, or a register that refuses the event, undoes
+ the load, pins and archive.
Unload. ``shirudo upatch unload fix.unload.upatch`` runs the same
pre-flight and the same signature-gated ``BPF_PROG_LOAD`` of the
diff --git a/Documentation/threat-model.rst b/Documentation/threat-model.rst
index 9bff89c0..ce282542 100644
--- a/Documentation/threat-model.rst
+++ b/Documentation/threat-model.rst
@@ -229,9 +229,9 @@ T5 Silent state change
with the index name right after that write, so nothing that runs
later can bind, an index undefined and recreated at runtime cannot
be written again, and one recreated under another policy has a name
- the eventlog does not know. A load whose extension fails is
- undone, pins and archive, and reports ``tpm_error`` rather than
- running unmeasured; an unload or purge is measured before it
+ the eventlog does not know. A load whose archive copy or
+ whose extension fails is undone, pins and archive, and reports the
+ failure rather than running unmeasured; an unload or purge is measured before it
detaches, so a process stopped between the two, or a TPM made
unreachable for the moment, leaves a register that claims more
than happened and never a detach it does not know; a re-run of
diff --git a/builtin-upatch.c b/builtin-upatch.c
index 305efe5b..2f9b7cb1 100644
--- a/builtin-upatch.c
+++ b/builtin-upatch.c
@@ -2654,7 +2654,8 @@ static int cmd_upatch_load(int argc, const char **argv)
/*
* Persist before measuring: the archive is the intent boot restore
* replays, and an event for an upatch that will not survive a reboot
- * would drift from it. A load the register then refuses to take is
+ * would drift from it. A load whose archive copy fails, a file system
+ * root filled say, or one the register then refuses to take is
* undone, pins and archive, so that no upatch runs unmeasured; a
* caller who stops this process first gets the same at the next
* init, which refuses to restore what the register does not cover.
@@ -2663,7 +2664,9 @@ static int cmd_upatch_load(int argc, const char **argv)
if (rc) {
pr_err("upatch load: loaded but failed to persist to %s: %s "
"-- not measured", SHIRUDO_UPATCHES_DIR, strerror(-rc));
- rep_fail(&rep, "persist", "unknown", -rc, "persist failed");
+ unload_unmeasured(name);
+ rep_fail(&rep, "persist", "unknown", -rc,
+ "persist failed; the load was undone");
goto done;
}