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 D80AC80027 for ; Fri, 20 Nov 2026 16:36:12 +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 6AKGYwDe006789; Fri, 20 Nov 2026 19:34:59 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AKGYwDe006789 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="TyR52YCJ" Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AKGYs4x006757 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Fri, 20 Nov 2026 19:34:54 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AKGYs4x006757 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-c4d58203e40so87901066b.1 for ; Fri, 20 Nov 2026 08:34:54 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErGcC++G4cubc8ynSj1dJ76y57NadGVY8UzYj6b0q3PclVK2T8w5zc8D1G317oDP7q5OmTVZaw==@openvz.org X-Gm-Message-State: APuU4Z/2RN2zxASWe3ojeUpWFyTkuSUk3I9KOSnCoHp+FsLmlu4le0jz eFBhPThmIKPlpb5YCdKCLlnkDOrMiTSoB06Fe90h1DxMDDdx3fRCSGN4PHrQWnRdJ1gjvshph/A g8k7mod9Zfqj2usrGjqKyu1D47bY1DRwJF8yzVxQThurfQm3ShqbuGw== X-Gm-Gg: AZFdTZdrRIt9tg1Mj7VwSxtPJ4R5SaKJezU/qoxkewFDor8HeNPqB9/jDXOsIsF/G/x A9mkaTqnPpIQ0pJJs4pyTMROkfCoIX9VdGJgqzvoBq6qDJ8zePdhh6hundQExkjghopSbkcMbMJ mHLizHppkqJekubsewFwKiCQG8h5CJ8d3fwjUYr7+FGoo9c63ygxxGZx0QF22XPgw160g35b1X/ OJTMQB4YoULxyNqDNwkW99c9zOuILfDB4AncJnfUffjExV3rKWxglfvnqZDfXfpEkDylOsk6U8w kzKxBufKwX35NtiqruypUvtqiKc+dWQGd+3skjSDlzYXHr8nd6Jyq9L8BGOiqGLtoexQH3h5VH3 O1AGnM/FwLRwkYC2+Fg== X-Received: by 2002:a17:907:fd15:b0:c40:33d:f06f with SMTP id a640c23a62f3a-c513aaad90bmr378047766b.39.1795192493999; Fri, 20 Nov 2026 08:34:53 -0800 (PST) X-Received: by 2002:a17:907:fd15:b0:c40:33d:f06f with SMTP id a640c23a62f3a-c513aaad90bmr378045566b.39.1795192493501; Fri, 20 Nov 2026 08:34:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795192493; cv=none; d=google.com; s=arc-20260327; b=TmSkk9DnpEgNGrey0AjAMYSCCnChAC//I67jAyGwFWTIFY/b0QQrclFKdYSFc/UgnH tAr7l9Hvaiu0wru7d2pYJb3Gy1YNPDSaw+A0K5NUOoC3AYi3kXiTYTOi4ba1GxZ+MPLJ KWRWxFviboD3D2nnVlu5WCYjw70vtZpICbsEcyLS4XMaas26to8cnws8rSK32Be1QWUo EEOuhU3NERgiepjNVhmJguzwJLiROMaYsu4MsoV35hFGCP86kk4A0ugjDou6EHTAjina T0Zh0Iow2SY7D/jG7sEPFDiIA+SE6ypVjAlk92It/sJDcMSlu8xgxY0rW9vWZKCJPJjO OOZw== 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=D5m8OPf7dJDPq6M2hxkf4OTKW0pGkYjDCJziuZv+D7w=; fh=xqcbrIOv/j1NC9DwWL7cs9wu5dYsNcrfZRJG6Y55lVA=; b=EwY2Rf9DzGaWamVUuw08C+Ox4U18/bGRtRJSxEgAAHfiOcD85cS1NmSw9uo6B9DA6w kKYMNsvyU6p+wfyPG7mXyjs9ZZtPQ/gcVX2y5nt/kwnP+E6Fkj/aSVQrm4lcWVt5NlZB NAE63MsTqTo8PyzVp4qLSS7yP04kXYv3dXeciQnN5SsYvRjn2Z8WCCVPOK0chl7l1+Vt Cfz8DA+cTv/LXkMZf8LHBTR6U3LdxAh3t1LudtfSdxOOZbFYxGgoEu2MxQuMhDSQMAAG iYHSGhGLfY41JDHBrrvk9GcrPcklnlbOKf9cCdJM8xc/8ElPN1BIJNIJe2CEapS1W20m EjTQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=TyR52YCJ; 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 a640c23a62f3a-c513afe2e22si240189866b.94.2026.11.20.08.34.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Nov 2026 08:34:53 -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=TyR52YCJ; 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=D5m8OPf7dJDPq6M2hxkf4OTKW0pGkYjDCJziuZv+D7w=; b=TyR52YCJMerCLGqHlYO ndEWcYUOZuAUv6I0vydLaXrYMB3g/qILvaVyrzdWBVci24js1MNMfvmJcLVmKxN03kk7805+myBPw aRvFYvT+Fc+0GodiTYxVoL3gnFzpN5G40ds6W2VEIck5b/UwkKNyGqbkgkDRgnhPBKBRYIRryveiQ 5pJStVwnslasPfPXfJKfGw7QHbaNAJHh7qHA1/LEK8KzYfY6i1uLyAHQQg4LX4xqPgwXSlPdu9YEi m6uuQdxFMJMNt07oThPEIiUFGhalLRd21jjjX9hC9bohkoqwC3Bpvd0fq1L187HNDY/LrvfWFbDMG c4xSWEzMeSsF0xQ==; 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 1xURZZ-00AYn4-0G; Fri, 20 Nov 2026 17:34:49 +0100 From: Konstantin Khorenko Date: Fri, 20 Nov 2026 17:34:49 +0100 MIME-Version: 1.0 Message-Id: <20261120-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v4-1-ac581cf6e36d@virtuozzo.com> References: <20261120-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v4-0-ac581cf6e36d@virtuozzo.com> In-Reply-To: <20261120-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v4-0-ac581cf6e36d@virtuozzo.com> To: Mirian Shilakadze , Pavel Tikhomirov X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=8881; i=khorenko@virtuozzo.com; h=from:subject:message-id; bh=Uyp/XOgShQS4KhKZOyGxnc81oQlUwKVCZ8B1VWQM7Ls=; b=owEBbQKS/ZANAwAKAVGWCkf5YVwqAcsmYgBrAHarSK4WLpLJqxgIa+gxNV+sG66tcJm3yUqy7 O59jZ9xn+yJAjMEAAEKAB0WIQRWD23IPcXT0GO9CCxRlgpH+WFcKgUCawB2qwAKCRBRlgpH+WFc KnLaD/oDiroYyBTEtKFnKTTuB04GVxpKF+TusTJ/opkg579/s3ASdjKWjeOtWzyI5GzP5Bbxvzp p/efbujd15W1v4mqpWOiFA+1w5j0Ci8WTNs4V77azJkmcR5cPh2NJ4Gzt0hJbcLdMFSMkcKTBVn Uk1MTHRvP7nrVvbGBdtDcjhgLf11Vp1f324fzUscs2+yiri03bXc6VjLWGxBqje+rPp11HzHA6O Zzq0ikHx6XUEDgNJmP3UMmu79zpGP3+SsFMSiyu0j0JVkhmcsa4OPvpTuL5EnvepokPLrdpYuws eMzM7ThNls4Up6G1vA4iFXihVEcmznxv5CHd99s2p4vzJb35Qc79WBoqz48jS2Z0OkqXzdrtipn gCcWurw7yxsWQFZunqNMZ1ZhGgmR8Ozu7VWmM4rtYsK26nGuPERcQQSyscDxFf4OrMIHvRb6HwQ eii/7bAkdEunSeFmw1y3wo4Kj1iL6ntrl8zxOCB5oqLMO6KIZeW6TTDL3EdYdxKieYLZJ76Rcot CMXAxAzrTIRnPRms3y2il1VQDFWJO6pud9yNqDBHQ/2bxTqkVjc+b1Uy2zI6NuhdiPXIcQSVsyO 8ylwTuUiXZ4/5cHFo9UaBF/NKY1tFtNBQZI9QH49zT07iDuvUsOh0pC3kX33+7qzUPg6124cDZW PnWVZ1yHvat54Kw== 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 v4 1/3] 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 Reviewed-by: Mirian Shilakadze 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