A container can strip ro, nosuid, nodev or noexec from a bind mount the host gave it with "mount -o remount,rw,bind" and then write host data. This series lets the host lock those flags on a mount, reports the locks in statmount() so that criu can carry them over a checkpoint and restore, and tests both.
Changes since v1, after Pavel's review and Sashiko's: - one attribute per protection, MOUNT_ATTR_VE_LOCK_RDONLY, _NOSUID, _NODEV and _NOEXEC, with MOUNT_ATTR_VE_LOCK as the mask of the four, so a lock state that is read back can be set again exactly - a protection lock can no longer be dropped, attr_clr refuses it, as nothing drops the locks lock_mnt_tree() raises - the gate is capable(CAP_SYS_ADMIN) alone, ve_may_lock_mount() is gone - one mount per call, a lock with AT_RECURSIVE is refused - do_remount() tests the locks under s_umount before it touches the superblock, and mount_setattr() holds s_umount for read while it locks. v1 could return EPERM with the superblock already changed. - lock_mnt_tree() and the perf header copy are left as they are - new: patch 2, statmount() reports the locks - new: patch 3, the selftest Pavel's other suggestion, a lock that keeps the container from unmounting or moving the mount, is a separate series on top of this one (VSTOR-154914). The vzctl and criu sides go to their repos separately. Tested on a VHI node with the 22.22 release kernel plus this series: - ve_mount_lock_test 8/8 (2/8 on the stock kernel, which lacks the feature), mount_setattr 21/21, statmount 15/15 and statmount_ns 2/2, the same as on the stock kernel - a container started by the current vzctl: without a lock it can still remount its read-only bind mount rw. Once the host locks the mount in the container's mount namespace, the remount fails with EPERM and a write with EROFS, while umount still works. Suspend and resume work, the current criu restores the mount unlocked. https://virtuozzo.atlassian.net/browse/VSTOR-155305 Mirian Shilakadze (3): fs: let the protection flags of a mount be locked from userspace fs: report the locks of a mount in statmount() selftests/ve: test locking a mount from the host fs/namespace.c | 67 ++++- include/uapi/linux/mount.h | 15 + tools/testing/selftests/ve/.gitignore | 1 + tools/testing/selftests/ve/Makefile | 1 + .../testing/selftests/ve/ve_mount_lock_test.c | 274 ++++++++++++++++++ 5 files changed, 352 insertions(+), 6 deletions(-) create mode 100644 tools/testing/selftests/ve/ve_mount_lock_test.c -- 2.43.0 _______________________________________________ Devel mailing list [email protected] https://lists.openvz.org/mailman/listinfo/devel
