]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/filesystems: add MOVE_MOUNT_BENEATH rootfs tests
authorChristian Brauner <brauner@kernel.org>
Tue, 24 Feb 2026 00:40:28 +0000 (01:40 +0100)
committerChristian Brauner <brauner@kernel.org>
Thu, 12 Mar 2026 12:34:59 +0000 (13:34 +0100)
commitbb5c17bc863d1ac9ee0d51d300d5399d632fe69f
tree6dc999bf0cf144862b77d1a7734dcc465d7f1efd
parentccfac16e0be52b674ac04fb5ba88c643f76ae0e1
selftests/filesystems: add MOVE_MOUNT_BENEATH rootfs tests

Add tests for mounting beneath the rootfs using MOVE_MOUNT_BENEATH:

- beneath_rootfs_success: mount beneath /, fchdir, chroot, umount2
  MNT_DETACH -- verify root changed
- beneath_rootfs_old_root_stacked: after mount-beneath, verify old root
  parent is clone via statmount
- beneath_rootfs_in_chroot_fail: chroot into subdir of same mount,
  mount-beneath fails (dentry != mnt_root)
- beneath_rootfs_in_chroot_success: chroot into separate tmpfs mount,
  mount-beneath succeeds
- beneath_rootfs_locked_transfer: in user+mount ns: mount-beneath
  rootfs succeeds, MNT_LOCKED transfers, old root unmountable
- beneath_rootfs_locked_containment: in user+mount ns: after full
  root-switch workflow, new root is MNT_LOCKED (containment preserved)
- beneath_non_rootfs_locked_transfer: mounts created before
  unshare(CLONE_NEWUSER | CLONE_NEWNS) become locked; mount-beneath
  transfers MNT_LOCKED, displaced mount can be unmounted
- beneath_non_rootfs_locked_containment: same setup, verify new mount
  is MNT_LOCKED (containment preserved)

Link: https://patch.msgid.link/20260224-work-mount-beneath-rootfs-v1-3-8c58bf08488f@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
tools/testing/selftests/Makefile
tools/testing/selftests/filesystems/move_mount/.gitignore [new file with mode: 0644]
tools/testing/selftests/filesystems/move_mount/Makefile [new file with mode: 0644]
tools/testing/selftests/filesystems/move_mount/move_mount_test.c [new file with mode: 0644]