From: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>
To: khorenko@virtuozzo.com, ptikhomirov@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH vz10 v2 0/3] fs: let the host lock the protection flags of a mount
Date: Mon, 16 Nov 2026 10:12:51 +0400 [thread overview]
Message-ID: <20261116061256.54472-1-mirian.shilakadze@virtuozzo.com> (raw)
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
next reply other threads:[~2026-11-16 6:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 6:12 Mirian Shilakadze [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261116061256.54472-1-mirian.shilakadze@virtuozzo.com \
--to=mirian.shilakadze@virtuozzo.com \
--cc=devel@openvz.org \
--cc=khorenko@virtuozzo.com \
--cc=ptikhomirov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox