Dan Nicholson 2973ec5910 switchroot: Stop making /sysroot mount private
Back in 2b8d586c5, /sysroot was changed to be a private mount so that
submounts of /var do not propagate back to the stateroot /var. That's
laudible, but it makes /sysroot different than every other shared mount
in the root namespace. In particular, it means that submounts of
/sysroot do not propagate into separate mount namespaces.

Rather than make /sysroot private, make /var a slave+shared mount so
that it receives mount events from /sysroot but not vice versa. That
achieves the same effect of preventing /var submount events from
propagating back to /sysroot while allowing /sysroot mount events to
propagate forward like every other system mount. See
mount_namespaces(7)[1] and the linux shared subtrees[2] documentation
for details on slave+shared mount propagation.

When /var is mounted in the initramfs, this is accomplished with
mount(2) syscalls. When /var is mounted after switching to the real
root, the mount propagation flags are applied as options in the
generated var.mount unit. This depends on a mount(8) feature that has
been present since util-linux 2.23. That's available in RHEL 7 and every
non-EOL Debian and Ubuntu release. Applying the propagation from
var.mount fixes a small race, too. Previously, if a /var submount was
added before /sysroot was made private, it would have propagated back
into /sysroot. That was possible since ostree-remount.service orders
itself after var.mount but not before any /var submounts.

1. https://man7.org/linux/man-pages/man7/mount_namespaces.7.html
2. https://docs.kernel.org/filesystems/sharedsubtree.html

Fixes: #2086
2024-09-06 15:49:49 -06:00
..
2023-05-02 08:42:19 -04:00
2023-05-02 08:42:19 -04:00
2020-05-27 21:59:23 +00:00
2024-02-16 13:34:34 +01:00
2023-05-02 08:42:19 -04:00
2023-05-02 08:42:19 -04:00
2023-05-02 08:42:19 -04:00
2023-05-02 08:42:19 -04:00
2023-05-02 08:42:19 -04:00
2023-05-02 08:42:19 -04:00
2023-05-02 08:42:19 -04:00
2023-05-02 08:42:19 -04:00
2023-05-02 08:42:19 -04:00
2024-07-18 17:55:21 -04:00
2023-05-02 08:42:19 -04:00
2023-05-02 08:42:19 -04:00