While a container starts or is restored, ve.pseudosuper is on and its relaxations apply to every process in the container. The container's own binaries that vzctl and CRIU run in that window get them too, such as quotaon at start and the tee that vz-rst-action runs at post-restore. Such a binary can rewrite the container's root memory.max, skip the mount limit and the mount option filter, use NETLINK_REPAIR, or clear pseudosuper early. During a restore it can also open /proc/<pid>/fd of CRIU's restoring tasks and take CRIU's log, its /proc fd and the transport socket.
This series marks the tasks the host sends into a starting VE as setup tasks. Fork keeps the mark, exec drops it, and only a task coming from the host gets it. - 1/6 passes ve_setup_task() the VE a task comes from - 2/6 hides only the tasks the host sends into a VE, in any state but starting - 3/6 marks setup tasks and lets them be reached only by each other while the VE is pseudosuper - 4/6 to 6/6 give the pseudosuper relaxations only to setup tasks: the container's root cgroup files, the mount filter and limit, and the rest. A host task that joins the VE after it has started, such as the CRIU helper that mounts proc for a nested pid namespace, still skips the mount limit. Once pseudosuper is cleared, the restored processes are ordinary container processes again. vzctl and CRIU need no change. Changes since v1, after Konstantin's review and Sashiko's: - a host task that moves from a starting VE into a running one is hidden there again: a setup task leaving a VE that is still pseudosuper counts as sent by the host (2/6 and 3/6) - a task that setns()es into its own VE keeps its mark (2/6 and 3/6) - ve_setup_task() runs before the old VE namespace is put, which may drop the last reference to the VE it now reads (1/6) - 5/6 has a new subject and uses ve_current_is_host_task() instead of the open-coded test in the mount limit - 3/6 adds ve_current_has_mark(), which ve_current_is_pseudosuper() and the 5/6 helper share - the comments on VD_VE_SETUP_TASK, ve_current_is_pseudosuper(), ve_pseudosuper_write(), ve_devmnt_process() and devcgroup_legacy_check_permission() describe the new checks - the 2/6 message says why a container task must not get VD_VE_ENTER_TASK and that a task entering its nested VE is no longer hidden there, and its first paragraph is reworded - Link to v1: http://lore.virtuozzo.com/[email protected] Tested on kernel 6.12.0-211.75.1.24.1.vz10 with this series, which applies there unchanged, on a VHI 8.1 node with vzctl 10.0.159 and criu 4.2.1.18, stock against patched: - a probe in place of the container's quotaon and tee: on stock it reads the fds of every restoring task, restore.log included, sets NETLINK_REPAIR and rewrites the root memory.max, on patched all of it is refused - the same probe gains nothing by moving into a nested VE and unsharing it from a vfork child that shares its mm - a host task that enters a starting VE, then joins a running container and its user namespace without exec: hidden on stock and on patched. With v1 the container could read its fds. - a host task that joins the container and its user namespace without exec stays hidden, and becomes visible once it execs - a container with a nested pid namespace restored with its mount limit lowered to 10: restores. Without the exemption in 5/6 the proc mount for that namespace failed with ENOMEM. - after resume the container sees its restored processes and they dump core, and start, stop, suspend, resume, a second disk and a container at its mount limit behave as on stock - CRIU zdtm in the ve flavor, with every userns test forced into it: 441 passed, 8 failed, all 8 fail on stock too. bridge, sit and socket_udplite cannot set up their devices in a VE on that node. - vzctl pytest 10.0.159: 1377 passed, 0 failed Mirian Shilakadze (6): ve: tell ve_setup_task() which VE the task comes from ve: hide only the tasks the host sends into a VE ve: hide the tasks that set up a starting VE from the rest of it cgroup: give the CT root file writes and hidden roots only to setup tasks fs: keep the mount relaxations of a pseudosuper VE from container binaries ve: give the remaining pseudosuper relaxations only to setup tasks fs/coredump.c | 2 +- fs/namespace.c | 12 +++--- include/linux/mm_types.h | 3 ++ include/linux/ve.h | 12 +++++- kernel/cgroup/cgroup.c | 4 +- kernel/ptrace.c | 23 +++++++++-- kernel/sys.c | 2 +- kernel/ve/ve.c | 89 +++++++++++++++++++++++++++++++++++----- kernel/ve/ve_namespace.c | 10 +++-- net/netlink/af_netlink.c | 2 +- security/device_cgroup.c | 8 ++-- 11 files changed, 132 insertions(+), 35 deletions(-) -- 2.43.0 _______________________________________________ Devel mailing list [email protected] https://lists.openvz.org/mailman/listinfo/devel
