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 488B08002A for ; Fri, 20 Nov 2026 13:16:33 +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 6AKDFA51019544; Fri, 20 Nov 2026 16:15:11 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AKDFA51019544 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="BEsaDb55" Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AKDF9v2019528 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Fri, 20 Nov 2026 16:15:09 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AKDF9v2019528 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-6ba203cc54bso1120962a12.0 for ; Fri, 20 Nov 2026 05:15:09 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErGUEkHC86OS9YXaTsPWd7iFvZWJD3SevYOCwGBHHIHixNxztkay74AqkigjTLMJxAYoFzxMCw==@openvz.org X-Gm-Message-State: APuU4Z9U4SpLIL+tUgjTy9UqB8A1kgJyyhdQnox9GXjOPnuFwflKYmxT PBI6cJhikynm9o2BduMEKuXlzMuBdnZTPeD0PIME/LSuOydSaFM/jZz2TkpQQoQd5W7VQWMAq11 3pz4C4tm8m4UcxAAQQrJ8Oe7oq62VffmhUO+5pRKJ4ab9o6C5UjEHqg== X-Gm-Gg: AZFdTZc8+1ykv6MaqiNexCgk4j6CPweiEt7c6+h298m5IIV9UhUDz5hz/1Pvz5xUi83 TsxPjamfbMhqUQuPU6tvc6d332pPN1uILD+8wkDeFw/C58ttqrT9eT/91IM6EWnFshjN/A1zW1T 6dcyS8D5JS1DAyN+TnGKmbfhMnVjdIYVlmGoju0ojPxW2L8z3h7+bBemYyIC41wjwo3SzdUyp/v YE69fCZvnhqM+CXpKXdGadkI7szVehCilsRzqbqfeY+5Kndhv5jkWJA9h5Gd/86O00K/cNKroJz 2kVPOU0/+IjKARFYgy2kG21uzIziReyZqpylML8l6TQbq0fJTafLYhlay0kiImbJspZWnmy6AkN VvxXJITAQV7ubeJse9A== X-Received: by 2002:a05:6402:4052:20b0:6b5:876c:a98f with SMTP id 4fb4d7f45d1cf-6ba37ee52e4mr1828626a12.34.1795180509018; Fri, 20 Nov 2026 05:15:09 -0800 (PST) X-Received: by 2002:a05:6402:4052:20b0:6b5:876c:a98f with SMTP id 4fb4d7f45d1cf-6ba37ee52e4mr1828604a12.34.1795180508527; Fri, 20 Nov 2026 05:15:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795180508; cv=none; d=google.com; s=arc-20260327; b=LHScgVJVqJLXME0z1kUZAJiq2TG/9ls4J3PzWKVORVt4x/W15+d4kg6fHmkwVSA3mN /5p6tcPx+/hyGBDl5YaPAe0rBwvXm9i8RfzxTMvg5Enx7tgYez/A90N4qxv4sS40aV7s cmCWPPLgDjMCrle4fKwRJoqdAqb7S2pEv+0nxIo9JgdeyOf4vvdoiagQ/WM9VBH2nyU0 SeZisc31zyCPe2PtlOdEwWk/R2hvwm+KruJmmlA5vgYzzeVwKZGDH6uM3LRn/+6qbms/ PBVJbdE4SStg40Dz2bR5fWa3JxIE9sAvcUPg4N8DE/h+cVWyzirlb+eXQbtJDWSdLQ9v onHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=5XHBjbaaOUVXEAd6SNCuermloFdqklUD3GxvapwJ0cE=; fh=xqcbrIOv/j1NC9DwWL7cs9wu5dYsNcrfZRJG6Y55lVA=; b=N07iBJB4KtPp40oIh1ELnue6vWFCQctRBuJQ4FT4RBT5w/znkZgqxYAlaiQiIlrfTU whgaGXg0EJKa1pRvcJJFZ6hOkjurYEIxFVV0UxStqNOHvrdicZhwQvZ3LkzIg1UxUS5L GRxro3thmZmb/eCl8xwmAvqcxPd21Re52nbPkuQ10E8GD8VM17SrBPqTf5gmXOZt+oHS rYUog2yIgPNuoiiIWyarpdzHggJLl30+BcqNqlWvePe8PkvSjLiyIsqy1Me6J7qRmitM huHCJS6UuMxykbELH0i5yoCKhTCixTck4tGkSF1+fNdErY8xa6x5+ZjC57bBdJ9ht8fp 1gyw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=BEsaDb55; spf=pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=khorenko@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 4fb4d7f45d1cf-6ba373ec656si2716533a12.246.2026.11.20.05.15.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Nov 2026 05:15:08 -0800 (PST) Received-SPF: pass (google.com: domain of khorenko@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=BEsaDb55; spf=pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=khorenko@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=Message-Id:Content-Type:MIME-Version:Subject:Date :From; bh=5XHBjbaaOUVXEAd6SNCuermloFdqklUD3GxvapwJ0cE=; b=BEsaDb55LUGGTyAQp2L fAMDAb0+6ZVmlssSAHm1U4paFyS4hFxQtVTJJUYb9NPd4JSb4MZAoCDK/rLS80UwbnW9Q5TfZ6zw3 8jEFljYEK09zZwisZCX016elyHWeAhwubOXg5cTsYwvK/GmUFalowQS//CVXXoRJGx1ltDqM/ybn7 1foNsJf8IbONeMT7AeJ63gpVK6VYiI8jJfxekSBetXBdaV6UR/GQj6sF4kyBU7HchU1YVecN6oX1J V5YCRuYesD0xhJNas91qaI4CmqRA9SlMq5DRc7oIch67XWSA1NyTlChVZD/3vi4Jta5mvBIi38Buk 5HTobduFZM0EF+Q==; Received: from ch-demo-asa.virtuozzo.com ([130.117.225.8] helo=f0.sw.ru) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xUOSG-006lM6-1D; Fri, 20 Nov 2026 14:15:04 +0100 From: Konstantin Khorenko Date: Fri, 20 Nov 2026 14:15:05 +0100 MIME-Version: 1.0 Message-Id: <20261120-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v2-1-c85e827c1dba@virtuozzo.com> References: <20261120-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v2-0-c85e827c1dba@virtuozzo.com> In-Reply-To: <20261120-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v2-0-c85e827c1dba@virtuozzo.com> To: Mirian Shilakadze , Pavel Tikhomirov X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=8815; i=khorenko@virtuozzo.com; h=from:subject:message-id; bh=l9W0kysjvq2nWA3y/40oG32QzuUsKVNYVtsOi07bB3Y=; b=owEBbQKS/ZANAwAKAVGWCkf5YVwqAcsmYgBrAEfbgvkw1scQNdw4Vvj7HGcpMLJG98YWjqr2h win5jddsE+JAjMEAAEKAB0WIQRWD23IPcXT0GO9CCxRlgpH+WFcKgUCawBH2wAKCRBRlgpH+WFc Kq1mD/43eG3v3BJB7w9Iapmcx+xVgHcCylAvN+WwM6EMgcvtXs6vh+WWnlBcNGUeM7B2uPPCCwP 629h+YA9mfwsnXaoNThbCr9FxTz/cuxfCPfOr24kxHj6mhhgB7qIleEEEb7O/OVouUErsbrHank GPtLpWtYfvA5MYV3cmhv5ZKxwDnOaJbOR5OjgGftnBaCwgVq5N+szLV02FIJUt4AFThp9IIc3u9 q6/QuNoh2rr0/IwvTnaJNXsuenhrXgN+dRDQeDbIB6MSLMkw7oLyJqNrleBqXmT2B+HbCpl4NdH I+qEMs4MmS5AxjqI4EY2lFfTUFDSHd3QXQMsedOxJfpcETghgBlRHEV1q8k6N+VSZbZDkzr9yDD 6ULY6PwxMSibb0ArMhsnGP9waDoQTE3rX8N0y/tOq6EVUx+x7eXUlvtLI1K1g5cypRG8sDHqTmt aGNgO/tQ/o9M+1N6372mFq7I0kZZy9PpaUfVR+jwiZVl9UPTUzLOYYWuSTvoM2e9ivKXsA/VgLb K7k0hMGltAsF+754AURamXHlEDlcjLRbvhN3l1KAqkBoa0rLw9XipU3grJ448S0ITWLARLRRJVn 2yUvBNYtkb8jH7hmnazBq5jAeR9+mI9rNo6Ustk5M8Lq+fbVM48LB6wrlfNCA+7ADjff45or/rU D7BC8kZrXga8d+w== X-Developer-Key: i=khorenko@virtuozzo.com; a=openpgp; fpr=560F6DC83DC5D3D063BD082C51960A47F9615C2A X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2 v2 1/2] ve: trust every host task of a pseudosuper VE until it execs 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 Since "ve: hide the tasks that set up a starting VE from the rest of it" a host task entering a VE is marked VD_VE_SETUP_TASK only while the VE is VE_STATE_STARTING, and VD_VE_ENTER_TASK afterwards. While the VE is pseudosuper only the setup tasks may reach each other and use the pseudosuper relaxations; an entered task only skips the mount limit. libvzctl before 10.0.144 writes START to ve.state, which ends in VE_STATE_RUNNING, before it configures the disk: a helper then joins the init task's namespaces one by one through setns(), opens /proc//ns/mnt, makes the ploop device nodes and mounts the second disk inside the container. It joined a running VE, so it is an entered task, and the init task, a setup task, is hidden from it. Every container start with such a libvzctl fails: Failed to open /proc//ns/mnt: Permission denied Failed to configure disk Cancel init execution libvzctl 10.0.144 and newer open the namespaces before joining any and are not affected. Both kinds of task come from the host and have not exec'd. Before the series every task of a pseudosuper VE had the relaxations, and libvzctl runs its in-process helpers for disks, devices, bind mounts and GPUs inside the VE after START, so trust them alike: ve_current_is_pseudosuper() accepts either mark while the VE is pseudosuper, and ve_current_is_host_task() goes. An entered task stays hidden from the container after pseudosuper is cleared, as before, and a binary the host tools exec still drops its mark. Fixes: a7d797d177e7 ("ve: hide the tasks that set up a starting VE from the rest of it") https://virtuozzo.atlassian.net/browse/VSTOR-156164 Feature: trace: prohibit tracing sensitive tasks from CT Signed-off-by: Konstantin Khorenko --- fs/namespace.c | 4 ++-- include/linux/mm_types.h | 4 ++-- include/linux/ve.h | 2 -- kernel/ptrace.c | 2 +- kernel/ve/ve.c | 43 ++++++++++++------------------------------- security/device_cgroup.c | 2 +- 6 files changed, 18 insertions(+), 39 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 0eae165b1299e..db0100203dc29 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -3226,7 +3226,7 @@ int ve_devmnt_process(struct ve_struct *ve, dev_t dev, void **data_pp, int remou if (devmnt->dev == dev) { err = ve_devmnt_check(data, devmnt->allowed_options); /* - * Setup tasks of a pseudosuper VE, ie the restore + * Host tasks of a pseudosuper VE, ie the restore * procedure, skip the allowed options filtering, since * restore mode is special. */ @@ -3367,7 +3367,7 @@ int ve_devmnt_verify(struct ve_struct *ve, dev_t dev, char *opts, bool new_mount static inline int ve_try_reserve_mount(struct ve_struct *ve) { - int ret = ve_current_is_host_task(ve) || ve_is_super(get_exec_env()); + int ret = ve_current_is_pseudosuper(ve) || ve_is_super(get_exec_env()); /* * Ignore limits in ve0 and for the host's tasks of a pseudosuper VE, * but still count. diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 53cb5ff32a233..388b256ed4af8 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -1116,8 +1116,8 @@ extern struct mm_struct init_mm; #define VD_LICDATA_ACCESS 2/* tasks accessed containers license data, * no ptrace and no coredump allowed */ #define VD_VE_SETUP_TASK 3/* tasks the host sent into a starting VE, - * reachable only from each other while it - * is pseudosuper, VD_PTRACE_COREDUMP after */ + * reachable only from the host's tasks while + * it is pseudosuper, VD_PTRACE_COREDUMP after */ /* Pointer magic because the dynamic array size confuses some compilers. */ static inline void mm_init_cpumask(struct mm_struct *mm) diff --git a/include/linux/ve.h b/include/linux/ve.h index f83d2229d36de..d29339112f250 100644 --- a/include/linux/ve.h +++ b/include/linux/ve.h @@ -284,7 +284,6 @@ extern bool is_ve_init_net(const struct net *net); void ve_setup_task(struct task_struct *p, struct ve_struct *old_ve, struct ve_struct *ve); bool ve_current_is_pseudosuper(struct ve_struct *ve); -bool ve_current_is_host_task(struct ve_struct *ve); int ve_vps_dumpable(struct mm_struct *mm, struct ve_struct *ve); void ve_set_rpc_kill_fn(void (*fn)(struct net *, bool)); @@ -419,7 +418,6 @@ static inline int vz_security_protocol_check(struct net *net, int protocol) { re static inline void ve_setup_task(struct task_struct *p, struct ve_struct *old_ve, struct ve_struct *ve) { } static inline bool ve_current_is_pseudosuper(struct ve_struct *ve) { return true; } -static inline bool ve_current_is_host_task(struct ve_struct *ve) { return true; } #define ve_vps_dumpable(mm, ve) ((mm)->vps_dumpable) static inline void ve_set_rpc_kill_fn(void (*fn)(struct net *, bool)) { } diff --git a/kernel/ptrace.c b/kernel/ptrace.c index ff71c3e37bc14..c2b27e455c8ee 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -285,7 +285,7 @@ static bool task_still_dumpable(struct task_struct *task, unsigned int mode) * have its vps_dumpable confirmed, so deny it. This closes the window * where a dying CT task could be inspected (e.g. an fd stolen via * pidfd_getfd()) after exit_mm() cleared ->mm. While its VE is - * pseudosuper, a setup task is only inspectable by another one. + * pseudosuper, a setup task is only inspectable by a host task. */ if (!ve_is_super(get_exec_env())) { struct ve_struct *ve = task_ve(task); diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c index 076892a750cfc..0ad145b38b54b 100644 --- a/kernel/ve/ve.c +++ b/kernel/ve/ve.c @@ -1022,7 +1022,7 @@ static u64 ve_pseudosuper_read(struct cgroup_subsys_state *css, struct cftype *c * is allowed in a sake of container restore for example. * * To set this value up one has to be a real node's owner. - * Inside the VE only its setup tasks may drop it, see + * Inside the VE only its host tasks may drop it, see * cgroup_file_write(). */ static int ve_pseudosuper_write(struct cgroup_subsys_state *css, struct cftype *cft, u64 val) @@ -1780,44 +1780,25 @@ bool ve_check_trusted_exec(struct file *file, struct filename *name) return false; } -/** - * ve_current_has_mark - is current a task of pseudosuper @ve with @mark - * @ve: the VE - * @mark: the vps_dumpable value - */ -static bool ve_current_has_mark(struct ve_struct *ve, unsigned int mark) -{ - struct mm_struct *mm = current->mm; - - return ve->is_pseudosuper && task_ve(current) == ve && - mm && mm->vps_dumpable == mark; -} - /** * ve_current_is_pseudosuper - may current use the pseudosuper relaxations of @ve * @ve: the VE that grants them * - * Always true for ve0. Otherwise only a VD_VE_SETUP_TASK of @ve may, and only - * until pseudosuper is cleared. Exec clears VD_VE_SETUP_TASK, so the container - * binaries that the host tools run may not. + * Always true for ve0. Otherwise only a host task of @ve may, one the host + * sent in while @ve was starting (VD_VE_SETUP_TASK) or after that + * (VD_VE_ENTER_TASK), and only until pseudosuper is cleared. Exec clears + * both marks, so the container binaries that the host tools run may not. */ bool ve_current_is_pseudosuper(struct ve_struct *ve) { - return ve_is_super(ve) || ve_current_has_mark(ve, VD_VE_SETUP_TASK); -} + struct mm_struct *mm = current->mm; -/** - * ve_current_is_host_task - is current a host task of pseudosuper @ve - * @ve: the VE - * - * Always true for ve0. Otherwise true for a setup task of @ve and for a host - * task that joined @ve after it started, such as the CRIU helper that mounts - * proc for a nested pid namespace, until pseudosuper is cleared. - */ -bool ve_current_is_host_task(struct ve_struct *ve) -{ - return ve_current_is_pseudosuper(ve) || - ve_current_has_mark(ve, VD_VE_ENTER_TASK); + if (ve_is_super(ve)) + return true; + + return ve->is_pseudosuper && task_ve(current) == ve && mm && + (mm->vps_dumpable == VD_VE_SETUP_TASK || + mm->vps_dumpable == VD_VE_ENTER_TASK); } /** diff --git a/security/device_cgroup.c b/security/device_cgroup.c index b0ef5f9380d1f..013fa00f15d8a 100644 --- a/security/device_cgroup.c +++ b/security/device_cgroup.c @@ -924,7 +924,7 @@ static int devcgroup_legacy_check_permission(short type, u32 major, u32 minor, #ifdef CONFIG_VE /* * When restoring container allow everything to its - * setup tasks in pseudosuper state. We need this for + * host tasks in pseudosuper state. We need this for * early mounting of second ploop device. Still, don't * change behaviour on the ve0. */ -- 2.43.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel