From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id B35BB803BB for ; Wed, 18 Nov 2026 10:38:15 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AIAb0np023378; Wed, 18 Nov 2026 13:37:02 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AIAb0np023378 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="dDntdqHL" Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AIAaxXl023370 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 18 Nov 2026 13:37:00 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AIAaxXl023370 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-4a3052225cbso774428f8f.1 for ; Wed, 18 Nov 2026 02:37:00 -0800 (PST) X-Gm-Message-State: APuU4Z/beAup0NxWzXx/XThXVbsiFD94kks0DjNoj+/GGnVY1kcmXoqA ebGgyMngW/kGf4Vkxe16SVvOzoJ9uaDGhGXo8a99GK022QRu4MqBjd/ep+IE1q4UZEAKgQBKIoa aQlNLTDeOE/+YLL3NTX/2DAoMbN4B7uvu7fXEMSe287rZB7jFKiy9nw== X-Gm-Gg: AZFdTZdy1GH9ypLZcznhw4cWMA7vcvKi+n+DkrYr/W6uBfP66mnyphJVA6ESoAh0N8n seXF/k7FMb2+yJylwTMSkpr6CCoMDCP0jKgWYjbSHb6XU0doSN2zKFGnIE7oTe3cYKmkwLOmQj5 pGncRXY+bb72qEbxuNdvtVcR25hCa1EL4MRIw/zmdqf3znC7UbBYrbhK4Fd3Sc32jRdloZtKZTP chVxjqcvNUmm1QRdo4tcO291XfgF+DHeWrvX2EloJgcrhec+axAzlBLJDUb+0TyMbf706hQA1x1 SR2eS4e+0nrbXjuZKpeUAf9Z2k3w/8p/r54VjXBZAYrYr2Rdu6ZetsZKLSVXYi3Ako/AhCGxcz6 cULKeiB8ZgPvvQ47Th2jNSQfpDBbEUA== X-Received: by 2002:a05:6000:310a:b0:4a8:714:7ae2 with SMTP id ffacd0b85a97d-4a807330779mr691010f8f.29.1794998219422; Wed, 18 Nov 2026 02:36:59 -0800 (PST) X-Received: by 2002:a05:6000:310a:b0:4a8:714:7ae2 with SMTP id ffacd0b85a97d-4a807330779mr690946f8f.29.1794998218862; Wed, 18 Nov 2026 02:36:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794998218; cv=none; d=google.com; s=arc-20260327; b=cJbj+kaHWnZ/brVXClDez9BcEbd9qJhusQtpbDx1aa/MJOmj74aV32Qyc3bnoIa+mL fCO5dTQWeFTAuzo3RwHAvrxGHSKDBr8608hTJYsJw+No+n5d1XrgNexoAwV+vQm5W2zn +7o29DPMgdqOTjD9V9wlMPhalhNYalkGrmpeLFENgf9sDUiPaVX97X7fixquOrmLG9rm c3Zaa8VLUt1bVL30+LOBu1dOZZZAS6e0i3zkotSKwYrvpOq+ROvmyfUy2OfXmkqC1+tG v1+e4LD8/3foXeSmoWvZCw4KSsXaKLDJd1ipjWfL+ivH7/i31moOfmiqXJEGrPz7iNkC kocw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=CGrheAvd8W8AMo0X8IMkImbTi165iiHYelNYnfUUNWA=; fh=wpoNUURlquLpJK/14Kny0oMIYkY7mYwjJ/Ils9UT2kk=; b=XeFyvIWZ4sPY4cT6+3AAgEcSpeoeGRJxpV0l3G8/hWWmazlWcfJFa2kuET7n13u/lR bgx3XFQ6HXuqjbJKYKaJzItAaBvAUgz0VeQDDkVXAWg1GRzQChBIUP/bNFFQwJDZNcph NuJYHmgJ3/8miUr391mMnP2Ra7nDgGkUoKHTVUeGtf8aKzIZJvdkFMchtjR3Ka8AFcxT U/M5kCHiIcC0ApLNFiZoWMTMFdV3cif8kn1X8oa87+Y0NcuVdam7FIARCM35CENsty9Z 10z+LkCxrlfdV48XDGwBsgid+cs51OK3p5vDXS3HvpVrUlaE9ptzbEXTSwIEeUqQcnod 0qZw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=dDntdqHL; spf=pass (google.com: domain of mirian.shilakadze@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=mirian.shilakadze@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id ffacd0b85a97d-4a65aa5d360si5104552f8f.419.2026.11.18.02.36.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2026 02:36:58 -0800 (PST) Received-SPF: pass (google.com: domain of mirian.shilakadze@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=dDntdqHL; spf=pass (google.com: domain of mirian.shilakadze@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=mirian.shilakadze@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=CGrheAvd8W8AMo0X8IMkImbTi165iiHYelNYnfUUNWA=; b=dDntdqHLht4u oU3j1yCnyw7ap4rmijyHRxiWSQ8pOpJD7wix/4ElSvSEVD50q/it4yMKLQIrOS04C2UjLZ+XvdFlJ Ig1Vc0XYyemyQ6rICsnwsQghmXYmGTcLMTnMxf0szLwo/5vKAolFYy7yVDX8apF/ikLEkqfarMpIU BwV897B/Kpe5czwCm73eV4NuOvJyF/zRXmhRFzYH3iJamMbIuLySdAJie4C+9y9889WJgqUL8Bsvz fhVvS8dhtqYODX0bQOfiNN0jMAfqGaMgTtU3JFx+gMn9QAPg1WFlQ2CneQYKhikZatmAAte1YB/Z2 nsru28vaxQUgadqqC9iDWQ==; Received: from ch-demo-asa.virtuozzo.com ([130.117.225.8] helo=localhost.localdomain) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xTcxs-001uKo-1q; Wed, 18 Nov 2026 11:36:58 +0100 From: Mirian Shilakadze To: khorenko@virtuozzo.com, ptikhomirov@virtuozzo.com Date: Wed, 18 Nov 2026 14:36:32 +0400 Message-ID: <20261118103656.363171-1-mirian.shilakadze@virtuozzo.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2 v3 0/6] ve: give the pseudosuper privileges only to the tasks setting up a VE X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org 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//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 v2, after Konstantin's review and Sashiko's: - a setup task that leaves its VE after pseudosuper is cleared drops the mark, so it is not a setup task in another pseudosuper VE. It is not hidden in the VE it enters either, the 3/6 message says why (3/6) - ve_try_reserve_mount() no longer tests ve_is_super(ve), and its comment says the limit is skipped for the host's tasks of a pseudosuper VE (5/6) - the paragraph about tasks leaving a pseudosuper VE stands on its own in the 3/6 message, the ve_vps_dumpable() kernel-doc no longer reads as if a setup task stayed one in ve0, and the 4/6 comment says "one has to be" - the v1 change log below drops the line about a task that setns()es into its own VE, as v1 kept that mark too 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) - 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/20261116104552.102938-1-mirian.shilakadze@virtuozzo.com - Link to v2: http://lore.virtuozzo.com/20261117101329.225854-1-mirian.shilakadze@virtuozzo.com Tested on the hci-8.2 tip with this series, on a VHI 8.2 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 - the same task moving on only after pseudosuper is cleared: hidden on stock, visible on patched, as 3/6 says - a setup task of a VE whose pseudosuper is cleared, moving on into another starting VE: gets NETLINK_REPAIR there on stock and with v2, refused with v3. A task the host sends into that VE still gets it. - 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 - the VE selftests (ve, ve_devcg_bpf, ve_printk): same results as on stock, ve_ns_owner_test fails on both - 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 | 18 ++++---- 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 | 96 +++++++++++++++++++++++++++++++++++----- kernel/ve/ve_namespace.c | 10 +++-- net/netlink/af_netlink.c | 2 +- security/device_cgroup.c | 8 ++-- 11 files changed, 143 insertions(+), 37 deletions(-) -- 2.43.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel