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 47B0680032 for ; Fri, 27 Nov 2026 17:41: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 6ARHdoms024309; Fri, 27 Nov 2026 20:39:51 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6ARHdoms024309 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="M+HPLzod" Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6ARHdmqE024288 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Fri, 27 Nov 2026 20:39:48 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6ARHdmqE024288 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-6bb067d094fso2288074a12.1 for ; Fri, 27 Nov 2026 09:39:48 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErEhpKBwdBRl+1Orq9/pk8ZX+J4lyoyzxMD7lyntkkFFBxgsy4vsEXi9fx0N2L8tBbSaUHHNCw==@openvz.org X-Gm-Message-State: APuU4Z8pgtgBMN9gznAlGkuMGDUNYsr36oT/JUnj8rXIcWnwyDUMiZqE Qm8Bwtd+QNSglBzjFYC+Fj1hNKeiRr06CB/4VirEOxDbP75lurpeumZVIyq0HwzwMxTzgRH0Jy5 h2RZtltQ3jyxHSTcb3ZTl8p/4pBk6ZADovfoudSHTgPuCXTmdEYvYKA== X-Gm-Gg: AZFdTZdyZOWxueSeH/6WYRIrWqDeXcQ7GP3AR0XmSjJWBZu8Jul6oULx6KHdtEinkKb Im1oglK6SEiNfB+KXOfuq5R3hzmySog3Inz/PPamajJtQ1TIcY4NFrLZR2ybixNSYaO5xL1mJ+s /RaWRUBwNHV1quICDwNxKRuwhXi3Ns6Fp679bPz4TxjOHOZgL4R11nZfV7l5SIEl+kZWbf3bqor o3aNJhVbk5qbPVMs7crnaF3m72C5r2mlRZy22tUDvZ5WSdV2Z+46v+DOH+tIu1NK+BoQUxmBh3l GVJtYl21fefhGhoYssRHxiwj1RQ3uapI9Pf5imDLX6zEy/lG0x4GUz+5us+Ep30jI/49qIYAKwa UfLDtNjUoe/wfBqGU X-Received: by 2002:a05:6402:13d6:b0:6ba:a799:d9bb with SMTP id 4fb4d7f45d1cf-6baa799dc20mr12759858a12.9.1795801188283; Fri, 27 Nov 2026 09:39:48 -0800 (PST) X-Received: by 2002:a05:6402:13d6:b0:6ba:a799:d9bb with SMTP id 4fb4d7f45d1cf-6baa799dc20mr12759848a12.9.1795801187821; Fri, 27 Nov 2026 09:39:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795801187; cv=none; d=google.com; s=arc-20260327; b=SkjkTA6aVWlJQtEeb2TNdcovheaZxAfwDPu6FaMPOnseuwrv0JgnV4JIxzQXAcCJJ9 ZCDtmpnZOvPqHGyLkNSConwhDjUSkChlKOeJfhUp/RE8llVwlg6wPGr3PnrVb5jOBxef qf7WU5iIYWk1Tk5QjpXp9icIh0io7Xu5ntXJtl94jDVJ+P6Hw3ypIRLoqV0xx6qEFNrk x7CHDqmn7z+qtgjHmarYcIcZg8FKecWryfVWT6S7yKQL8FkmGWtN944nfDwzkidAgugD NvqX94lQsdr9vMA5hzErjuMDmi8MiqYrYM9B/SnHQKVlgbz/E1i8CE0ZJb1XLw4fRLsG Hgow== 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=t45Tad/8l1zAIu9jXl0wP+25ufbj0nO13pGumiXxjus=; fh=xqcbrIOv/j1NC9DwWL7cs9wu5dYsNcrfZRJG6Y55lVA=; b=oM+heSgw8jDKvU0R+7R6yBb1r/JB4q/Girfwl7aETJp8hP/r9ESW0mIrF6d4WzZBt8 cVV8topX6ckQCa1nC/s5cux3fpljpkNP5bpkXsuSX2uLhSzKVcaeU/mh+VdDHQdFrpO1 aoMoobIPI4xZZVDOE+V4anuxxE4GRYi3ei6/EIYQN+Q5Auei6X1dBfawCLO/YLDsBmsD KFppuuiHRKrd5qO4EteFulhCv5NlnGu/7q84WuuCITBjAPISjALXBMzLfM9HCVS7s9s/ tByv6mvxLH/sGyy9yfkh8BR8RjDSbXvB89KOqq12Oz6Wdgpm/iTUHEYMR03hSEmhz5JM Ab3A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=M+HPLzod; 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-6ba46da4350si18987233a12.14.2026.11.27.09.39.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Nov 2026 09:39:47 -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=M+HPLzod; 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=t45Tad/8l1zAIu9jXl0wP+25ufbj0nO13pGumiXxjus=; b=M+HPLzodalIB21XJamb E1AKrhWDQAWW0Hb2zJSdnCteq6srA5cHL2axDT2YxHhJTwioR7/YDv+Wro8OphZjqww3UaHu4WWQi NH6sJlkR8PmO2SiUcybcRQ5saKbD+y7+cfh9MROYj3KEvfUh0e4v+WgE/PKxDEuv/lllKri3ND3BB gJhIdsga7sOnzPy6nfrEihTZjZEqsJ+WIf2nmwqMBk32dgWgc1QIWV40LtlqhaWSKC3UrBORDCV5r pV6XPLCMn1FNknxyR1g6QCNeinKTdGMwn99zmukLrlU+y71Y/Uyx5yqprZBbH0DGo9A4z8yBf4fDO jd5zYVbqqLgFCnw==; 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 1xWzv2-00CAsq-2Z; Fri, 27 Nov 2026 18:39:43 +0100 From: Konstantin Khorenko Date: Fri, 27 Nov 2026 18:39:43 +0100 MIME-Version: 1.0 Message-Id: <20261127-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v5-1-32c4b6342ec2@virtuozzo.com> References: <20261127-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v5-0-32c4b6342ec2@virtuozzo.com> In-Reply-To: <20261127-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v5-0-32c4b6342ec2@virtuozzo.com> To: Mirian Shilakadze , Pavel Tikhomirov X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=8940; i=khorenko@virtuozzo.com; h=from:subject:message-id; bh=/lkvyd+ouHDUbrhkVlDsbRK3XhhFvPG9W7aN+vUMuuw=; b=owEBbQKS/ZANAwAKAVGWCkf5YVwqAcsmYgBrCcBhayuIroqterOUn9jhsFWCp7gPrJIAukM6H uC/ey+RdCmJAjMEAAEKAB0WIQRWD23IPcXT0GO9CCxRlgpH+WFcKgUCawnAYQAKCRBRlgpH+WFc KihND/0cj+JMADDtoYipBQN3P6Qj/Aa7i4M+4UluMO04K6PQiPz7YMpBoazWT2cpREwFGGyMa8a oMbEVdfeqSAuoecfGrsLhawDAHTtqzd9PsVeBlJtQUxTwj+oxRJPOqciu+Hs5p/wl/SN3qTtos9 KGsrdYfEwnaV1LJv7ZoLjvxCjOIFxvyRsK27CnBfGDeNpRAqt6G/bLTJKDI5CNaTOykpYeRQ5f+ 7lt0D1Ax7t/DsIR1/3Xio613ardtM5nKmZKpta3fmv620PLUIteP45jpSOqXdCgzbJuacUWBX3x o2TjSmwPu/prdMzoVIscAPaxxXk7EDX8LqpRcSL+Okk6a6czW3JHVRllmhXC+DX304hmFtGT35y FC1YXt0mXNmvwVS4cgrrETcA+6pYl4pGIacJQMj5b9IuxuwR9920p2O4xpFjDwHFqcA19jLJagu f4+QfE2ZMMFvpmbuYeSA9PBBAS4gc0zKLopR/84+SRN/qpaj7BGMgHFrR7nNbWL9pgBx2RXN+t3 T14O7R3ylgEZoQI6PbL5dg/I8IaNq+FY0uRH1gPbWC6UyIRms9+2pGnJejdrG1bQaL/QU1uUxoK T8Y8oPiZ3vQexgF7y2Ycpai6hd3UOqUWG5fJ62bRFaT53FKtc2UY1xlrjdMxCu5iDARRSlQ6cwF UT2wDqnIpvRiAvg== 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 v5 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 Reviewed-by: Pavel Tikhomirov 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