eBPF-based security platform
docs: say what the mount guards refuse PID 1 after the root switch
John Fastabend838ae008207a
diff --git a/Documentation/internals/enforcement.rst b/Documentation/internals/enforcement.rstindex a08567de..98f52ebf 100644--- a/Documentation/internals/enforcement.rst+++ b/Documentation/internals/enforcement.rst@@ -404,9 +404,12 @@ Hooks in bpf2bpffs mount survives on the target root. A walk beyond 1024mounts, 32 levels or 4 masters is refused.* - ``lsm/sb_pivotroot``- - A pivot in the namespace containing the recorded bpffs. Host- PID 1 may pivot from the recorded initrd root to the recorded- target root.+ - To every caller: a pivot in the namespace containing the recorded+ bpffs. Host PID 1 may pivot from the recorded initrd root to the+ recorded target root. That exception ends with the handoff, and+ PID 1's later pivots are refused like any other: a return to+ ``/run/initramfs`` at shutdown and a soft reboot into+ ``/run/nextroot``, see :doc:`/operate/plan/interoperability`.- ``EPERM`` and ``BpffsUmountAbove``.- A pivot in another mount namespace proceeds.* - ``lsm/move_mount``@@ -425,7 +428,9 @@ Hooks in bpf2initrd handoff. A legacy ``MS_MOVE`` onto any mount of therecorded bpffs's mount namespace, which reaches the hook withoutits source, with the same PID 1 exception; ``move_mount(2)``- moves a mount there. A mount onto a+ moves a mount there. After the handoff the exception is over, and+ PID 1's request to make ``/`` private at shutdown or for a soft+ reboot is refused. A mount onto apath in ``/run/shirudo`` or on a config image to a task withoutauthority. The source of a bind is not checked.- ``EPERM``: ``BpffsMount``; others uncounteddiff --git a/Documentation/operate/plan/interoperability.rst b/Documentation/operate/plan/interoperability.rstindex ef24706a..bb1d11f4 100644--- a/Documentation/operate/plan/interoperability.rst+++ b/Documentation/operate/plan/interoperability.rst@@ -273,6 +273,45 @@ kexec and kdumpsecond kernel, such as pstore, which shirudo does not hook. Rebootthrough the firmware instead of kexec.+Shutdown initramfs and soft reboot+----------------------------------++:Mechanism: The mount guards keep the private bpffs and every mount above+ it in place in the host's mount namespace, so that nothing detaches+ the pins (R3 in :doc:`/security/threat-model`). Host PID 1 is exempt+ only while it switches from the initrd root to the root file system,+ and the exemption ends when it has unmounted the initrd root. From+ then on ``lsm/sb_mount`` refuses every caller a legacy request to make+ ``/`` or another mount above the bpffs private and a legacy+ ``MS_MOVE`` in that namespace, and ``lsm/sb_pivotroot`` every pivot+ there. systemd changes root a second time in two places, both as+ PID 1: ``systemd-shutdown`` returns to a shutdown initramfs unpacked+ at ``/run/initramfs``, and a soft reboot enters ``/run/nextroot``.+ Each begins by making ``/`` recursively private, then pivots, then+ falls back to ``MS_MOVE``.+:Symptom: Every shutdown moves ``BpffsMount`` once: ``systemd-shutdown``+ asks for private mounts before it unmounts, logs ``Failed to make+ mounts private, ignoring`` and goes on. With an executable+ ``/run/initramfs/shutdown`` it then logs ``Failed to set "/" mount+ propagation to private: Operation not permitted`` and ``Failed to+ switch root to "/run/initramfs"``, moves ``BpffsMount`` again, does+ not run the shutdown initramfs and reboots, halts or powers off from+ the root file system. Storage below the root that only the shutdown+ initramfs detaches, such as device mapper, MD RAID or a network block+ device, is not detached before the reset. ``systemctl soft-reboot``+ with an operating system tree at ``/run/nextroot`` logs ``Failed to+ switch root, trying to continue`` and restarts userspace on the root+ it had. A caller that reaches the pivot is refused with ``EPERM`` and+ moves ``BpffsUmountAbove``. This is a reading of the hooks and of the+ systemd 259 source and is not tested on a target; ``t6158`` covers+ the refusals themselves.+:What to do: Do not rely on a shutdown initramfs on targets, and choose+ root storage that is consistent once ``systemd-shutdown`` has+ remounted it read-only. Do not place a tree at ``/run/nextroot``:+ change the root file system with a full reboot, which also gives the+ new root a boot of its own to be measured in. Count the shutdown's+ ``BpffsMount`` into the baseline of your hosts.+Module loading and kernel live patching---------------------------------------diff --git a/Documentation/security/tamper-counters.rst b/Documentation/security/tamper-counters.rstindex 555a61df..8b379498 100644--- a/Documentation/security/tamper-counters.rst+++ b/Documentation/security/tamper-counters.rst@@ -124,7 +124,8 @@ counter.reaches the recorded bpffs mount, or a tree the walk cannotfinish, with the checked initrd handoff exception.``lsm/sb_pivotroot`` counts a refused pivot in the protected- namespace. ``lsm/inode_rmdir``,+ namespace, one by host PID 1 after the initrd handoff+ included. ``lsm/inode_rmdir``,``lsm/inode_unlink``, ``lsm/inode_rename``: the removal or renameof the mount point of that mount or of one above it, whichdetaches or moves the mounts on it in every namespace, to a task@@ -132,7 +133,8 @@ counter.- ``EPERM``* - ``BpffsMount``- move, mount over or remount of the private bpffs, or a refused- legacy propagation change on its mount ancestry+ legacy propagation change on its mount ancestry, which systemd+ requests at every shutdown- ``lsm/move_mount``, ``lsm/sb_mount``, ``lsm/sb_remount``, everycaller- ``EPERM``