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, the vzctl
start path was already fixed under VSTOR-151174.

Tested on kernel 6.12.0-211.75.1.24.1.vz10 on VHI 8.1 nodes, vzctl
10.0.148 and 10.0.159, criu 4.2.1.15 and 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. With an earlier
  version, which marked any task coming from another VE, it gained all
  of the above.
- 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.
- a host task that joins a running container without exec stays
  hidden from it
- 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:
  440 passed, the same 5 fail on stock with the same errors
- 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: give the mount relaxations of a pseudosuper VE only to setup tasks
  ve: give the remaining pseudosuper relaxations only to setup tasks

 fs/coredump.c            |  2 +-
 fs/namespace.c           | 18 ++++++++----
 include/linux/mm_types.h |  4 +++
 include/linux/ve.h       | 10 +++++--
 kernel/cgroup/cgroup.c   |  4 +--
 kernel/ptrace.c          | 23 +++++++++++++---
 kernel/sys.c             |  2 +-
 kernel/ve/ve.c           | 59 ++++++++++++++++++++++++++++++++++------
 kernel/ve/ve_namespace.c |  7 +++--
 net/netlink/af_netlink.c |  2 +-
 security/device_cgroup.c |  2 +-
 11 files changed, 106 insertions(+), 27 deletions(-)

-- 
2.43.0

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to