eBPF-based security platform
seal: refuse the runtime to a task that shares its file system context
Daniel Borkmann06f03896a635
diff --git a/Documentation/contribute/testing/test-coverage.rst b/Documentation/contribute/testing/test-coverage.rstindex ba1a99bc..1508d623 100644--- a/Documentation/contribute/testing/test-coverage.rst+++ b/Documentation/contribute/testing/test-coverage.rst@@ -499,6 +499,9 @@ signed config image.* - ``t6151-personality``- Started under ``setarch --uname-2.6``, shirudo still reads thekernel's release+ * - ``t6152-exec-shared``+ - The exec of the runtime binary by a task that shares its+ ``fs_struct`` is refused and counted; another program's is not``bpm`` (7)~~~~~~~~~~~@@ -1016,6 +1019,8 @@ tests assert that a refusal moves its counter:- ``t6143``* - ``ExecTraced``- ``t6137``+ * - ``ExecShared``+ - ``t6152``* - ``Kexec``- ``t6126``diff --git a/Documentation/internals/enforcement.rst b/Documentation/internals/enforcement.rstindex ae52a1d7..2388bee7 100644--- a/Documentation/internals/enforcement.rst+++ b/Documentation/internals/enforcement.rst@@ -442,9 +442,10 @@ when the record it needs is missing.* - ``lsm.s/bprm_check_security`` (``seal``)- Stages the mark candidate: trusted when the file is a direct, notoverlay, inode on a recorded runtime device. Refuses a trusted- candidate that is traced or has a seccomp filter.+ candidate that is traced, shares its ``fs_struct`` with another+ process or has a seccomp filter.- ``EACCES``- - ``ExecTraced``; seccomp uncounted+ - ``ExecTraced``, ``ExecShared``; seccomp uncounted- Closed: no task storage refuses the exec with ``ENOMEM``.* - ``lsm.s/bprm_committed_creds`` (``seal``)- Commits the staged candidate as the task's mark when an execdiff --git a/Documentation/internals/seal.rst b/Documentation/internals/seal.rstindex 4cddd12b..57484aa1 100644--- a/Documentation/internals/seal.rst+++ b/Documentation/internals/seal.rst@@ -59,11 +59,14 @@ when all of these hold:- the inode is on a read-only superblock whose block device is recordedas the runtime device, with the same device number and disk sequence;- the task is not traced;+- no other process shares the task's root and working directory;- the task has no seccomp filter.-A traced exec of a runtime file is refused (``ExecTraced``), and so is-one with a seccomp filter, because a tracer or a filter installed before-the exec would control the trusted process. ``lsm.s/bprm_committed_creds``+A traced exec of a runtime file is refused (``ExecTraced``), and so are+one by a task that shares its ``fs_struct`` with another process+(``ExecShared``), which exec does not unshare, and one with a seccomp+filter, because a tracer, the other process or a filter installed+before the exec would control the trusted process. ``lsm.s/bprm_committed_creds``commits the candidate when the exec succeeds. A failed exec never reachesthat hook and leaves the existing mark alone. A successful exec of a filethat is not on the runtime image commits an untrusted candidate and sodiff --git a/Documentation/reference/cli/status.rst b/Documentation/reference/cli/status.rstindex bcab5837..f08a8821 100644--- a/Documentation/reference/cli/status.rst+++ b/Documentation/reference/cli/status.rst@@ -408,7 +408,7 @@ Print the keepalive body of the same target, which follows no tree:.. code-block:: consoletarget# 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,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,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.rstindex 14a1eca9..a2adabc8 100644--- a/Documentation/reference/formats/status-json.rst+++ b/Documentation/reference/formats/status-json.rst@@ -957,7 +957,8 @@ indented here:"ObjGet": 0,"SealSignal": 0,"SealCoreDump": 0,- "SealUprobe": 0+ "SealUprobe": 0,+ "ExecShared": 0}},"config": {@@ -1013,7 +1014,8 @@ 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, "SealUprobe": 0+ "SealSignal": 0, "SealCoreDump": 0, "SealUprobe": 0,+ "ExecShared": 0}}diff --git a/Documentation/security/tamper-counters.rst b/Documentation/security/tamper-counters.rstindex 674c706c..48812621 100644--- a/Documentation/security/tamper-counters.rst+++ b/Documentation/security/tamper-counters.rst@@ -231,6 +231,13 @@ counter.its authority for good, and the hook refuses the operation andmoves its own counter- the hook's+ * - ``ExecShared``+ - exec of the runtime binary by a task that shares its file system+ context+ - ``lsm.s/bprm_check_security``: an exec of the runtime binary+ while another process shares the task's root and working+ directory (``CLONE_FS``)+ - ``EACCES``Unless the row says every caller, a task with runtime authority isnot refused and moves nothing.diff --git a/Documentation/security/threat-model.rst b/Documentation/security/threat-model.rstindex 38aa199e..3772eb5a 100644--- a/Documentation/security/threat-model.rst+++ b/Documentation/security/threat-model.rst@@ -834,8 +834,10 @@ An authorized process is protected against being taken over:without authority (``SealSignal``) and lets it through: root can stopa command (R2, U17), and the count shows that it did.- The exec of a runtime file by a traced task is refused- (``ExecTraced``), and so is one under a seccomp filter, without a- counter.+ (``ExecTraced``), and so is one by a task that shares its root and+ working directory with another process (``ExecShared``), which could+ ``chroot`` or ``chdir`` the command while it runs, and one under a+ seccomp filter, without a counter.- ``lsm/bprm_check_security`` in the ``bpf2`` object runs everyruntime executable in secure-exec mode, so the C library ignores theloader variables, and shirudo itself is static.@@ -888,12 +890,13 @@ An authorized process is protected against being taken over:``SealSetattr``, ``SealXattr``, ``SealLabel``, ``SealEntry``,``SealCopyUp``, ``KeyringWrite``, ``SealPtrace``, ``SealPerf``,``SealSignal``, ``SealCoreDump``, ``SealUprobe``, ``ExecTraced``,+ ``ExecShared``,``ExeIdentity``:Tests: ``t6001``, ``t6006``, ``t6007``, ``t6110``, ``t6111``,``t6112``, ``t6113``, ``t6114``, ``t6115``, ``t6118``, ``t6123``,``t6124``, ``t6127``, ``t6129``, ``t6131``, ``t6133``, ``t6134``,``t6135``, ``t6136``, ``t6137``, ``t6144``, ``t6145``, ``t6146``,- ``t6149``, ``t6150``+ ``t6149``, ``t6150``, ``t6152``:Residual: R2, R19, R22T4 Substituting artifactsdiff --git a/Makefile.shirudo b/Makefile.shirudoindex 576862e6..340d086c 100644--- a/Makefile.shirudo+++ b/Makefile.shirudo@@ -776,6 +776,7 @@ TEST_HELPERS := $(VERITY_TEST_HELPERS) \testing/helper/test-bpf-load \testing/helper/test-bpf-cmd \testing/helper/test-exec-fail \+ testing/helper/test-exec-shared \testing/helper/test-perf-attach \testing/helper/test-otel-map \testing/helper/test-upatch-map-types \@@ -918,6 +919,10 @@ testing/helper/test-exec-fail: testing/helper/test-exec-fail.c@printf ' CC $@\n'$(Q)$(CC) $(CFLAGS) -o $@ $^+testing/helper/test-exec-shared: testing/helper/test-exec-shared.c+ @printf ' CC $@\n'+ $(Q)$(CC) $(CFLAGS) -o $@ $^+testing/helper/test-perf-attach: testing/helper/test-perf-attach.c@printf ' CC $@\n'$(Q)$(CC) $(CFLAGS) -I$(BPF_UAPI_INCLUDE) -o $@ $^diff --git a/bpf/lib/tamper.h b/bpf/lib/tamper.hindex ce96cb48..928cd62d 100644--- a/bpf/lib/tamper.h+++ b/bpf/lib/tamper.h@@ -51,6 +51,7 @@ enum tamper_point {TAMPER_SEAL_SIGNAL,TAMPER_SEAL_CORE_DUMP,TAMPER_SEAL_UPROBE,+ TAMPER_EXEC_SHARED,TAMPER_MAX};diff --git a/bpf/seal.c b/bpf/seal.cindex d117c279..3eb19175 100644--- a/bpf/seal.c+++ b/bpf/seal.c@@ -708,10 +708,14 @@ int BPF_PROG(shirudo_seal_bprm_creds_for_exec, struct linux_binprm *bprm,return 0;}+#define LSM_UNSAFE_SHARE 1+/** shirudo grants authority only to a direct file on the verified runtime.* Overlay copies cannot qualify. Ptrace or seccomp supplied before exec must- * not control the new trusted process. A failed exec retains the old mark.+ * not control the new trusted process, nor a process that shares its root+ * and working directory, which exec does not unshare. A failed exec retains+ * the old mark.*/SEC("lsm.s/bprm_check_security")int BPF_PROG(shirudo_seal_bprm_check_security,@@ -751,6 +755,8 @@ int BPF_PROG(shirudo_seal_bprm_check_security,shirudo_file_runtime(bprm->file);if (trusted && BPF_CORE_READ(task, ptrace))return shirudo_tamper_deny(TAMPER_EXEC_TRACED, -EACCES);+ if (trusted && (BPF_CORE_READ(bprm, unsafe) & LSM_UNSAFE_SHARE))+ return shirudo_tamper_deny(TAMPER_EXEC_SHARED, -EACCES);if (trusted && shirudo_task_has_seccomp(task))return -EACCES;authority = bpf_task_storage_get(&shirudo_tasks, task, NULL,diff --git a/testing/fixtures/keepalive/node-a-1.0.0.json b/testing/fixtures/keepalive/node-a-1.0.0.jsonindex 6c615bf2..daf86a6d 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,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,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 filediff --git a/testing/fixtures/keepalive/node-a-1.1.0.json b/testing/fixtures/keepalive/node-a-1.1.0.jsonindex ecba2d1e..81379516 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,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,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 filediff --git a/testing/fixtures/keepalive/node-b-1.0.0.json b/testing/fixtures/keepalive/node-b-1.0.0.jsonindex 737c6a54..7c6bf655 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,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,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 filediff --git a/testing/fixtures/keepalive/node-b-1.1.0.json b/testing/fixtures/keepalive/node-b-1.1.0.jsonindex 04c3abad..12da5921 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,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,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 filediff --git a/testing/fixtures/keepalive/ops-16.json b/testing/fixtures/keepalive/ops-16.jsonindex a1eabe54..47530972 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,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,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 filediff --git a/testing/fixtures/keepalive/quotes.tsv b/testing/fixtures/keepalive/quotes.tsvindex 9738b1af..f1ee1f3d 100644--- a/testing/fixtures/keepalive/quotes.tsv+++ b/testing/fixtures/keepalive/quotes.tsv@@ -1,4 +1,4 @@-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+node-a-1.0.0.json /1RDR4AYACIAC6g5pzR1aKcWDeiOfwjwtf5XxZ9BVaT6eYTStcbVHDGzACBUVp05I5kSn+uYG2wCWnPITsgwEP4XtU9lCCqPRIZg/QAAAAAAAAAJAAAAAAAAAAABIBkQIwAWNjYAAAABAAsDAAAAACDjsMRCmPwcFJr79MiZb7kkJ65B5GSbk0yklZkbeFK4VQ== ABgACwAgGdPq8y/bh8Xf5aAE7VYzjssKiCHSzOJczHEcte72dZcAIEg17/dY5efOKfr8Jjy8IjsIm64XATm+IBpjRi2Xk+PW ACMACwAFAHIAAAAQABgACwADABAAIPH0oXsS7TbVbWJ2dns42uteKlcvs3RJCu/m6bdv1h/aACDppRuefM1dDFxLHlEVeI9USkrN5LBXFiIh4EtpKwsp1g== 54569d392399129feb981b6c025a73c84ec83010fe17b54f65082a8f448660fd+node-a-1.1.0.json /1RDR4AYACIAC6g5pzR1aKcWDeiOfwjwtf5XxZ9BVaT6eYTStcbVHDGzACBRCQb08KpPeWEJLPQdMO+acYOzDoP/BD+8V50265vuMQAAAAAAAAAbAAAAAAAAAAABIBkQIwAWNjYAAAABAAsDAAAAACDjsMRCmPwcFJr79MiZb7kkJ65B5GSbk0yklZkbeFK4VQ== ABgACwAgstoIbbCbJl04us+3WU8VmbnWN6aLwxCLJQDmznQWnh4AIEYfyG9k0QWeZRq6LRlErGaa1LRAaFX+iGpIeT4HCwSQ ACMACwAFAHIAAAAQABgACwADABAAIPH0oXsS7TbVbWJ2dns42uteKlcvs3RJCu/m6bdv1h/aACDppRuefM1dDFxLHlEVeI9USkrN5LBXFiIh4EtpKwsp1g== 510906f4f0aa4f7961092cf41d30ef9a7183b30e83ff043fbc579d36eb9bee31+node-b-1.0.0.json /1RDR4AYACIAC2Gm27OAwZ9VyAugoPReFl7LRGZ00wXC3pm7OixDcFmZACDTe2TD6WPChtm1FHQKUZhHitndUVRwfaVFGXDY40qlsAAAAAAAAAAJAAAAAAAAAAABIBkQIwAWNjYAAAABAAsDAAAAACDjsMRCmPwcFJr79MiZb7kkJ65B5GSbk0yklZkbeFK4VQ== ABgACwAg6HK93DHg0OiHH9GfFKzMVOWaptBwgFfPW8YAd6NSkOsAIPnEfoiRKlVCggRRhbjQMN01svaQgj8u4wHoc/s26Cug ACMACwAFAHIAAAAQABgACwADABAAIAHAteZRrmI/aXfBdmgB+/MA3EZ7Ng7ctI8moukmgSjdACBM/X0qACJhDZR/pLchNIrX/cZ+mG9zi6dia+l9sT0i6A== d37b64c3e963c286d9b514740a5198478ad9dd5154707da5451970d8e34aa5b0+node-b-1.1.0.json /1RDR4AYACIAC2Gm27OAwZ9VyAugoPReFl7LRGZ00wXC3pm7OixDcFmZACDbxZUSdvWxq9cRdDiUzk3o19H6gxmaKakw7E4KJB5mjQAAAAAAAAAaAAAAAAAAAAABIBkQIwAWNjYAAAABAAsDAAAAACDjsMRCmPwcFJr79MiZb7kkJ65B5GSbk0yklZkbeFK4VQ== ABgACwAguKRxC6oOC+rp8k+X9NH7L/LwDjwU5RAStE397GAHNVQAINhQ4K1nS6BpgCj0Bbj6ziHSXi8mXdulrY8Mjft/DF9M ACMACwAFAHIAAAAQABgACwADABAAIAHAteZRrmI/aXfBdmgB+/MA3EZ7Ng7ctI8moukmgSjdACBM/X0qACJhDZR/pLchNIrX/cZ+mG9zi6dia+l9sT0i6A== dbc5951276f5b1abd711743894ce4de8d7d1fa83199a29a930ec4e0a241e668ddiff --git a/testing/fixtures/keepalive/recompute.py b/testing/fixtures/keepalive/recompute.pyindex d77381f7..7f0ba74e 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 = 39+TAMPER_COUNTERS = 40ALL_OK = 0x1555OPERATION_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 = 736+PAGE_BODY_LEN = 738PAGE_BODY_SHA256 = \- "2c133a5d34993e3370c521e2868d6c9f16ec22b952e7a16b1478b37bb717f0b4"+ "387a1917e56c2e73478982a50df323289fd648195afe5baa3f3c37ef8ad1f724"PAGE_COND = 0x555VERSION_ID = "d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f"diff --git a/testing/functional/tamperproof/t6152-exec-shared.sh b/testing/functional/tamperproof/t6152-exec-shared.shnew file mode 100755index 00000000..45d26a0a--- /dev/null+++ b/testing/functional/tamperproof/t6152-exec-shared.sh@@ -0,0 +1,38 @@+#!/bin/sh+# SPDX-License-Identifier: BSD-2-Clause+# Copyright (c) 2026 Authors of shirudo+#+# t6152 -- the runtime binary is not exec'd by a task that shares its root+# and working directory with another process, which could chroot or chdir+# the authorized command while it runs: the exec is refused and counted+# as ExecShared, and an exec of any other program that way still works.++cd "$(dirname "$0")/../.."+. ./integration-lib.sh+target_guard+command -v python3 >/dev/null 2>&1 || test_skip_all "no python3"+H=helper/test-exec-shared+[ -x "$H" ] || test_skip_all "test-exec-shared helper not built"+RUNTIME=$(runtime_binary)+W=$(mktemp -d)+trap 'rm -rf "$W"' EXIT+counter() {+ "$SHIRUDO_BIN" status --json | python3 -c '+import json, sys+print(json.load(sys.stdin)["tamper_attempts"]["counters"][sys.argv[1]])+' "$1"+}+before=$(counter ExecShared) || test_skip_all "no tamper counters"++test_expect_success 'another program execs with a shared file system context' '+ "$H" /bin/true+'+test_expect_success 'the runtime binary does not, and the refusal counts' '+ if "$H" "$RUNTIME" version >"$W/out" 2>"$W/err"; then false; fi &&+ grep -q "Permission denied" "$W/err" &&+ [ "$(counter ExecShared)" -gt "$before" ]+'+test_expect_success 'and runs as before without the sharing' '+ "$RUNTIME" version >/dev/null+'+test_donediff --git a/testing/helper/test-exec-shared.c b/testing/helper/test-exec-shared.cnew file mode 100644index 00000000..3ca8840d--- /dev/null+++ b/testing/helper/test-exec-shared.c@@ -0,0 +1,44 @@+// SPDX-License-Identifier: BSD-2-Clause+/*+ * Copyright (c) 2026 Authors of shirudo+ *+ * Execs a program in a child that shares this process's root and working+ * directory, as clone(CLONE_FS) leaves them, while this process waits,+ * and exits as the child did, or with 126 when its exec failed.+ */++#include <errno.h>+#include <sched.h>+#include <signal.h>+#include <stdio.h>+#include <string.h>+#include <unistd.h>+#include <sys/syscall.h>+#include <sys/wait.h>++int main(int argc, char **argv)+{+ int status;+ long pid;++ if (argc < 2) {+ fprintf(stderr, "usage: %s <program> [<argument>...]\n",+ argv[0]);+ return 2;+ }+ pid = syscall(SYS_clone, CLONE_FS | SIGCHLD, 0, 0, 0, 0);+ if (pid < 0) {+ fprintf(stderr, "clone: %s\n", strerror(errno));+ return 2;+ }+ if (!pid) {+ execv(argv[1], argv + 1);+ fprintf(stderr, "execv %s: %s\n", argv[1], strerror(errno));+ _exit(126);+ }+ if (waitpid((pid_t)pid, &status, 0) < 0) {+ fprintf(stderr, "waitpid: %s\n", strerror(errno));+ return 2;+ }+ return WIFEXITED(status) ? WEXITSTATUS(status) : 2;+}diff --git a/testing/proofs/cbmc/proofs.list b/testing/proofs/cbmc/proofs.listindex a06c9157..f44bb24b 100644--- a/testing/proofs/cbmc/proofs.list+++ b/testing/proofs/cbmc/proofs.list@@ -56,7 +56,7 @@ log-escape --unwind 7 LEN=0-5json-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-4json-emit-buffer --unwind 1 --unwindset json_raw_value.0:5,harness.0:5 --malloc-may-fail --malloc-fail-null LEN=0-4json-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: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+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:41,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-3json-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-6json-escape --unwind 5 --unwindset parse_string.0:4,memcmp.0:9json-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-4diff --git a/testing/unit/keepalive.c b/testing/unit/keepalive.cindex 581e33ef..777ddbea 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", "SealUprobe",+ "SealCoreDump", "SealUprobe", "ExecShared",};static void tamper_counters_keep_their_places(void){size_t i;- ASSERT_EQ(ARRAY_SIZE(tamper_order), 39);+ ASSERT_EQ(ARRAY_SIZE(tamper_order), 40);ASSERT_EQ(TAMPER_MAX, ARRAY_SIZE(tamper_order));EXPECT_EQ(TAMPER_LOAD_NOT_LOADER, 0);- EXPECT_EQ(TAMPER_SEAL_UPROBE, TAMPER_MAX - 1);+ EXPECT_EQ(TAMPER_EXEC_SHARED, 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,39],\"tree_id\":");+ "34,35,36,18446744073709551615,38,39,40],\"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, 3340);+ EXPECT_EQ(whole, 3361);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/testing/vm/build-bundle-payload.sh b/testing/vm/build-bundle-payload.shindex 75e483a2..11eb2020 100755--- a/testing/vm/build-bundle-payload.sh+++ b/testing/vm/build-bundle-payload.sh@@ -100,6 +100,7 @@ testing/helper/test-configtesting/helper/test-bpf-loadtesting/helper/test-bpf-cmdtesting/helper/test-exec-fail+testing/helper/test-exec-sharedtesting/helper/test-perf-attachtesting/helper/test-otel-maptesting/helper/test-upatch-map-typesdiff --git a/util/tamper.c b/util/tamper.cindex 85d06fb5..25febd8d 100644--- a/util/tamper.c+++ b/util/tamper.c@@ -98,6 +98,8 @@ static const struct {"core dump of a shirudo task, which acts without authority" },[TAMPER_SEAL_UPROBE] = { "SealUprobe","uprobe in a shirudo task, which acts without authority" },+ [TAMPER_EXEC_SHARED] = { "ExecShared",+ "exec of the runtime binary by a task that shares its file system context" },};const char *tamper_name(enum tamper_point point)