eBPF-based security platform
bpf: keep the bpffs guarded across the systemd root switch
KP Singh8978bc8a5cfb
diff --git a/Documentation/contribute/testing/test-coverage.rst b/Documentation/contribute/testing/test-coverage.rstindex eda2f4cb..8b3dcfb7 100644--- a/Documentation/contribute/testing/test-coverage.rst+++ b/Documentation/contribute/testing/test-coverage.rst@@ -414,7 +414,8 @@ signed config image.* - ``t4101-initrd``- The production configuration: ``init`` from the initrd, itsmessages in the journal once, adoption, PCR 11 after the binding,- pins under ``/run``+ pins under ``/run``, a successful PID 1 pivot in the TPM guest,+ shared propagation and unchanged mount tamper counts* - ``t4102-tpm-chain``- Replay, measured load and unload, evidence from the VM's TPM,challenges with ECC and RSA endorsement keysdiff --git a/Documentation/internals/enforcement.rst b/Documentation/internals/enforcement.rstindex 40f206d7..0414a970 100644--- a/Documentation/internals/enforcement.rst+++ b/Documentation/internals/enforcement.rst@@ -400,8 +400,15 @@ Hooks in bpf2config image to a task without authority.- ``EPERM``: ``BpffsUmount``, ``BpffsUmountAbove``; imageand ``/run/shirudo`` refusals uncounted- - Closed: a walk beyond 1024 mounts, 32 levels or 4 masters is- refused.+ - Host PID 1 may detach the recorded initrd root once a matching+ bpffs mount survives on the target root. A walk beyond 1024+ mounts, 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.+ - ``EPERM`` and ``BpffsUmountAbove``.+ - A pivot in another mount namespace proceeds.* - ``lsm/move_mount``- To every caller: moving the bpffs, the ``/run/shirudo`` mount orthe runtime image, or moving a mount onto the bpffs or the runtime@@ -410,8 +417,10 @@ Hooks in bpf2- ``EPERM``: ``BpffsMount``; others uncounted- Closed.* - ``lsm/sb_mount``- - To every caller: a mount onto the bpffs or the runtime image, and- a propagation change of the ``/run/shirudo`` mount. A mount onto a+ - A mount onto the bpffs or runtime image. A legacy propagation+ change on the bpffs or its ancestry, with the host PID 1+ exceptions for the initrd handoff and restoring shared mounts.+ A mount onto apath in ``/run/shirudo`` or on a config image to a task withoutauthority. The source of a bind or legacy move is not checked.- ``EPERM``: ``BpffsMount``; others uncounted@@ -638,9 +647,9 @@ The hooks decide only what reaches them. These paths do not:``lsm/file_ioctl`` refuse the ``bpf()`` attach commands and the perfioctl to tasks without authority; other kernel interfaces that take aprogram descriptor are not hooked here.-- ``mount_setattr(2)`` has no LSM hook, ``pivot_root(2)`` is not hooked,- and ``lsm/sb_mount`` does not check the source of a bind or legacy- move.+- On the pinned kernel, propagation changes through ``mount_setattr(2)``+ have no LSM hook. The source of a bind or legacy move is absent from+ ``lsm/sb_mount``.- A perf event bound to a task before that task execs the runtime imagesurvives the exec, and CPU-wide events and probes on the runtimebinary are not checked.diff --git a/Documentation/security/tamper-counters.rst b/Documentation/security/tamper-counters.rstindex 6882edba..555a61df 100644--- a/Documentation/security/tamper-counters.rst+++ b/Documentation/security/tamper-counters.rst@@ -119,17 +119,20 @@ counter.- ``lsm/sb_umount``: the bpffs superblock, every caller- ``EPERM``* - ``BpffsUmountAbove``- - unmount of a mount above the private bpffs+ - unmount of a mount above the private bpffs or a refused host pivot- ``lsm/sb_umount``: an unmount whose subtree or propagationreaches the recorded bpffs mount, or a tree the walk cannot- finish, every caller; ``lsm/inode_rmdir``,+ finish, with the checked initrd handoff exception.+ ``lsm/sb_pivotroot`` counts a refused pivot in the protected+ namespace. ``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 taskwithout authority- ``EPERM``* - ``BpffsMount``- - move, mount over or remount of the private bpffs+ - move, mount over or remount of the private bpffs, or a refused+ legacy propagation change on its mount ancestry- ``lsm/move_mount``, ``lsm/sb_mount``, ``lsm/sb_remount``, everycaller- ``EPERM``diff --git a/Documentation/security/threat-model.rst b/Documentation/security/threat-model.rstindex 6b6e65bd..f5b5f9c7 100644--- a/Documentation/security/threat-model.rst+++ b/Documentation/security/threat-model.rst@@ -651,6 +651,14 @@ move, a mount over or a remount of the private bpffs (``BpffsUmount``,``BpffsMount``). Figure 2 shows the two ways an operation on a mount farfrom the bpffs takes it along.+Bootstrap in the initrd records the unique mount IDs of its root and the+target root. In the protected namespace, only host PID 1 can pivot from+the first to the second. It may change propagation on the bpffs ancestry+while it is on the initrd root and restore shared propagation after the+switch. Before allowing the old root to detach, the unmount guard checks+that the new root has a copy of the same bpffs subtree outside the reach+of the unmount and transfers its protection to that copy.+.. figure:: /images/security-bpffs-mounts.svg:alt: Three mount namespaces. In init's, the root, /run, the/run/shirudo tmpfs and the recorded bpffs nest in that order;@@ -709,7 +717,7 @@ and the returned link's ifindex around attachment.``lsm/inode_rename``, ``lsm/inode_mkdir``, ``lsm/inode_symlink``,``lsm/inode_link``, ``lsm/inode_rmdir``, ``lsm/inode_setxattr``,``lsm/inode_removexattr``, ``lsm/sb_umount``, ``lsm/move_mount``,- ``lsm/sb_mount``, ``lsm/sb_remount``+ ``lsm/sb_mount``, ``lsm/sb_remount``, ``lsm/sb_pivotroot``:Refusal: ``EACCES`` from ``bpf()``, from opening a pin and from theperf ioctl; ``EPERM`` from the inode and mount guards;``attach_scope_mismatch`` from ``shirudo upatch load``@@ -1672,8 +1680,8 @@ R3 Pins depend on the mount treenamespace. A private copy of the tree in another namespace is anyprocess's to drop, which releases nothing. Legacy ``mount(2)`` with``MS_MOVE`` reaches ``lsm/sb_mount`` with the target only, so the- source mount is not checked (D8). ``pivot_root(2)`` is not hooked,- and ``mount_setattr(2)`` has no LSM hook at all, so root can change+ source mount is not checked (D8). On the pinned kernel,+ ``mount_setattr(2)`` has no propagation hook, so root can changemount attributes and propagation, making the bpffs read-only forinstance. A mount over ``/run`` or an ancestor hides the pins withoutreleasing them: enforcement continues, ``shirudo status`` reports the@@ -2256,26 +2264,12 @@ D10 A payload type in the signed messagecan describe, and the reverse, without resting on the signedsections that follow (T15).-D11 Protect the bpffs mount through systemd switch-root- Guard pivots and propagation changes in the mount namespace that- holds the recorded bpffs (R3). Allow host PID 1 to change propagation- and pivot during the initrd handoff. End this exception once PID 1- has unmounted the recorded old root. Allow PID 1 to make the mounts- shared again after the handoff.-- In the proposed BPF hook, split nested CO-RE reads and read the- stored pointer directly from the map value before using CO-RE to- read the kernel mount's namespace. Check that the hook builds and- loads. Boot a systemd initrd that switches root and verify that it- attests, the protected mounts are shared and the mount tamper counter- stays unchanged. See the `switch-root review on PR 213- <https://github.com/shirudo-dev/shirudo/pull/213#issuecomment-7111239313>`__.-- Cover propagation changes through both ``mount(2)`` and- ``mount_setattr(2)``. The latter needs a kernel hook. Test each- interface directly. Check that other host tasks cannot make the- protected tree private and that unrelated mounts stay usable. See- the `propagation test review+D11 Propagation changes through the new mount API+ The pivot and legacy propagation guards cover the initrd handoff (T2).+ The pinned kernel still needs an LSM hook for propagation changes+ through ``mount_setattr(2)``, including recursive changes. Compare+ both interfaces when testing a kernel with that hook. See the+ `propagation review on PR 213<https://github.com/shirudo-dev/shirudo/pull/213#issuecomment-7111496290>`__.Out of scopediff --git a/bpf/bpf2.c b/bpf/bpf2.cindex 5ecea018..5849932b 100644--- a/bpf/bpf2.c+++ b/bpf/bpf2.c@@ -718,6 +718,14 @@ char _license[] SEC("license") = "Dual BSD/GPL";#define MOUNT_WALK_MAX 1024#define MOUNT_DEPTH_MAX 32#define MOUNT_MASTERS_MAX 4+#define MOUNT_CHILDREN_MAX 64+#define MOUNT_CHAIN_MAX 8+#define SHIRUDO_MNT_DETACH 2+#define SHIRUDO_MS_REC (1UL << 14)+#define SHIRUDO_MS_SILENT (1UL << 15)+#define SHIRUDO_MS_SHARED (1UL << 20)+/* MS_UNBINDABLE, MS_PRIVATE, MS_SLAVE and MS_SHARED from linux/mount.h. */+#define PROPAGATION_TYPES ((1UL << 17) | (1UL << 18) | (1UL << 19) | SHIRUDO_MS_SHARED)static __always_inline struct mount *shirudo_mount_of(struct vfsmount *mnt){@@ -840,37 +848,146 @@ static __always_inline int shirudo_mount_next_sibling(struct mount *t,* it. The namespace lock is not held here, so a tree that cannot be* walked within the bounds is refused rather than taken for safe.*/-static __always_inline int shirudo_umount_above(struct vfsmount *mnt)+static __always_inline bool shirudo_umount_takes(struct mount *t,+ struct mount *bpffs){- struct mount *t, *m, *bpffs;- struct mount_record *rec;- __u32 zero = 0;+ struct mount *m = t;__u64 next;int i, ret;- rec = bpf_map_lookup_elem(&shirudo_mnt_rec, &zero);- if (!rec || !rec->mount)- return 0;- bpffs = (struct mount *)rec->mount;- t = shirudo_mount_of(mnt);- m = t;bpf_for(i, 0, MOUNT_WALK_MAX) {if (shirudo_umount_takes_bpffs(m, bpffs))- goto deny;+ return true;next = (__u64)BPF_CORE_READ(m, mnt_mounts.next);if (!next)- goto deny;+ return true;if (next != shirudo_mount_children(m)) {m = shirudo_mount_child(next);continue;}ret = shirudo_mount_next_sibling(t, &m);if (!ret)- return 0;+ return false;if (ret < 0)- goto deny;+ return true;+ }+ return true;+}++/* A recursive bind preserves the mounted subtree root and its child mountpoints. */+static __always_inline struct mount *+shirudo_mount_find_child(struct mount *parent, struct mount *skip,+ struct mount *original, bool same_mountpoint)+{+ __u64 head = shirudo_mount_children(parent), next;+ struct super_block *sb = BPF_CORE_READ(original, mnt.mnt_sb);+ struct dentry *root = BPF_CORE_READ(original, mnt.mnt_root);+ struct mountpoint *mp = BPF_CORE_READ(original, mnt_mp);+ struct mount *child;+ int i;++ if (!sb || !root || (same_mountpoint && !mp))+ return NULL;++ next = (__u64)BPF_CORE_READ(parent, mnt_mounts.next);+ bpf_for(i, 0, MOUNT_CHILDREN_MAX) {+ if (!next || next == head)+ return NULL;+ child = shirudo_mount_child(next);+ if (child != skip &&+ BPF_CORE_READ(child, mnt.mnt_sb) == sb &&+ BPF_CORE_READ(child, mnt.mnt_root) == root &&+ (!same_mountpoint || BPF_CORE_READ(child, mnt_mp) == mp))+ return child;+ next = (__u64)BPF_CORE_READ(child, mnt_child.next);+ }+ return NULL;+}++/*+ * PID 1 leaves the initrd by binding /run recursively into the new+ * root, pivot_root(".", ".") and a lazy unmount of the old root, now+ * stacked on the new root's own root. The recorded bpffs mount goes+ * with the old root while the recursive copy of it keeps the superblock+ * mounted. That one unmount, once per boot, may hand the record over+ * to the copy: return the copy when the caller is PID 1, the unmount is+ * lazy, t is stacked on PID 1's root and the record lies below t, as+ * the bpffs on the /run/shirudo tmpfs on systemd's /run. The copy is+ * found by following the same chain down from the new root: a child of+ * it on the superblock of the chain's top below t, then at each level a+ * child on the next superblock at the same mountpoint, which a+ * recursive bind reuses. A soft reboot binds /run alone and finds none.+ */+static __always_inline struct mount *+shirudo_root_switch_copy(struct mount *t, int flags,+ const struct mount_record *rec, struct mount *bpffs)+{+ struct task_struct *task = bpf_get_current_task_btf();+ __u64 chain[MOUNT_CHAIN_MAX] = {};+ struct mount *root, *a, *orig, *copy;+ int i, level, depth = 0;++ if (!(flags & SHIRUDO_MNT_DETACH) ||+ (__u32)bpf_get_current_pid_tgid() != 1 || !rec->initrd_root_id ||+ BPF_CORE_READ(t, mnt_id_unique) != rec->initrd_root_id)+ return NULL;+ root = shirudo_mount_of(BPF_CORE_READ(task, fs, root.mnt));+ if (BPF_CORE_READ(root, mnt_id_unique) != rec->sysroot_id ||+ BPF_CORE_READ(t, mnt_parent) != root ||+ BPF_CORE_READ(t, mnt_mp, m_dentry) !=+ BPF_CORE_READ(task, fs, root.dentry))+ return NULL;+ a = bpffs;+ bpf_for(i, 0, MOUNT_CHAIN_MAX) {+ if (!a || a == t || a == root)+ break;+ chain[i] = (__u64)a;+ depth = i + 1;+ a = BPF_CORE_READ(a, mnt_parent);+ }+ if (a != t || !depth)+ return NULL;+ copy = root;+ bpf_for(i, 0, MOUNT_CHAIN_MAX) {+ level = depth - 1 - i;+ if (level < 0 || level >= MOUNT_CHAIN_MAX)+ break;+ orig = (struct mount *)chain[level];+ copy = shirudo_mount_find_child(copy, i ? NULL : t, orig, i != 0);+ if (!copy)+ return NULL;+ }+ return copy == root ? NULL : copy;+}++/*+ * Refuse an unmount that takes the recorded bpffs mount or one above+ * it, except PID 1's switch from the initrd, which keeps a copy of it+ * mounted and records that copy in its place.+ */+static __always_inline int shirudo_umount_above(struct vfsmount *mnt,+ int flags)+{+ struct mount_record *rec;+ struct mount *t, *copy, *bpffs;+ __u32 zero = 0;++ rec = bpf_map_lookup_elem(&shirudo_mnt_rec, &zero);+ if (!rec)+ return 0;+ bpffs = (struct mount *)rec->mount;+ if (!bpffs)+ return 0;+ t = shirudo_mount_of(mnt);+ if (!shirudo_umount_takes(t, bpffs))+ return 0;+ copy = shirudo_root_switch_copy(t, flags, rec, bpffs);+ if (copy && !shirudo_umount_takes(t, copy) &&+ __sync_val_compare_and_swap(&rec->mount, (__u64)bpffs,+ (__u64)copy) == (__u64)bpffs) {+ rec->initrd_root_id = 0;+ return 0;}-deny:return shirudo_tamper_deny(TAMPER_BPFFS_UMOUNT_ABOVE, -EPERM);}@@ -927,8 +1044,13 @@ int BPF_PROG(shirudo_lsm_file_open, struct file *file, int ret)if (!shirudo_bootstrap_task())return 0;rec = bpf_map_lookup_elem(&shirudo_mnt_rec, &zero);- if (rec && !rec->mount)- rec->mount = (__u64)shirudo_mount_of(mnt);+ if (rec && !rec->mount) {+ struct mount *mount = shirudo_mount_of(mnt);++ rec->mount_ns = (__u64)BPF_CORE_READ(mount, mnt_ns);+ if (rec->mount_ns)+ rec->mount = (__u64)mount;+ }return 0;}@@ -981,7 +1103,7 @@ int BPF_PROG(shirudo_lsm_sb_umount, struct vfsmount *mnt, int flags,-EPERM);ret = shirudo_deny_bpffs_mount(dev, TAMPER_BPFFS_UMOUNT);if (!ret)- ret = shirudo_umount_above(mnt);+ ret = shirudo_umount_above(mnt, flags);return ret ? ret : shirudo_image_mount(sb, true);}@@ -1006,6 +1128,87 @@ int BPF_PROG(shirudo_lsm_move_mount, const struct path *from_path,return ret ? ret : shirudo_image_mount(to, true);}+/* Only the host's PID 1 can cross between the two roots recorded by bootstrap. */+static __always_inline bool shirudo_initrd_pid1(const struct mount_record *rec)+{+ struct task_struct *task;+ struct vfsmount *vfsmnt;+ struct mount *root;++ if ((__u32)bpf_get_current_pid_tgid() != 1 || !rec->initrd_root_id)+ return false;+ task = bpf_get_current_task_btf();+ vfsmnt = BPF_CORE_READ(task, fs, root.mnt);+ if (!vfsmnt)+ return false;+ root = shirudo_mount_of(vfsmnt);+ return BPF_CORE_READ(root, mnt_id_unique) == rec->initrd_root_id;+}++static __always_inline int shirudo_propagation(struct mount *target,+ unsigned long type)+{+ struct mnt_namespace *ns;+ struct mount_record *rec;+ struct mount *m, *parent;+ __u32 zero = 0;+ int i;++ rec = bpf_map_lookup_elem(&shirudo_mnt_rec, &zero);+ if (!rec)+ return 0;+ m = (struct mount *)rec->mount;+ if (!m)+ return 0;+ if (BPF_CORE_READ_INTO(&ns, target, mnt_ns))+ goto deny;+ if ((__u64)ns != rec->mount_ns)+ return 0;+ if ((__u32)bpf_get_current_pid_tgid() == 1 &&+ (type == SHIRUDO_MS_SHARED || shirudo_initrd_pid1(rec)))+ return 0;+ bpf_for(i, 0, MOUNT_DEPTH_MAX) {+ if (m == target)+ break;+ parent = BPF_CORE_READ(m, mnt_parent);+ if (parent == m)+ return 0;+ if (!parent)+ break;+ m = parent;+ }+deny:+ return shirudo_tamper_deny(TAMPER_BPFFS_MOUNT, -EPERM);+}++SEC("lsm/sb_pivotroot")+int BPF_PROG(shirudo_lsm_sb_pivotroot, const struct path *put_old,+ const struct path *new_root, int ret)+{+ struct mnt_namespace *ns;+ struct mount_record *rec;+ struct mount *target;+ struct vfsmount *vfsmnt;+ __u32 zero = 0;++ if (ret)+ return ret;+ rec = bpf_map_lookup_elem(&shirudo_mnt_rec, &zero);+ if (!rec || !rec->mount_ns)+ return 0;+ vfsmnt = BPF_CORE_READ(new_root, mnt);+ target = shirudo_mount_of(vfsmnt);+ if (BPF_CORE_READ_INTO(&ns, target, mnt_ns))+ goto deny;+ if ((__u64)ns != rec->mount_ns)+ return 0;+ if (shirudo_initrd_pid1(rec) &&+ BPF_CORE_READ(target, mnt_id_unique) == rec->sysroot_id)+ return 0;+deny:+ return shirudo_tamper_deny(TAMPER_BPFFS_UMOUNT_ABOVE, -EPERM);+}+SEC("lsm/sb_mount")int BPF_PROG(shirudo_lsm_sb_mount, const char *dev_name,const struct path *path, const char *type,@@ -1015,8 +1218,15 @@ int BPF_PROG(shirudo_lsm_sb_mount, const char *dev_name,if (ret)return ret;- if ((flags & ((1UL << 17) | (1UL << 18) | (1UL << 19) |- (1UL << 20))) && shirudo_parent_mount(sb, false))+ if ((flags & PROPAGATION_TYPES) &&+ !(flags & ~(PROPAGATION_TYPES | SHIRUDO_MS_REC | SHIRUDO_MS_SILENT))) {+ struct vfsmount *vfsmnt = BPF_CORE_READ(path, mnt);+ unsigned long propagation = flags & PROPAGATION_TYPES;++ ret = shirudo_propagation(shirudo_mount_of(vfsmnt), propagation);+ return ret ? ret : shirudo_image_mount(sb, true);+ }+ if ((flags & PROPAGATION_TYPES) && shirudo_parent_mount(sb, false))return -EPERM;ret = shirudo_parent_mount(sb, true);if (ret)diff --git a/bpf/lib/identity.h b/bpf/lib/identity.hindex ac78a1bf..836d738d 100644--- a/bpf/lib/identity.h+++ b/bpf/lib/identity.h@@ -40,6 +40,9 @@ struct {/* The bpffs mount of init's namespace, as the unmount guard keeps it. */struct mount_record {__u64 mount;+ __u64 mount_ns;+ __u64 initrd_root_id;+ __u64 sysroot_id;};struct {diff --git a/builtin-init.c b/builtin-init.cindex ceaaa692..f3c426ca 100644--- a/builtin-init.c+++ b/builtin-init.c@@ -425,6 +425,18 @@ static int attach_guard_group(struct bpf_object *obj,return 0;}+static int mount_id_unique(const char *path, __u64 *id)+{+ struct statx stx;++ if (statx(AT_FDCWD, path, 0, STATX_MNT_ID_UNIQUE, &stx))+ return -errno;+ if (!(stx.stx_mask & STATX_MNT_ID_UNIQUE) || !stx.stx_mnt_id)+ return -EOPNOTSUPP;+ *id = stx.stx_mnt_id;+ return 0;+}+/** The recorder in the mount guards sees the bootstrap task open the* bpffs root; the record is read back, since a guard with none to keep@@ -435,7 +447,7 @@ static int record_bpffs_mount(struct bpf_object *obj)struct mount_record rec = {};struct bpf_map *map;__u32 zero = 0;- int fd;+ int fd, ret;fd = open(BPFFS_DIR, O_RDONLY | O_DIRECTORY | O_CLOEXEC);if (fd < 0)@@ -446,8 +458,19 @@ static int record_bpffs_mount(struct bpf_object *obj)return -ENOENT;if (bpf_map_lookup_elem(bpf_map__fd(map), &zero, &rec))return -errno;- if (!rec.mount)+ if (!rec.mount || !rec.mount_ns)return -ENOENT;+ if (initrd_mode) {+ ret = mount_id_unique("/", &rec.initrd_root_id);+ if (!ret)+ ret = mount_id_unique(sysroot(), &rec.sysroot_id);+ if (ret)+ return ret;+ if (rec.initrd_root_id == rec.sysroot_id)+ return -EINVAL;+ if (bpf_map_update_elem(bpf_map__fd(map), &zero, &rec, BPF_EXIST))+ return -errno;+ }return bpf_map_freeze(bpf_map__fd(map)) ? -errno : 0;}diff --git a/testing/functional/tpm/t4101-initrd.sh b/testing/functional/tpm/t4101-initrd.shindex f6269f78..6ccee5bb 100755--- a/testing/functional/tpm/t4101-initrd.sh+++ b/testing/functional/tpm/t4101-initrd.sh@@ -78,4 +78,21 @@ test_expect_success 'the runtime command can check initialization after switch-r[ "$(status_field tpm.bound_in)" = initrd ]'+# The QEMU TPM suite enables just this syscall exit at boot. A successful+# service alone could also mean systemd used its move-mount fallback.+if grep -qw 'trace_event=syscalls:sys_exit_pivot_root' /proc/cmdline; then+ test_expect_success 'host PID 1 completed a native pivot_root' '+ grep -E -- "-1[[:space:]]+\[.*(sys_exit_pivot_root:|sys_pivot_root ->) (0x)?0+([[:space:]]|$)" /sys/kernel/tracing/trace ||+ { grep -i pivot /sys/kernel/tracing/trace; false; }+ '++ test_expect_success 'systemd restored shared propagation with no mount refusal' '+ [ "$(status_field tamper_attempts.counters.BpffsMount)" = 0 ] &&+ [ "$(status_field tamper_attempts.counters.BpffsUmountAbove)" = 0 ] &&+ for path in / /run /run/shirudo /run/shirudo/bpffs; do+ findmnt -n -o PROPAGATION -T "$path" | grep -qw shared || return 1+ done+ '+fi+test_donediff --git a/testing/vm/run.sh b/testing/vm/run.shindex dd5a3cc7..c6bf9f84 100755--- a/testing/vm/run.sh+++ b/testing/vm/run.sh@@ -1956,6 +1956,9 @@ if [[ "$VM_ROLE" == target ]]; then# seal it, as a production initrd does.KERNEL_LSM_ARGS="lsm=bpf bpf.keyring_unsealed=1"KERNEL_LSM_ARGS+=" dm_verity.keyring_unsealed=1 initcall_debug ignore_loglevel"+ if [[ "$VM_INITRD" == 1 && "$VM_SUITE" == tpm ]]; then+ KERNEL_LSM_ARGS+=" trace_event=syscalls:sys_exit_pivot_root"+ fifiKERNEL_NET_DEVICE="virtio-net-pci,netdev=net0"diff --git a/util/identity.h b/util/identity.hindex 88b77520..94dbe5d5 100644--- a/util/identity.h+++ b/util/identity.h@@ -83,9 +83,12 @@ BUILD_BUG_ON(sizeof(struct task_policy) != 16);/* The bpffs mount init made, which the unmount guard keeps mounted. */struct mount_record {__u64 mount;+ __u64 mount_ns;+ __u64 initrd_root_id;+ __u64 sysroot_id;};-BUILD_BUG_ON(sizeof(struct mount_record) != 8);+BUILD_BUG_ON(sizeof(struct mount_record) != 32);enum guard_map_index {GUARD_IDENTITY,diff --git a/util/image_guards.c b/util/image_guards.cindex b04a2f18..3803def1 100644--- a/util/image_guards.c+++ b/util/image_guards.c@@ -83,6 +83,7 @@ shirudo_mount_guards[MOUNT_HOOK_COUNT] = {{ "shirudo_lsm_move_mount", MOVE_MOUNT_LINK_PIN },{ "shirudo_lsm_sb_mount", SB_MOUNT_LINK_PIN },{ "shirudo_lsm_sb_remount", SB_REMOUNT_LINK_PIN },+ { "shirudo_lsm_sb_pivotroot", BPFFS_DIR "/bpf2_sb_pivotroot_link" },{ "shirudo_lsm_file_open", BPFFS_DIR "/bpf2_file_open_link" },};diff --git a/util/image_guards.h b/util/image_guards.hindex ef484adb..20f7d00a 100644--- a/util/image_guards.h+++ b/util/image_guards.h@@ -10,7 +10,7 @@#define SEAL_HOOK_COUNT 29#define IMAGE_SEAL_HOOK_COUNT 2-#define MOUNT_HOOK_COUNT 5+#define MOUNT_HOOK_COUNT 6#define OBSERVER_HOOK_COUNT 10#define IMAGE_OBSERVER_HOOK_COUNT 4