Skip to content

eBPF-based security platform

seal: take authority from a task whose memory a uprobe reaches

Daniel Borkmann33472adc40a0
diff --git a/Documentation/contribute/testing/test-coverage.rst b/Documentation/contribute/testing/test-coverage.rst
index f5dfd9d0..5c23dedc 100644
--- a/Documentation/contribute/testing/test-coverage.rst
+++ b/Documentation/contribute/testing/test-coverage.rst
@@ -476,6 +476,10 @@ signed config image.
- An exec of the runtime that fails after its mark is committed
dumps core without authority: the dump cannot unlink a pin or
replace a sealed file, and ``SealCoreDump`` counts it
+ * - ``t6146-uprobe``
+ - A uprobe set through tracefs on the runtime binary leaves the
+ commands it reaches without authority, counted as
+ ``SealUprobe``, until it is removed
``bpm`` (7)
~~~~~~~~~~~
diff --git a/Documentation/internals/enforcement.rst b/Documentation/internals/enforcement.rst
index 707d7f21..0f587d7f 100644
--- a/Documentation/internals/enforcement.rst
+++ b/Documentation/internals/enforcement.rst
@@ -109,10 +109,12 @@ question: does the calling task have runtime authority? A task has it
when it carries a mark in ``shirudo_tasks``. A task gets the mark by a
successful exec of a file on the authenticated runtime image, or, for the
``init`` process in the initrd, from a seed ``init`` writes before it
-freezes the map. A fork inherits the mark. A task that dumps core
-keeps its mark but not its authority, since the kernel's dump code runs
-as the task and writes where ``kernel.core_pattern`` says. :doc:`seal`
-explains how the mark is granted and cleared.
+freezes the map. A fork inherits the mark. A task that dumps core, or
+whose memory a uprobe reaches, keeps its mark but not its authority:
+the kernel's dump code runs as the task and writes where
+``kernel.core_pattern`` says, and a uprobe has the kernel change the
+task's memory. :doc:`seal` explains how the mark is granted and
+cleared.
The ``bpf()`` hooks have a second discriminator. ``lsm/bpf`` and
``lsm/bpf_prog_load`` receive ``bool kernel``, which is true for calls a
diff --git a/Documentation/internals/seal.rst b/Documentation/internals/seal.rst
index ac6f9eb0..223160f8 100644
--- a/Documentation/internals/seal.rst
+++ b/Documentation/internals/seal.rst
@@ -83,6 +83,22 @@ stays, so the protections below still keep other tasks off the dumping
task, and a fork copies the revocation along with the mark. The next
successful exec commits a fresh mark without it.
+A task whose memory a uprobe reaches loses its authority the same way,
+counted as ``SealUprobe``. Root sets a uprobe on any file it can name,
+the runtime binary included, through ``uprobe_events`` in tracefs or a
+perf event on the ``uprobe`` PMU, and no LSM hook sees either. A probe
+can carry a reference counter, a 16-bit value at a file offset of the
+probed binary, and the kernel adds one to it in every process that maps
+the binary writable at that offset, at every exec and every
+registration: a probe placed on the binary's data changes the variables
+shirudo reads before ``main()`` runs. The kernel sets
+``MMF_HAS_UPROBES`` in the memory of a process before it installs a
+probe there, and the check of authority reads that flag. The kernel
+installs probes in every mapping of a probed file that could be
+executable, so shirudo reads the binaries uprobe upatches target with
+``pread()`` rather than mapping them: the static runtime binary maps no
+file but itself, and the flag in its memory means a probe on it.
+
Policy bits
-----------
diff --git a/Documentation/reference/cli/status.rst b/Documentation/reference/cli/status.rst
index dea81f5e..3bba86a3 100644
--- a/Documentation/reference/cli/status.rst
+++ b/Documentation/reference/cli/status.rst
@@ -409,7 +409,7 @@ Print the keepalive body of the same target, which follows no tree:
.. code-block:: console
target# shirudo status --keepalive
- {"schema":"shirudo.keepalive/1","boot_id":"82639935-1127-4dab-91b5-f818eabc7f13","version_id":"d0d7aa800303439023907d1979d917d46a21bec21f816689c138728a28e84af9","config_root":"6d5ed552f448a1c07e3b9d24f5a86c1e0b7d93f2c4e5a6b7180c9d2e3f4a5b6c","kernel_release":"7.3.0-bpf-next+","image_id":null,"image_version":null,"image_root":null,"verdict":"ok","cond":5461,"flags":0,"tamper":[15,0,0,0,0,1,0,0,0,0,0,8,0,0,0,0,0,1,0,0,1,0,0,0,0,0,7,0,0,2,0,0,0,0,0,0,0,0],"tree_id":null,"generation":null,"base_seq":null,"last_seq":null,"base_root":null,"projection_root":null,"mask":null,"set_sha256":"5f0c2e8b7a1d4c3f9e6b2a0d8c7f1e3b5a9d4c2e6f8b0a1d3c5e7f9b2d4a6c8e","count":1,"not_ok":0}
+ {"schema":"shirudo.keepalive/1","boot_id":"82639935-1127-4dab-91b5-f818eabc7f13","version_id":"d0d7aa800303439023907d1979d917d46a21bec21f816689c138728a28e84af9","config_root":"6d5ed552f448a1c07e3b9d24f5a86c1e0b7d93f2c4e5a6b7180c9d2e3f4a5b6c","kernel_release":"7.3.0-bpf-next+","image_id":null,"image_version":null,"image_root":null,"verdict":"ok","cond":5461,"flags":0,"tamper":[15,0,0,0,0,1,0,0,0,0,0,8,0,0,0,0,0,1,0,0,1,0,0,0,0,0,7,0,0,2,0,0,0,0,0,0,0,0,0],"tree_id":null,"generation":null,"base_seq":null,"last_seq":null,"base_root":null,"projection_root":null,"mask":null,"set_sha256":"5f0c2e8b7a1d4c3f9e6b2a0d8c7f1e3b5a9d4c2e6f8b0a1d3c5e7f9b2d4a6c8e","count":1,"not_ok":0}
Add this boot's eventlog to the report:
diff --git a/Documentation/reference/formats/status-json.rst b/Documentation/reference/formats/status-json.rst
index 694524cb..4e5993a2 100644
--- a/Documentation/reference/formats/status-json.rst
+++ b/Documentation/reference/formats/status-json.rst
@@ -956,7 +956,8 @@ indented here:
"TpmExtend": 0,
"ObjGet": 0,
"SealSignal": 0,
- "SealCoreDump": 0
+ "SealCoreDump": 0,
+ "SealUprobe": 0
}
},
"config": {
@@ -1012,7 +1013,7 @@ of the same target read:
"SealXattr": 0, "SealLabel": 0, "SealPtrace": 0, "SealPerf": 0,
"ExecTraced": 0, "SealEntry": 0, "PerfAttach": 0, "PinEntry": 0,
"SealCopyUp": 0, "Kexec": 0, "TpmExtend": 0, "ObjGet": 1,
- "SealSignal": 0, "SealCoreDump": 0
+ "SealSignal": 0, "SealCoreDump": 0, "SealUprobe": 0
}
}
diff --git a/Documentation/security/tamper-counters.rst b/Documentation/security/tamper-counters.rst
index 6c18b209..28cdb0ce 100644
--- a/Documentation/security/tamper-counters.rst
+++ b/Documentation/security/tamper-counters.rst
@@ -222,6 +222,13 @@ counter.
authority for good, and the hook refuses the operation and moves
its own counter
- the hook's
+ * - ``SealUprobe``
+ - uprobe in a shirudo task, which acts without authority
+ - Any hook that asks for runtime authority, the first time a
+ marked task whose memory a uprobe reached asks: the task loses
+ its authority for good, and the hook refuses the operation and
+ moves its own counter
+ - the hook's
Unless the row says every caller, a task with runtime authority is
not refused and moves nothing.
@@ -324,6 +331,9 @@ and ``shirudo status`` find what a stopped load left. ``SealCoreDump``
counts a shirudo task that dumped core, after a crash or after an exec
that failed past its point of no return, which root can bring about
with a small stack limit; the dump did not get the task's authority.
+``SealUprobe`` counts a shirudo task whose memory a uprobe reached, one
+that root set through tracefs or perf on the runtime binary or on a
+library it maps.
A non-zero counter does not mean:
diff --git a/Documentation/security/threat-model.rst b/Documentation/security/threat-model.rst
index 3332b938..c114ce20 100644
--- a/Documentation/security/threat-model.rst
+++ b/Documentation/security/threat-model.rst
@@ -796,6 +796,15 @@ its mark was committed, when root gives it a stack too small for its
arguments, and the task then dumps core before shirudo has run: a pin
or a sealed file at that path was the dump's to remove (``t6145``).
+A task whose memory a uprobe reaches loses its authority as well
+(``SealUprobe``, ``t6146``). Root sets uprobes on the runtime binary
+through tracefs or perf, where no hook sees them, and a probe's
+reference counter has the kernel add to a value in the task's writable
+data at every exec: a variable shirudo reads before ``main()`` runs, a
+descriptor it takes for closed among them, changed under it. What a
+probe reads, a command's arguments and memory, is what root learns by
+running the command (R2).
+
An authorized process is protected against being taken over:
- ``lsm/ptrace_access_check`` refuses every ptrace mode against a marked
@@ -864,11 +873,12 @@ An authorized process is protected against being taken over:
:Counters: ``SealWrite``, ``SealUnlink``, ``SealRename``,
``SealSetattr``, ``SealXattr``, ``SealLabel``, ``SealEntry``,
``SealCopyUp``, ``KeyringWrite``, ``SealPtrace``, ``SealPerf``,
- ``SealSignal``, ``SealCoreDump``, ``ExecTraced``, ``ExeIdentity``
+ ``SealSignal``, ``SealCoreDump``, ``SealUprobe``, ``ExecTraced``,
+ ``ExeIdentity``
:Tests: ``t6001``, ``t6006``, ``t6007``, ``t6110``, ``t6111``,
``t6112``, ``t6113``, ``t6114``, ``t6115``, ``t6118``, ``t6123``,
``t6124``, ``t6127``, ``t6129``, ``t6131``, ``t6133``, ``t6134``,
- ``t6135``, ``t6136``, ``t6137``, ``t6144``, ``t6145``
+ ``t6135``, ``t6136``, ``t6137``, ``t6144``, ``t6145``, ``t6146``
:Residual: R2, R19, R22
T4 Substituting artifacts
diff --git a/bpf/lib/tamper.h b/bpf/lib/tamper.h
index a2372d62..ce96cb48 100644
--- a/bpf/lib/tamper.h
+++ b/bpf/lib/tamper.h
@@ -50,6 +50,7 @@ enum tamper_point {
TAMPER_OBJ_GET,
TAMPER_SEAL_SIGNAL,
TAMPER_SEAL_CORE_DUMP,
+ TAMPER_SEAL_UPROBE,
TAMPER_MAX
};
diff --git a/bpf/lib/verity.h b/bpf/lib/verity.h
index de5f735f..f06522c2 100644
--- a/bpf/lib/verity.h
+++ b/bpf/lib/verity.h
@@ -48,6 +48,7 @@ static __always_inline bool shirudo_bootstrap_task(void)
}
#define PF_DUMPCORE 0x00000200
+#define MMF_HAS_UPROBES 19
/* A task loses authority for good, and the cause is counted once. */
static __always_inline bool shirudo_revoke(struct task_authority *authority,
@@ -60,6 +61,19 @@ static __always_inline bool shirudo_revoke(struct task_authority *authority,
return false;
}
+/*
+ * A uprobe that reaches a task's memory, set through tracefs or perf
+ * where no hook sees it, has the kernel add to a counter in the task's
+ * writable data at every exec and registration: what the program then
+ * reads is no longer what the runtime image holds.
+ */
+static __always_inline bool shirudo_mm_has_uprobes(struct task_struct *task)
+{
+ unsigned long flags = BPF_CORE_READ(task, mm, flags.__mm_flags[0]);
+
+ return flags & (1UL << MMF_HAS_UPROBES);
+}
+
/*
* The mark changes only when exec commits, so failed exec keeps authority.
* An exec that fails after its commit dumps core, and so does a crash:
@@ -76,6 +90,8 @@ static __always_inline bool shirudo_task_is_self(const struct sb_id *id)
return false;
if (BPF_CORE_READ(task, flags) & PF_DUMPCORE)
return shirudo_revoke(authority, TAMPER_SEAL_CORE_DUMP);
+ if (shirudo_mm_has_uprobes(task))
+ return shirudo_revoke(authority, TAMPER_SEAL_UPROBE);
return true;
}
diff --git a/testing/fixtures/keepalive/node-a-1.0.0.json b/testing/fixtures/keepalive/node-a-1.0.0.json
index ea0753a4..6c615bf2 100644
--- a/testing/fixtures/keepalive/node-a-1.0.0.json
+++ b/testing/fixtures/keepalive/node-a-1.0.0.json
@@ -1 +1 @@
-{"schema":"shirudo.keepalive/1","boot_id":"168d20a1-5011-4e1b-9924-d8b73c85aa4e","version_id":"d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f","config_root":"1d8465c5b17838303fee92b3905420d294d2c22c576a0bdef0f69f190ed22807","kernel_release":"7.4.2","image_id":"fleet-os","image_version":"2026.11.1","image_root":"a3c3f1b0e4c2d7f09e3b6b2a8b1d5e7c4f6a9d0b2c8e1f3a5b7d9c0e2f4a6b8c","verdict":"ok","cond":5461,"flags":0,"tamper":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"tree_id":"fleet-base","generation":1,"base_seq":0,"last_seq":1,"base_root":"0000000000000000000000000000000000000000000000000000000000000000","projection_root":"04f83540c1727aefcf3c53449a99594c8fd1cc15e1466dbdbf3168cc8f9dc136","mask":"QA==","set_sha256":"6c9e113d02cd14646f617d7bba4a092b91bc3802dfdaae50e2fef7a01e0580aa","count":1,"not_ok":0}
\ No newline at end of file
+{"schema":"shirudo.keepalive/1","boot_id":"168d20a1-5011-4e1b-9924-d8b73c85aa4e","version_id":"d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f","config_root":"1d8465c5b17838303fee92b3905420d294d2c22c576a0bdef0f69f190ed22807","kernel_release":"7.4.2","image_id":"fleet-os","image_version":"2026.11.1","image_root":"a3c3f1b0e4c2d7f09e3b6b2a8b1d5e7c4f6a9d0b2c8e1f3a5b7d9c0e2f4a6b8c","verdict":"ok","cond":5461,"flags":0,"tamper":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"tree_id":"fleet-base","generation":1,"base_seq":0,"last_seq":1,"base_root":"0000000000000000000000000000000000000000000000000000000000000000","projection_root":"04f83540c1727aefcf3c53449a99594c8fd1cc15e1466dbdbf3168cc8f9dc136","mask":"QA==","set_sha256":"6c9e113d02cd14646f617d7bba4a092b91bc3802dfdaae50e2fef7a01e0580aa","count":1,"not_ok":0}
\ No newline at end of file
diff --git a/testing/fixtures/keepalive/node-a-1.1.0.json b/testing/fixtures/keepalive/node-a-1.1.0.json
index f02bbbb2..ecba2d1e 100644
--- a/testing/fixtures/keepalive/node-a-1.1.0.json
+++ b/testing/fixtures/keepalive/node-a-1.1.0.json
@@ -1 +1 @@
-{"schema":"shirudo.keepalive/1","boot_id":"168d20a1-5011-4e1b-9924-d8b73c85aa4e","version_id":"d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f","config_root":"1d8465c5b17838303fee92b3905420d294d2c22c576a0bdef0f69f190ed22807","kernel_release":"7.4.2","image_id":"fleet-os","image_version":"2026.11.1","image_root":"a3c3f1b0e4c2d7f09e3b6b2a8b1d5e7c4f6a9d0b2c8e1f3a5b7d9c0e2f4a6b8c","verdict":"ok","cond":5461,"flags":0,"tamper":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"tree_id":"fleet-base","generation":3,"base_seq":0,"last_seq":3,"base_root":"0000000000000000000000000000000000000000000000000000000000000000","projection_root":"154522480ff8884daa95589e80f26f20248bbf9c192dfbb3cee04e03b4f136a1","mask":"VA==","set_sha256":"74e5bd2c665109f6d8f926af5476c266ad70ab07293ff13b1a13d0b89aa5c1bf","count":1,"not_ok":0}
\ No newline at end of file
+{"schema":"shirudo.keepalive/1","boot_id":"168d20a1-5011-4e1b-9924-d8b73c85aa4e","version_id":"d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f","config_root":"1d8465c5b17838303fee92b3905420d294d2c22c576a0bdef0f69f190ed22807","kernel_release":"7.4.2","image_id":"fleet-os","image_version":"2026.11.1","image_root":"a3c3f1b0e4c2d7f09e3b6b2a8b1d5e7c4f6a9d0b2c8e1f3a5b7d9c0e2f4a6b8c","verdict":"ok","cond":5461,"flags":0,"tamper":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"tree_id":"fleet-base","generation":3,"base_seq":0,"last_seq":3,"base_root":"0000000000000000000000000000000000000000000000000000000000000000","projection_root":"154522480ff8884daa95589e80f26f20248bbf9c192dfbb3cee04e03b4f136a1","mask":"VA==","set_sha256":"74e5bd2c665109f6d8f926af5476c266ad70ab07293ff13b1a13d0b89aa5c1bf","count":1,"not_ok":0}
\ No newline at end of file
diff --git a/testing/fixtures/keepalive/node-b-1.0.0.json b/testing/fixtures/keepalive/node-b-1.0.0.json
index f922ce65..737c6a54 100644
--- a/testing/fixtures/keepalive/node-b-1.0.0.json
+++ b/testing/fixtures/keepalive/node-b-1.0.0.json
@@ -1 +1 @@
-{"schema":"shirudo.keepalive/1","boot_id":"9a6f14ea-0cc2-45e1-8e23-7b887120cf54","version_id":"d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f","config_root":"ff2cbeff5d0e9c41a7b36f28d14ce09b73a5182e6fc40d97b5e2a1683c0f7ff8","kernel_release":"7.4.2","image_id":"fleet-os","image_version":"2026.11.1","image_root":null,"verdict":"ok","cond":5461,"flags":0,"tamper":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"tree_id":"fleet-base","generation":1,"base_seq":0,"last_seq":1,"base_root":"0000000000000000000000000000000000000000000000000000000000000000","projection_root":"0000000000000000000000000000000000000000000000000000000000000000","mask":"gA==","set_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","count":0,"not_ok":0}
\ No newline at end of file
+{"schema":"shirudo.keepalive/1","boot_id":"9a6f14ea-0cc2-45e1-8e23-7b887120cf54","version_id":"d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f","config_root":"ff2cbeff5d0e9c41a7b36f28d14ce09b73a5182e6fc40d97b5e2a1683c0f7ff8","kernel_release":"7.4.2","image_id":"fleet-os","image_version":"2026.11.1","image_root":null,"verdict":"ok","cond":5461,"flags":0,"tamper":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"tree_id":"fleet-base","generation":1,"base_seq":0,"last_seq":1,"base_root":"0000000000000000000000000000000000000000000000000000000000000000","projection_root":"0000000000000000000000000000000000000000000000000000000000000000","mask":"gA==","set_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","count":0,"not_ok":0}
\ No newline at end of file
diff --git a/testing/fixtures/keepalive/node-b-1.1.0.json b/testing/fixtures/keepalive/node-b-1.1.0.json
index 086f7a47..04c3abad 100644
--- a/testing/fixtures/keepalive/node-b-1.1.0.json
+++ b/testing/fixtures/keepalive/node-b-1.1.0.json
@@ -1 +1 @@
-{"schema":"shirudo.keepalive/1","boot_id":"9a6f14ea-0cc2-45e1-8e23-7b887120cf54","version_id":"d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f","config_root":"ff2cbeff5d0e9c41a7b36f28d14ce09b73a5182e6fc40d97b5e2a1683c0f7ff8","kernel_release":"7.4.2","image_id":"fleet-os","image_version":"2026.11.1","image_root":null,"verdict":"ok","cond":5461,"flags":0,"tamper":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"tree_id":"fleet-base","generation":3,"base_seq":0,"last_seq":3,"base_root":"0000000000000000000000000000000000000000000000000000000000000000","projection_root":"0000000000000000000000000000000000000000000000000000000000000000","mask":"qA==","set_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","count":0,"not_ok":0}
\ No newline at end of file
+{"schema":"shirudo.keepalive/1","boot_id":"9a6f14ea-0cc2-45e1-8e23-7b887120cf54","version_id":"d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f","config_root":"ff2cbeff5d0e9c41a7b36f28d14ce09b73a5182e6fc40d97b5e2a1683c0f7ff8","kernel_release":"7.4.2","image_id":"fleet-os","image_version":"2026.11.1","image_root":null,"verdict":"ok","cond":5461,"flags":0,"tamper":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"tree_id":"fleet-base","generation":3,"base_seq":0,"last_seq":3,"base_root":"0000000000000000000000000000000000000000000000000000000000000000","projection_root":"0000000000000000000000000000000000000000000000000000000000000000","mask":"qA==","set_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","count":0,"not_ok":0}
\ No newline at end of file
diff --git a/testing/fixtures/keepalive/ops-16.json b/testing/fixtures/keepalive/ops-16.json
index cbc02b45..a1eabe54 100644
--- a/testing/fixtures/keepalive/ops-16.json
+++ b/testing/fixtures/keepalive/ops-16.json
@@ -1 +1 @@
-{"schema":"shirudo.keepalive/1","boot_id":"d5140906-4eab-4983-a62c-29e49d449ea3","version_id":"d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f","config_root":"1fbdff17ad8d50404772901df54d5aa2c698eddbb413e286fc654f80931c688a","kernel_release":"7.4.0-shirudo","image_id":"fleet-os","image_version":"2026.11.1","image_root":"a3c3f1b0e4c2d7f09e3b6b2a8b1d5e7c4f6a9d0b2c8e1f3a5b7d9c0e2f4a6b8c","verdict":"ok","cond":5461,"flags":0,"tamper":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"tree_id":"fleet-base","generation":42,"base_seq":0,"last_seq":12,"base_root":"0000000000000000000000000000000000000000000000000000000000000000","projection_root":"f59301708fc8e150c5d2abb1009b4f13fc0dcc1304b708f77dc14b1541679e28","mask":"WdlZAA==","set_sha256":"ac1af1d44b5c1fe3f616384db421138aa4d296595797b5864908a89276e17e6d","count":7,"not_ok":0}
\ No newline at end of file
+{"schema":"shirudo.keepalive/1","boot_id":"d5140906-4eab-4983-a62c-29e49d449ea3","version_id":"d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f","config_root":"1fbdff17ad8d50404772901df54d5aa2c698eddbb413e286fc654f80931c688a","kernel_release":"7.4.0-shirudo","image_id":"fleet-os","image_version":"2026.11.1","image_root":"a3c3f1b0e4c2d7f09e3b6b2a8b1d5e7c4f6a9d0b2c8e1f3a5b7d9c0e2f4a6b8c","verdict":"ok","cond":5461,"flags":0,"tamper":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"tree_id":"fleet-base","generation":42,"base_seq":0,"last_seq":12,"base_root":"0000000000000000000000000000000000000000000000000000000000000000","projection_root":"f59301708fc8e150c5d2abb1009b4f13fc0dcc1304b708f77dc14b1541679e28","mask":"WdlZAA==","set_sha256":"ac1af1d44b5c1fe3f616384db421138aa4d296595797b5864908a89276e17e6d","count":7,"not_ok":0}
\ No newline at end of file
diff --git a/testing/fixtures/keepalive/quotes.tsv b/testing/fixtures/keepalive/quotes.tsv
index bc465baf..9738b1af 100644
--- a/testing/fixtures/keepalive/quotes.tsv
+++ b/testing/fixtures/keepalive/quotes.tsv
@@ -1,4 +1,4 @@
-node-a-1.0.0.json /1RDR4AYACIAC06VSpnP3gTtZ2QchaGhY6WafCeOpBKEDpclW3Ccx9pCACBngwv8v+85ZN3/oJ1GGn0fixDXLgaGC3UF8Wu/O2sDwwAAAAAAAAAJAAAAAAAAAAABIBkQIwAWNjYAAAABAAsDAAAAACDjsMRCmPwcFJr79MiZb7kkJ65B5GSbk0yklZkbeFK4VQ== ABgACwAgF54Eav6u2zeENsA1jeBYVgjj+l7E8LIUJOUoN8QLeT0AII1JeKh1bOZfMm7B5Q5eInB6aS+OK2fNPIsiaEwwhGyi ACMACwAFAHIAAAAQABgACwADABAAIN9saxpH/ucken3zjEseEEzYZvqMfs7wBNWhcoXbvxPiACBdpocLC7oT7KaYEXol55BxGuufUfbSls5QY32xTXqkuQ== 67830bfcbfef3964ddffa09d461a7d1f8b10d72e06860b7505f16bbf3b6b03c3
-node-a-1.1.0.json /1RDR4AYACIAC06VSpnP3gTtZ2QchaGhY6WafCeOpBKEDpclW3Ccx9pCACCbpMuJxrs2A6V9v69DLet/wf0qO4aqF18ndNEbb/pcogAAAAAAAAAbAAAAAAAAAAABIBkQIwAWNjYAAAABAAsDAAAAACDjsMRCmPwcFJr79MiZb7kkJ65B5GSbk0yklZkbeFK4VQ== ABgACwAgTktehUD9YADS42OE1PzhnnU+vAh0/mZcQFnKxeKRRnQAIM/7fZPRNXpCCLy9jZZQIRVbecuqrGIUfIj44MG7Mvll ACMACwAFAHIAAAAQABgACwADABAAIN9saxpH/ucken3zjEseEEzYZvqMfs7wBNWhcoXbvxPiACBdpocLC7oT7KaYEXol55BxGuufUfbSls5QY32xTXqkuQ== 9ba4cb89c6bb3603a57dbfaf432deb7fc1fd2a3b86aa175f2774d11b6ffa5ca2
-node-b-1.0.0.json /1RDR4AYACIAC5EYvRv0FXHXovYD+xAPliggq1OPqxM+81LROPxt/tN2ACB8gTf/A7Q0+a6br7prB//DXMPAsSO8Vi8ARa8dPbzEGwAAAAAAAAAJAAAAAAAAAAABIBkQIwAWNjYAAAABAAsDAAAAACDjsMRCmPwcFJr79MiZb7kkJ65B5GSbk0yklZkbeFK4VQ== ABgACwAgKL665Vea0pt1M23mcy1igr9b6NEwaQKu7oklTIbL2tgAICid2HVaSm+Nm0YVe0bth3/E9qKA82rHDjTghyqCJgzB ACMACwAFAHIAAAAQABgACwADABAAIAV3xBjVs+04CIyAS9AsTz4ApNm4WoiTVYq/JNrP+TidACA35XRpkfzMf+pbOuIfzdkep23x7uS9SJVnLbQogFUmvg== 7c8137ff03b434f9ae9bafba6b07ffc35cc3c0b123bc562f0045af1d3dbcc41b
-node-b-1.1.0.json /1RDR4AYACIAC5EYvRv0FXHXovYD+xAPliggq1OPqxM+81LROPxt/tN2ACBN6tw34riJIdknzeJSR8rvG2A9dddKiVF2WmkMUywSAwAAAAAAAAAcAAAAAAAAAAABIBkQIwAWNjYAAAABAAsDAAAAACDjsMRCmPwcFJr79MiZb7kkJ65B5GSbk0yklZkbeFK4VQ== ABgACwAggO0fJ8hNRqLVECVnNq2dx/aQu31X3k4FiRnvxs3GtKMAIL+liSZZkyW0DgOBE//PNcCPkWye7AybH+4KymjaYBoh ACMACwAFAHIAAAAQABgACwADABAAIAV3xBjVs+04CIyAS9AsTz4ApNm4WoiTVYq/JNrP+TidACA35XRpkfzMf+pbOuIfzdkep23x7uS9SJVnLbQogFUmvg== 4deadc37e2b88921d927cde25247caef1b603d75d74a8951765a690c532c1203
+node-a-1.0.0.json /1RDR4AYACIACw2NC0UnOqe73PSIvgWv6G7EZGDO55kZ+Edl38SrdiSSACDja+hHOZ8FG9b/uJ2v2egENbB3JPvn38iTgJatVdl8LQAAAAAAAAAJAAAAAAAAAAABIBkQIwAWNjYAAAABAAsDAAAAACDjsMRCmPwcFJr79MiZb7kkJ65B5GSbk0yklZkbeFK4VQ== ABgACwAgLcFZVYZJUuUtAdWculOWqT3owk71Ri1lRWUQR1bFRi8AIC8Rbda6LjDvqz9c11hpAMImvimjMPEP1QK/mkvI1YEA ACMACwAFAHIAAAAQABgACwADABAAIH3+jlK5HCsAILGBrSlFDvIyOroo8xll9ORzhtPbZK5QACDjiC6pZtXgu9IzpTlaqaVTpQUeAFbyG+vPc4HGdaFMdg== e36be847399f051bd6ffb89dafd9e80435b07724fbe7dfc8938096ad55d97c2d
+node-a-1.1.0.json /1RDR4AYACIACw2NC0UnOqe73PSIvgWv6G7EZGDO55kZ+Edl38SrdiSSACCPLNyZU9A+l5chyzqnPPTGCZTyJ+jIrdosGD4QNQwK5wAAAAAAAAAaAAAAAAAAAAABIBkQIwAWNjYAAAABAAsDAAAAACDjsMRCmPwcFJr79MiZb7kkJ65B5GSbk0yklZkbeFK4VQ== ABgACwAguKfDN2mIBZEUkMrWMdqib0HqgNGpuXU+yp3JCe/RMnIAIK7mxd/Ryg1wXJwYOBWsSCDhdcYj4fwk0EDsAs4naMlj ACMACwAFAHIAAAAQABgACwADABAAIH3+jlK5HCsAILGBrSlFDvIyOroo8xll9ORzhtPbZK5QACDjiC6pZtXgu9IzpTlaqaVTpQUeAFbyG+vPc4HGdaFMdg== 8f2cdc9953d03e979721cb3aa73cf4c60994f227e8c8adda2c183e10350c0ae7
+node-b-1.0.0.json /1RDR4AYACIAC6/YTcFv3rkM9q9QHas1lNJCp+CKBQ95thJpGzj4YQj5ACDXe5rit6YC9t6GXM8wwi+DrwLtsUGNkgA/GuZMwjwdJQAAAAAAAAAKAAAAAAAAAAABIBkQIwAWNjYAAAABAAsDAAAAACDjsMRCmPwcFJr79MiZb7kkJ65B5GSbk0yklZkbeFK4VQ== ABgACwAgD76seQRb2xBw2pVn8Eosqz4DH9Qmi3b3tCEhYp4v4ToAIGkWS8lpU6VUv/da1pBdWxYBfnBbAJbHIRBjigf+G1CP ACMACwAFAHIAAAAQABgACwADABAAIOXn2ZUlFA7JDnvWwVogN32v54jP6thanxYM1B0BsnZ2ACCGGrcAT7mbP/jSKF/a9kg4nRVzlzoat51s5Cz3UOSRqw== d77b9ae2b7a602f6de865ccf30c22f83af02edb1418d92003f1ae64cc23c1d25
+node-b-1.1.0.json /1RDR4AYACIAC6/YTcFv3rkM9q9QHas1lNJCp+CKBQ95thJpGzj4YQj5ACCxAst8n8nryOWGYet3Yl7EbzM7Zc27hbP93Jsyj8wkHgAAAAAAAAAdAAAAAAAAAAABIBkQIwAWNjYAAAABAAsDAAAAACDjsMRCmPwcFJr79MiZb7kkJ65B5GSbk0yklZkbeFK4VQ== ABgACwAgOy9q1VnGq2L7FmBZmsJtIkJfXhrIxT026BIl3prBAi4AIB57maxzEH7DkK8L1iM7IWWv/aBX4ughYEYihRWvwg/C ACMACwAFAHIAAAAQABgACwADABAAIOXn2ZUlFA7JDnvWwVogN32v54jP6thanxYM1B0BsnZ2ACCGGrcAT7mbP/jSKF/a9kg4nRVzlzoat51s5Cz3UOSRqw== b102cb7c9fc9ebc8e58661eb77625ec46f333b65cdbb85b3fddc9b328fcc241e
diff --git a/testing/fixtures/keepalive/recompute.py b/testing/fixtures/keepalive/recompute.py
index 4f0c6ca6..d77381f7 100755
--- a/testing/fixtures/keepalive/recompute.py
+++ b/testing/fixtures/keepalive/recompute.py
@@ -24,7 +24,7 @@ BODY_KEYS = [
"projection_root", "mask", "set_sha256", "count", "not_ok",
]
CANONICAL_KEYS = ["seq", "op", "id", "selector", "artifact"]
-TAMPER_COUNTERS = 38
+TAMPER_COUNTERS = 39
ALL_OK = 0x1555
OPERATION_DIGESTS = [
@@ -51,9 +51,9 @@ MASKS = [
# The body the example pages print for node A after release 1.1.0: six
# conditions and no image keys.
-PAGE_BODY_LEN = 734
+PAGE_BODY_LEN = 736
PAGE_BODY_SHA256 = \
- "7aea4a7847c84d70ef4251c798cf09700dd2757ddf1e90d18519e0462e4a361a"
+ "2c133a5d34993e3370c521e2868d6c9f16ec22b952e7a16b1478b37bb717f0b4"
PAGE_COND = 0x555
VERSION_ID = "d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f"
diff --git a/testing/functional/tamperproof/t6146-uprobe.sh b/testing/functional/tamperproof/t6146-uprobe.sh
new file mode 100755
index 00000000..303651a6
--- /dev/null
+++ b/testing/functional/tamperproof/t6146-uprobe.sh
@@ -0,0 +1,85 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+#
+# t6146 -- a uprobe on the runtime binary takes the authority of the
+# shirudo tasks whose memory it reaches: while a probe set through tracefs
+# sits at the binary's entry point, a load is refused and SealUprobe
+# counts it, and shirudo works again once the probe is gone.
+
+cd "$(dirname "$0")/../.."
+. ./integration-lib.sh
+target_guard
+command -v python3 >/dev/null 2>&1 || test_skip_all "no python3"
+T=/sys/kernel/tracing
+[ -w "$T/uprobe_events" ] || test_skip_all "no uprobe events in tracefs"
+FIXTURES=$SHIRUDO_TEST_FIXTURES_DIR
+NAME=shirudo-test-basic
+PINDIR="/run/shirudo/bpffs/upatches/$NAME"
+[ -s "$FIXTURES/$NAME.upatch" ] || test_skip_all "missing fixture $NAME"
+RUNTIME=$(runtime_binary)
+GROUP=shirudo_t6146
+cleanup() {
+ [ ! -e "$T/events/$GROUP/entry/enable" ] ||
+ echo 0 >"$T/events/$GROUP/entry/enable" || :
+ echo "-:$GROUP/entry" >>"$T/uprobe_events" 2>/dev/null || :
+ [ ! -e "$PINDIR" ] ||
+ "$SHIRUDO_BIN" upatch unload "$FIXTURES/$NAME.unload.upatch" \
+ >/dev/null 2>&1 || :
+}
+trap cleanup EXIT
+counter() {
+ "$SHIRUDO_BIN" status --json | python3 -c '
+import json, sys
+print(json.load(sys.stdin)["tamper_attempts"]["counters"][sys.argv[1]])
+' "$1"
+}
+# The file offset of the ELF entry point, from the segment that holds it.
+entry_offset() {
+ python3 - "$1" <<'PY'
+import struct, sys
+elf = open(sys.argv[1], "rb").read()
+entry, = struct.unpack_from("<Q", elf, 24)
+phoff, = struct.unpack_from("<Q", elf, 32)
+phentsize, phnum = struct.unpack_from("<HH", elf, 54)
+for i in range(phnum):
+ kind, flags, offset, vaddr, _, filesz = struct.unpack_from(
+ "<IIQQQQ", elf, phoff + i * phentsize)
+ if kind == 1 and flags & 1 and vaddr <= entry < vaddr + filesz:
+ print(hex(entry - vaddr + offset))
+ break
+else:
+ sys.exit(1)
+PY
+}
+ENTRY=$(entry_offset "$RUNTIME") || test_skip_all "no entry point in $RUNTIME"
+before=$(counter SealUprobe) || test_skip_all "no tamper counters"
+[ ! -e "$PINDIR" ] ||
+ "$SHIRUDO_BIN" upatch unload "$FIXTURES/$NAME.unload.upatch" \
+ >/dev/null 2>&1
+[ ! -e "$PINDIR" ] || test_skip_all "$NAME cannot be unloaded"
+
+test_expect_success 'root sets a uprobe at the entry of the runtime binary' '
+ echo "p:$GROUP/entry $RUNTIME:$ENTRY" >>"$T/uprobe_events" &&
+ echo 1 >"$T/events/$GROUP/entry/enable"
+'
+test_expect_success 'a load from a task the probe reached is refused' '
+ ! "$SHIRUDO_BIN" upatch load "$FIXTURES/$NAME.upatch" >/dev/null 2>&1 &&
+ [ ! -e "$PINDIR" ]
+'
+test_expect_success 'the probe is gone again' '
+ echo 0 >"$T/events/$GROUP/entry/enable" &&
+ echo "-:$GROUP/entry" >>"$T/uprobe_events" &&
+ [ ! -e "$T/events/$GROUP/entry" ]
+'
+test_expect_success 'the lost authority is counted as SealUprobe' '
+ [ "$(counter SealUprobe)" -gt "$before" ]
+'
+test_expect_success 'a load without the probe succeeds and is undone' '
+ "$SHIRUDO_BIN" upatch load "$FIXTURES/$NAME.upatch" >/dev/null 2>&1 &&
+ [ -e "$PINDIR/link" ] &&
+ "$SHIRUDO_BIN" upatch unload "$FIXTURES/$NAME.unload.upatch" \
+ >/dev/null 2>&1 &&
+ [ ! -e "$PINDIR" ]
+'
+test_done
diff --git a/testing/proofs/cbmc/proofs.list b/testing/proofs/cbmc/proofs.list
index c2fd5c7a..a06c9157 100644
--- a/testing/proofs/cbmc/proofs.list
+++ b/testing/proofs/cbmc/proofs.list
@@ -56,7 +56,7 @@ log-escape --unwind 7 LEN=0-5
json-emit-string --unwind 5 --unwindset json_string.0:27,put_string_n.0:5,put_raw.0:7,well_formed.0:27,replaced.0:5,memchr.0:9,memcmp.0:13 LEN=0-4
json-emit-buffer --unwind 1 --unwindset json_raw_value.0:5,harness.0:5 --malloc-may-fail --malloc-fail-null LEN=0-4
json-emit-nest --object-bits 12 --unwind 1 --unwindset json_text.0:57,sequences.0:4,sequences.1:5,any_depth.0:4,any_depth.1:4,strcmp.0:12,memchr.0:9,put_string_n.0:2,put_string_n.1:2,put_raw.0:8,json_kv_raw.0:3,json_raw_value.0:3,json_raw.0:5,strlen.0:3,vsnprintf.2:5,vsnprintf.0:2,format_number.0:3,format_number.2:5,format_number.3:3
-keepalive-emit -I ../../.. --object-bits 12 --max-field-sensitivity-array-size 832 --unwind 1 --unwindset json_members.0:833,power_of_ten.0:6,put_string_n.0:5,put_string_n.1:66,put_raw.0:7,strlen.0:66,hex_is_lower.0:66,kv_tamper.0:39,kv_no_tree.0:8,json_raw_value.0:6,vsnprintf.2:4,vsnprintf.0:2,format_number.0:6,format_number.2:5,format_number.3:6,ends_in_any_number.0:6,ends_in_any_number.1:833,ends_in_any_number.2:5 LEN=0-3
+keepalive-emit -I ../../.. --object-bits 12 --max-field-sensitivity-array-size 832 --unwind 1 --unwindset json_members.0:833,power_of_ten.0:6,put_string_n.0:5,put_string_n.1:66,put_raw.0:7,strlen.0:66,hex_is_lower.0:66,kv_tamper.0:40,kv_no_tree.0:8,json_raw_value.0:6,vsnprintf.2:4,vsnprintf.0:2,format_number.0:6,format_number.2:5,format_number.3:6,ends_in_any_number.0:6,ends_in_any_number.1:833,ends_in_any_number.2:5 LEN=0-3
json-string --unwind 5 --unwindset json_string.0:7,parse_string.0:5,parse_string.1:7,memchr.0:9,memcmp.0:7,harness.0:8 LEN=0-6
json-escape --unwind 5 --unwindset parse_string.0:4,memcmp.0:9
json-roundtrip --unwind 1 --unwindset put_string_n.0:5,put_string_n.1:5,put_raw.0:7,vsnprintf.2:4,vsnprintf.0:2,format_number.0:3,format_number.2:5,format_number.3:3,parse_string.1:6,parse_string.0:4,hex4.0:5,utf8_width.0:4,memcmp.0:5 LEN=0-4
diff --git a/testing/unit/keepalive.c b/testing/unit/keepalive.c
index e25a27ea..581e33ef 100644
--- a/testing/unit/keepalive.c
+++ b/testing/unit/keepalive.c
@@ -595,17 +595,17 @@ static const char * const tamper_order[] = {
"SealRename", "SealSetattr", "SealXattr", "SealLabel", "SealPtrace",
"SealPerf", "ExecTraced", "SealEntry", "PerfAttach", "PinEntry",
"SealCopyUp", "Kexec", "TpmExtend", "ObjGet", "SealSignal",
- "SealCoreDump",
+ "SealCoreDump", "SealUprobe",
};
static void tamper_counters_keep_their_places(void)
{
size_t i;
- ASSERT_EQ(ARRAY_SIZE(tamper_order), 38);
+ ASSERT_EQ(ARRAY_SIZE(tamper_order), 39);
ASSERT_EQ(TAMPER_MAX, ARRAY_SIZE(tamper_order));
EXPECT_EQ(TAMPER_LOAD_NOT_LOADER, 0);
- EXPECT_EQ(TAMPER_SEAL_CORE_DUMP, TAMPER_MAX - 1);
+ EXPECT_EQ(TAMPER_SEAL_UPROBE, TAMPER_MAX - 1);
for (i = 0; i < ARRAY_SIZE(tamper_order); i++)
EXPECT_STREQ(tamper_name(i), tamper_order[i]);
}
@@ -622,7 +622,7 @@ static void body_lists_the_counters_in_enum_order(void)
in.tamper = tamper;
expect_member(&in, ",\"tamper\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,"
"16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,"
- "34,35,36,18446744073709551615,38],\"tree_id\":");
+ "34,35,36,18446744073709551615,38,39],\"tree_id\":");
}
static void body_refuses_a_missing_string(void)
@@ -742,7 +742,7 @@ static void body_of_the_largest_values_fits(void)
in.tamper = tamper;
ASSERT_EQ(keepalive_emit(&in, body, sizeof(body), &whole), 0);
- EXPECT_EQ(whole, 3319);
+ EXPECT_EQ(whole, 3340);
EXPECT_LT(whole, KEEPALIVE_BODY_MAX);
EXPECT_EQ(keepalive_emit(&in, body, whole, &len), -ENOSPC);
EXPECT_EQ(keepalive_emit(&in, body, whole + 1, &len), 0);
diff --git a/util/elf_target.c b/util/elf_target.c
index b70fc11d..59025176 100644
--- a/util/elf_target.c
+++ b/util/elf_target.c
@@ -124,7 +124,13 @@ int elf_build_id_fd(int fd,
*build_id_len = 0;
if (elf_version(EV_CURRENT) == EV_NONE)
return -EINVAL;
- elf = elf_begin(fd, ELF_C_READ_MMAP, NULL);
+ /*
+ * Read, not mapped: a mapping of a binary that a loaded upatch
+ * probes takes the probe's breakpoints into shirudo's memory, and
+ * the seal takes the authority of a task whose memory a uprobe
+ * reached.
+ */
+ elf = elf_begin(fd, ELF_C_READ, NULL);
if (!elf)
return -EINVAL;
if (elf_kind(elf) != ELF_K_ELF)
diff --git a/util/tamper.c b/util/tamper.c
index 6e3dd08e..937b5165 100644
--- a/util/tamper.c
+++ b/util/tamper.c
@@ -96,6 +96,8 @@ static const struct {
"signal to a shirudo task (let through)" },
[TAMPER_SEAL_CORE_DUMP] = { "SealCoreDump",
"core dump of a shirudo task, which acts without authority" },
+ [TAMPER_SEAL_UPROBE] = { "SealUprobe",
+ "uprobe in a shirudo task, which acts without authority" },
};
const char *tamper_name(enum tamper_point point)