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 AB14E8017D for ; Tue, 17 Nov 2026 10:15:00 +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 6AHADbqJ007894; Tue, 17 Nov 2026 13:13:39 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AHADbqJ007894 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="Ex1DljbI" Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AHADYvs007878 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 17 Nov 2026 13:13:35 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AHADYvs007878 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-4903fc8537aso3157878f8f.0 for ; Tue, 17 Nov 2026 02:13:35 -0800 (PST) X-Gm-Message-State: APuU4Z9uiqlXLVCBWE5PFpAlyJhQ9uPbuuhC9q/KFzuY7QgcGZ+CLajj wBCKME/YTXoqiIHNFyAQgIqmQQ5+6YExBywrB2f2Xdw6YWLMWS/i0FTxgSdD+tHBuFp/4cv1WUB PlZhmzn9mf8nUsGcnqNNw8eAZ4hDWbWME64H9Lm8qYH52EReCxjJ70w== X-Gm-Gg: AZFdTZdARiynLBfNMjJ0LBNokqRoFrJYgMsrywnW6uEq/EwjJ95iDhGl8+lD8gdEEoK C3i6+DsOaNNKUZO23Ek2O9Qg+C51NiUg6fU6iv9rynx678Ue85a+kG/KHx9U2cMSjZV7/l/ZPe7 ut2xGLQ93UTQlKKoMMTTz8z9LyZh0F0EcvST95mZab48OOTryUzMh/Xx4Smt2uAG40LCks+X6eu UgBM1v60YIY+ojqfzstH3Va7310R4hPfVSpqBoW3+m9dqaYhLWSxqDhYU7BKrInwu/jLUsiVol5 k9TIDTQPmRtS6JMA5L4GzqugpG2LFWpY7uJi1VpPSp0STy1j4JQSUbaEQsPvo0VI164VA3wwZ9q tTHNzQQFm4ZxeZ6dG9qL9gMBBEGU+ X-Received: by 2002:a5d:64cf:0:b0:493:690c:8364 with SMTP id ffacd0b85a97d-49c6fc9e96amr27264808f8f.3.1794910414210; Tue, 17 Nov 2026 02:13:34 -0800 (PST) X-Received: by 2002:a5d:64cf:0:b0:493:690c:8364 with SMTP id ffacd0b85a97d-49c6fc9e96amr27264756f8f.3.1794910413672; Tue, 17 Nov 2026 02:13:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794910413; cv=none; d=google.com; s=arc-20260327; b=XATkFqjwg11DDUbWN6rIYWdX+2DwdyrlPM9OEU3eVIFycmN7hVtbu9OgDqkAwpAYjn E3pG0fnjVC3FnCkmW2Q8duc1R9nVmoUE3XF3Zs+UjfolGbJnKxAzQzl+gyGt0tc1tEAY spfLFPFLrQLTXOu3qy3HNa4ZZK5QPog77dFtacQDLXJnRly+yyhFpxxiCB6r4Bzwfv4s RFn7OYpBYyR11ppAGZo3KysH7RwpZs7gd6DlaD9uqCDupBzLWpwWcKDAMqMthpY7p9YU sTTXpYq80JCfSu9w9QA+MVwEKTzWj7Q13Qqz1RJxAF10uO+nhaMAVZyode6ZR3Tkm7cL 0xEw== 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=iQTLDWOwGK3heGjt2GPq/NCN5koJ5dqMhroZe7mhRtY=; fh=wpoNUURlquLpJK/14Kny0oMIYkY7mYwjJ/Ils9UT2kk=; b=aYqYBGjPzdb36Fl/hq4Q0D8zHPcZDfkxYMBDArIN7rpYwcR2ER9JeRsHR3CAukEmFJ ZIbQY1JnrPTyQYiT5X81I/3Hf0rE4DB08hhmMdhMBG7GfVW2WNTItVNB71f8HuxxeadZ n0Gi3jStgja81Cq3S7Gq5F8odz2l72dV0HDhMhsJr+5tg8XosrXAIUS1m/2H6mMcoAVY FpvwM6GpVH627nwFy3WPXuqXy+AHxzAuqIUiIadlf/XeXro/U3T+VaQ3WGWVj1MDD9wT 9HFBP8b9ZQ+nIV1oHDfpcuk7/8+dHfKYtpwULzTwk3V4P88ftu9A92yUBorqmK33+iSr sDVQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=Ex1DljbI; 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-49c64cf6034si25530616f8f.424.2026.11.17.02.13.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2026 02:13:33 -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=Ex1DljbI; 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=iQTLDWOwGK3heGjt2GPq/NCN5koJ5dqMhroZe7mhRtY=; b=Ex1DljbI3/Hb P3ezut6NZEnvNhdqVmZtghQomCg2DAkWas6bzhfPMbuEIqfnGcHCFr7MdPUsFF1G69PDrr2KWoGEL rBbyFedX/2c6KrY05ONIGAH0L9IXa30kMYfJBlCxKlT/SGC0qy6o4XvqQM4Lkgc86XBuQOpjDU0/y iJ9eJPGh3HYyMWy0MplAnZSbnTOO1UgFo+RR1tzPHxIDjrDgSD7zEKG2XxjcdolebUBvD0WInuPzk 42nWAniYj/ovwAGv7bho2vMd9AuFSI1YWCqggjujqtZxx6L/rHzEAiKKZSDdsmgzjeDRXbiDUJCjL r9r83pJIiAntPLjYg/Hg/w==; 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 1xTG7g-009MQ7-2u; Tue, 17 Nov 2026 11:13:23 +0100 From: Mirian Shilakadze To: khorenko@virtuozzo.com, ptikhomirov@virtuozzo.com Date: Tue, 17 Nov 2026 14:13:20 +0400 Message-ID: <20261117101329.225854-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 v2 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 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/20261116104552.102938-1-mirian.shilakadze@virtuozzo.com 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 Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel