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 5025B8002A for ; Fri, 20 Nov 2026 14:26: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 6AKEPFLQ026206; Fri, 20 Nov 2026 17:25:16 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AKEPFLQ026206 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="o9MfKU8t" Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AKEPDcZ026192 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Fri, 20 Nov 2026 17:25:13 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AKEPDcZ026192 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-c49b95262a5so80543366b.3 for ; Fri, 20 Nov 2026 06:25:13 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErFY8sfkth8QZ36IL/aePDWvoxBFL32zr+FMT2TYS925GcpDrpYcN6JKl0pIRvl2Q2MVok4dBw==@openvz.org X-Gm-Message-State: APuU4Z/peqQ6NIrr1jSdt8x/bRT+2f0OPo5cl5k7xcJLYHAgKvmiNizU 2OaXrnkyfzKNny2gRcl6P7xqzjdbYy/Z3WtKDOJIPQ/HVPCp9hM0LMzwBLrqQY/5vkbLlXDSBvH Ge7toOq+cndQofrLbRHn7JWLij47E3NK6OKvvr5q/5xgyOag9uJwkSQ== X-Gm-Gg: AZFdTZcUsknDRq9+9oMppF3q4h6g88M1gEx2l7PK2Y6cIkmbJ3wOOPbQLXD6fp7hNsC 8N0oEoNod8t0IoQ8WhkuETXV4SVxEflqVY9kIH2CCa0Mw9h+zhtWd/vFzzKOZ4S/KlBUPLy40Hr /zJLXhcacWa4vqvK0IMGMG6J2/SWk2hToVo4Bn2B3/kiD+uo4CLKAcnB/j5PGgPoDx2VpV1dGaH 394g2t99Bzhei7U7+VqmRbTomzmdCOTCFePuNaHQHpoA/D6YZMF0BoVLqu941vcGIj2daAxiMnm IXXBh0aZa1YjFnQimW+gDVX2rRBq8IG8e2vmFlUkgT7UeZj7b/lA+QgoDEj8xWh3RQiAnw1iqYf oSy+UtT7uEJpXBipm X-Received: by 2002:a17:906:9c84:b0:c40:80eb:c541 with SMTP id a640c23a62f3a-c513a4347e4mr356959566b.2.1795184712983; Fri, 20 Nov 2026 06:25:12 -0800 (PST) X-Received: by 2002:a17:906:9c84:b0:c40:80eb:c541 with SMTP id a640c23a62f3a-c513a4347e4mr356956866b.2.1795184712394; Fri, 20 Nov 2026 06:25:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795184712; cv=none; d=google.com; s=arc-20260327; b=TG5c3H8evMAe7TmiA7/bHbZqJ+Zz+1qL1u72QiQRRG0lQ7W9JauLAcj82K4w0yikuS p9CuFAfrfrk0h2uX+e+QRlqRJbi6SYF5d8ZtOhbbKJdlBuMUhR6l7EPW8w6CmHRSDOX0 wbrFy+qyX4Er+7SP/jX1bJj4lwA0C8OIV3zOkrAwUir36sOnEUZy6b5t5f8zg4kBM9BV yIM1vJptLCTXMTTobn/acrm4k+v8FkqkUB1ywGkEYi3kLeBg9rP12MOAtXEgM5j0WLnO Tonk/j57dbMZPiWsqL+wRd/2Gg9Hr1CDeqxq2Vn0bwmEZWQUhYhWOwEof5qj5FO/tX/t NS5Q== 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=DKAzw71VhEbcG/iy2MAUGLmkfG+aB6Arc65RExtSa3Uvq/RUo/u6kHidvgE15YR9Ca lY0+D/VuuIdiZYZjJJ67eyb6VkYYdquyhzu/UkHdxjTGygVNnCkLj7kgB/X7gauCUFio Qy3942IH++vdEl/KUbIZZgDrDd9n54HgtiyEPro+75yGwM6pZrKK51ZPlvMAwt2pvdlv /W9CHP4eyEmRJVqAvSY3GA4GwG0Ki4Qd8yS0SJ2d0RZvO/VedgNcjlevwZVcefgHhNnY PQEAmqLEE/lqI12o5E2ITVMLNUH2OufumoXPeDwWdsElneAx+ZXmYq6mzT5MrM/41UUY 4DIQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=o9MfKU8t; 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-c513b0309f9si207860766b.153.2026.11.20.06.25.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Nov 2026 06:25:12 -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=o9MfKU8t; 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=o9MfKU8tT2hfewoTi/2 8S6uB/NVr70MnmK1iM9XVU7X99Khd5py+aIbE75SoRCOdSPhLWD+SRUkr5P5NO6GB/3TkFRAUhDBM 2HrvS6PtYqibftAf2WJM+xfo9UHGJwRMI+v/g3ynMkfVkpNqCbLmDTHT4JMt7+B1k68k5cVzn/J6q f0p1AXufphTyp43C1xDiRFCRcD4WiwC73trq9bQD6o3XdVwMohS/RwkJ9dQTvF/N3Jcr6U8q6Mvp5 x89NWoRWc910bJClLgert9eb6TI0+7V19l35fHnyjySz2WmEvBByVj0o5rHcooQFhNdumD0Ob+m0u rhfF7lCUpbaDJ9Q==; 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 1xUPY4-0085mG-0b; Fri, 20 Nov 2026 15:25:08 +0100 From: Konstantin Khorenko Date: Fri, 20 Nov 2026 15:25:09 +0100 MIME-Version: 1.0 Message-Id: <20261120-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v3-1-fb0214ce4f45@virtuozzo.com> References: <20261120-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v3-0-fb0214ce4f45@virtuozzo.com> In-Reply-To: <20261120-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v3-0-fb0214ce4f45@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/ZANAwAKAVGWCkf5YVwqAcsmYgBrAFhG1g7JL6+dNdogVPpO2b2gV1gaqouXBvMhN kHSb8HAnTOJAjMEAAEKAB0WIQRWD23IPcXT0GO9CCxRlgpH+WFcKgUCawBYRgAKCRBRlgpH+WFc KvESEACDhiLJE0cgnqECaJ+rO6FuBMNtsETi2SkrUs6/6+OZ6xeE0rdpUpQHrMCYUydlRYUyA6I fZgK3q7RusXCCh/MrRoIMVzTYg6E1RtbRvxIIZ2rmtf42XpMI8LIQIGwW8MqvxVgL498pEBFwr7 ofnWDbeM7IQHIZjAhBkdc00nSq4t+4MvbWM7KRcWYbXgfSY330jvNMng7VVttITchZMkqbk4Jrc cKureL1k4NVv89PNtyeR2WBAscoKJaxm19xgWZOldT67nPFyddm5W/0tAT30xytRzJ78uNJHJFk ccpzCVYKiV7NlceDH9CnVQ50apEsyWLy4U4WjgjynL/GuHuw6B/FsVGYLcgPMUHuZyISJpmf4az eJsBs1RaB+QZj6vJA7uMD8lqrw2QbHds8DGIWojPuKqDRHGGa8upNsBGXyFuUlMIQ5YlygpH5o7 Ltf6hwGRJsaLd9mdnujUd97tIS4EvdTKCrLyjTlWgbToL0vRARhBW9sc8SCSkz0Pv68G4cl+3Xh 9zJqcO8AqBwNKnqL3un0IxZCJqyVki5pefgJEqfB8zu8OggI+Ht7JKAfMtnsPb8VHEBk3ouE+2y e7Bm+bg/t4Jcn+lf1YyzQ5YnzPOI1zXTsnuj1c9jv5n305ZqDOwQunHVrmj5cCCJQNcO0B2lhoG Djb734sQlaUI+/A== 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 v3 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 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