]> git.ipfire.org Git - thirdparty/systemd.git/commit
mount-util/sysext: Clone sub mounts as private to preserve nested ones
authorKai Lüke <kai@amutable.com>
Wed, 29 Apr 2026 14:53:40 +0000 (23:53 +0900)
committerKai Lüke <pothos@users.noreply.github.com>
Fri, 10 Jul 2026 01:34:54 +0000 (03:34 +0200)
commitf6a7a9ec3df64a7b46725558b49b3a6c5499400a
tree519fbca5476ea24c698966cc849177c582b36fee
parent7eabeaed0e6495ff74bc5f6cce98ec8209cef540
mount-util/sysext: Clone sub mounts as private to preserve nested ones

When nested mounts appear under a sysext hierarchy like this:
  mkdir -p /opt/trigger/
  mount -t tmpfs tmpfs /opt/trigger
  mkdir -p /opt/trigger/inner
  mount -t tmpfs tmpfs /opt/trigger/inner
Then systemd-sysext merge will lose the inner mount because it uses a
regular bind mount with propagation and then unmounts the source,
unmounting all children with it which propagates (as found out in
https://github.com/flatcar/Flatcar/issues/2111).
To solve this, clone the sub mount with MS_PRIVATE to decouple sub
mounts from the original mount. Then attach the cloned mount instead of
doing regular bind mounts. For old kernels we still attach the cloned
mount but we fallback to cloning without MS_PRIVATE. This change also
affects mount_private_apivfs which is used for private /proc, /sys, and
cgroupfs but I think it makes sense there, too, instead of only doing
mount_setattr for sysext alone because, e.g., a container and the host
should not be leaking mount actions into each other for these mounts.
src/shared/mount-util.c
src/sysext/sysext.c
test/units/TEST-50-DISSECT.sysext.sh