All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
* [Devel] [PATCH vz10 v2 0/3] fs: let the host lock the protection flags of a mount
@ 2026-11-16  6:12 Mirian Shilakadze
  2026-11-16  6:12 ` [Devel] [PATCH vz10 v2 1/3] fs: let the protection flags of a mount be locked from userspace Mirian Shilakadze
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Mirian Shilakadze @ 2026-11-16  6:12 UTC (permalink / raw)
  To: khorenko, ptikhomirov; +Cc: devel

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
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-11-16 17:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16  6:12 [Devel] [PATCH vz10 v2 0/3] fs: let the host lock the protection flags of a mount Mirian Shilakadze
2026-11-16  6:12 ` [Devel] [PATCH vz10 v2 1/3] fs: let the protection flags of a mount be locked from userspace Mirian Shilakadze
2026-11-16  6:24   ` no-reply
2026-11-16 17:13   ` Konstantin Khorenko
2026-11-16  6:12 ` [Devel] [PATCH vz10 v2 2/3] fs: report the locks of a mount in statmount() Mirian Shilakadze
2026-11-16  6:17   ` no-reply
2026-11-16 17:13   ` Konstantin Khorenko
2026-11-16  6:12 ` [Devel] [PATCH vz10 v2 3/3] selftests/ve: test locking a mount from the host Mirian Shilakadze
2026-11-16  6:38   ` no-reply
2026-11-16 17:13   ` Konstantin Khorenko
2026-11-16 17:13 ` [Devel] [PATCH vz10 v2 0/3] fs: let the host lock the protection flags of a mount Konstantin Khorenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.