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 19271817A0 for ; Mon, 16 Nov 2026 10:47:22 +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 6AGAkAK1022670; Mon, 16 Nov 2026 13:46:10 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AGAkAK1022670 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="Q0vfnhzx" Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AGAk16g022636 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Mon, 16 Nov 2026 13:46:01 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AGAk16g022636 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-490ab0a20ebso1981492f8f.1 for ; Mon, 16 Nov 2026 02:46:01 -0800 (PST) X-Gm-Message-State: APuU4Z80b2Jl++q1G+oH5AI56wMFhRoK+6V7CtU675OBnKl1gHJLYBz5 p8D1zOfPKw2zDPQ09oZTGhLaqK5b15eKr9EEy7QiGFpzre1wgVROdvdlWmpBsBLsJPFFH2X+zHN qmLl6/wsu6TTDJ+2RA7V36nhkr0DpDTfRyRt3KGqxLjLWSavCNWGjSQ== X-Gm-Gg: AZFdTZd+6K6LY0emojPo0rGrsmvtTKFVMgdoMroiE+95LfYAVCXgZ/tD/N1InQVvO3k HTClDnl7GBwcGNIB8Uu7fbCUOS3qmJBAWqUnQMpgSZ5F9x/BZOH0jnc9Ji/2ZHyLpldgXUQ585T tYlr6uHEIjuBS/azl1p7bEiSGY4eBYtk2gMiIQ1dwhZESiS/2nWYRkFtKUC6lj10XKrcGr4VBiN abkxE3TI50cNtxzQYwovYlxfZwmDWp0wFUC3G3/UuckHyp305xrFtXJCmpy6h0DP98jI3xH1mUI Hso6p1Yy2i5JOUMeBYH0pMK6TRb5FD/M3Yh5BAskly4On8hGqj7Ze7B8B3z9DGX/EqYgq2b7PXa 9mCK26FBKfFodG58M5WJagatY4EN6jg== X-Received: by 2002:a05:6000:490a:b0:487:1662:cf4c with SMTP id ffacd0b85a97d-49c6dc01394mr21183542f8f.7.1794825961384; Mon, 16 Nov 2026 02:46:01 -0800 (PST) X-Received: by 2002:a05:6000:490a:b0:487:1662:cf4c with SMTP id ffacd0b85a97d-49c6dc01394mr21183491f8f.7.1794825960889; Mon, 16 Nov 2026 02:46:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794825960; cv=none; d=google.com; s=arc-20260327; b=e/lERJYY1J1GuC43fdSRcLp4J01qiAcKKyCPmvPOLY9D7Pf59GfRXmd8GfDS79MQPO /A0pv4c+HIdTW7W5Ytjc6ix0rLaFINDalb5k4evHhF5CQGU3Ur5ZIhqRo0QJ4cEzn1kk bL04NIUGV5sfaSJl+bXQwLOnvHjob04yvYFfXx0oU3rgLK6qEdbk5zTV6fCHAU1MfHrG jux5Ri+Ub8Cb9V8LqxbVsr5ouolOr3vvtDwIiGxCwCTzT3pa6qdZmV312JY/xpj5y79C 4sjtxy6BsnYA7Q7awYcxYzjr4Ub5zLtBoSncNb2g8ZHrbsNg6N7orr6qWrtLjvdaNiXi ZLbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=CTYvNHALx0zuMlqZWkciNgwqKtxQfAo+rIee+N1rHJM=; fh=wpoNUURlquLpJK/14Kny0oMIYkY7mYwjJ/Ils9UT2kk=; b=gwRhDnZYjrlQqQDJv9+bi8IcFuLhej7XU8GG3VtKaEOJY1g0VGyxhpLIseuvJ+Zu5a gMUhgGztDetGFq/qXxyHkk7bkJmzN4nLjO4qKC6AzklNo1hJlYS/l0oKZLx0PgzatAV9 rRpWj+97z9H6bBxOVX06A9v2sMN9amqlgjLxG88zkoqCwD37mtUGFids5bUGhRq5Jhi4 zpcSjJpE2LoRmm6sVYLJ++SdUwiDSa8Taj5pKP3tEjHX6zwHfL3wzXAS9uWPZ7aDYb/3 hfFI9zs1E2T7jWL+9Q4kCnwPVPL5EGNAK5CYcP41FxcQCN+hSbtULT/PTRBo3EBzHtya 5yYg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=Q0vfnhzx; 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-49d85afc0fbsi15975057f8f.93.2026.11.16.02.46.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Nov 2026 02:46:00 -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=Q0vfnhzx; 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=CTYvNHALx0zuMlqZWkciNgwqKtxQfAo+rIee+N1rHJM=; b=Q0vfnhzxzJHY WtsoWYXaX1fcyYZBOaS/Qs8weEcbZfXyvt8SLGF7KL1FBGew5V7/jZ1IfN2IN7PtdZBTMHru1MVfm xk2R/S5XiZfm6yGxm4pHjZndr+bMTovshQutuh4/lRvA/UKeBSjOrcYTGn0q4H0uKBzXYb2dF9qVF hkO+c0gmGliRhLirfmN+uU4m2KHOaQ6AapjIYhAebXx8RuzRg53r7xzl9n5WJgsEITJxFE4CAnGUE cqKkyw5zA91JE3ptWNMhBLFgWT7sFKFjkhnPOqrF++rmo2HhUlZeIB5s61mi+hfYd5oe63qBfgJZX ub5BfKLFWcP+CslO3LrKBg==; 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 1xSu9Z-000IkS-2E; Mon, 16 Nov 2026 11:45:52 +0100 From: Mirian Shilakadze To: khorenko@virtuozzo.com, ptikhomirov@virtuozzo.com Date: Mon, 16 Nov 2026 14:45:46 +0400 Message-ID: <20261116104552.102938-4-mirian.shilakadze@virtuozzo.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261116104552.102938-1-mirian.shilakadze@virtuozzo.com> References: <20261116104552.102938-1-mirian.shilakadze@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH vz10 3/6] ve: hide the tasks that set up a starting VE from the rest of it 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 CRIU's restoring tasks enter the VE before it runs, so they stay VD_PTRACE_COREDUMP. A container binary run during the restore, such as the tee that post-restore runs via vzctl exec3, can open their /proc//fd and take CRIU's log, its /proc fd and the transport socket. Mark a task the host sends into a starting VE as VD_VE_SETUP_TASK. Fork keeps the mark and exec drops it. While the VE is pseudosuper, such a task dumps no core and is reachable only from another setup task of the VE, so CRIU's tasks still reach each other and what they exec does not. Once pseudosuper is cleared the mark counts as VD_PTRACE_COREDUMP, so the restored processes become ordinary ones. Feature: trace: prohibit tracing sensitive tasks from CT https://virtuozzo.atlassian.net/browse/VSTOR-151265 Signed-off-by: Mirian Shilakadze --- fs/coredump.c | 2 +- include/linux/mm_types.h | 4 ++++ include/linux/ve.h | 4 ++++ kernel/ptrace.c | 23 +++++++++++++++---- kernel/ve/ve.c | 48 +++++++++++++++++++++++++++++++++++----- 5 files changed, 71 insertions(+), 10 deletions(-) diff --git a/fs/coredump.c b/fs/coredump.c index 3d15612e3493..6977c31aad59 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -618,7 +618,7 @@ void do_coredump(const kernel_siginfo_t *siginfo) goto fail; /* Avoid dumping sensitive tasks */ - if (mm->vps_dumpable != VD_PTRACE_COREDUMP) + if (ve_vps_dumpable(mm, get_exec_env()) != VD_PTRACE_COREDUMP) goto fail; cred = prepare_creds(); if (!cred) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index befdf38ef855..9067efbaccac 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -1115,6 +1115,10 @@ extern struct mm_struct init_mm; #define VD_PTRACE_COREDUMP 1/* tasks with ptrace and coredump allowed */ #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 and the + * only ones with the pseudosuper relaxations, + * VD_PTRACE_COREDUMP once pseudosuper is off */ /* 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 2fe1a1c9ff55..56c310205394 100644 --- a/include/linux/ve.h +++ b/include/linux/ve.h @@ -284,6 +284,8 @@ 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); +int ve_vps_dumpable(struct mm_struct *mm, struct ve_struct *ve); void ve_set_rpc_kill_fn(void (*fn)(struct net *, bool)); @@ -393,6 +395,8 @@ 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; } +#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 faf60bb8ae2c..ff71c3e37bc1 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -284,11 +284,26 @@ static bool task_still_dumpable(struct task_struct *task, unsigned int mode) * whose mm was already dropped in exit_mm() or a kernel thread - cannot * 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. + * pidfd_getfd()) after exit_mm() cleared ->mm. While its VE is + * pseudosuper, a setup task is only inspectable by another one. */ - if (!ve_is_super(get_exec_env()) && - (!mm || mm->vps_dumpable != VD_PTRACE_COREDUMP)) - return false; + if (!ve_is_super(get_exec_env())) { + struct ve_struct *ve = task_ve(task); + + if (!mm) + return false; + + switch (ve_vps_dumpable(mm, ve)) { + case VD_PTRACE_COREDUMP: + break; + case VD_VE_SETUP_TASK: + if (!ve_current_is_pseudosuper(ve)) + return false; + break; + default: + return false; + } + } if (mm) { if (get_dumpable(mm) == SUID_DUMP_USER) diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c index 4db2d06da643..f7f802dc7ffb 100644 --- a/kernel/ve/ve.c +++ b/kernel/ve/ve.c @@ -1788,6 +1788,42 @@ bool ve_check_trusted_exec(struct file *file, struct filename *name) return false; } +/** + * ve_current_is_pseudosuper - may current use the pseudosuper relaxations of @ve + * @ve: the VE that grants them + * + * 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. + */ +bool ve_current_is_pseudosuper(struct ve_struct *ve) +{ + struct mm_struct *mm = current->mm; + + if (ve_is_super(ve)) + return true; + + return ve->is_pseudosuper && task_ve(current) == ve && + mm && mm->vps_dumpable == VD_VE_SETUP_TASK; +} + +/** + * ve_vps_dumpable - vps_dumpable of a task as the access checks see it + * @mm: the task's mm + * @ve: the task's VE + * + * A setup task becomes an ordinary one once @ve leaves pseudosuper, which + * cannot be set again while @ve runs. ve0 never leaves it. + */ +int ve_vps_dumpable(struct mm_struct *mm, struct ve_struct *ve) +{ + if (mm->vps_dumpable == VD_VE_SETUP_TASK && + (ve_is_super(ve) || !ve->is_pseudosuper)) + return VD_PTRACE_COREDUMP; + + return mm->vps_dumpable; +} + #ifdef CONFIG_CGROUP_SCHED int ve_show_cpu_stat(struct ve_struct *ve, struct seq_file *p) { @@ -1848,12 +1884,14 @@ void ve_setup_task(struct task_struct *task, struct ve_struct *old_ve, return; /* - * A task the host sends into a started VE is hidden from the tasks of - * the VE. The mark goes to the mm, which may be shared, so a task - * coming from a container never gets it. + * A task the host sends into a starting VE is a setup task, one it + * sends into a started VE is hidden from the tasks of the VE. The + * mark goes to the mm, which may be shared, so a task coming from a + * container never gets either. */ - if (task->mm && ve_is_super(old_ve) && ve->state != VE_STATE_STARTING) - task->mm->vps_dumpable = VD_VE_ENTER_TASK; + if (task->mm && ve_is_super(old_ve)) + task->mm->vps_dumpable = ve->state == VE_STATE_STARTING ? + VD_VE_SETUP_TASK : VD_VE_ENTER_TASK; /* Drop OOM protection. */ task->signal->oom_score_adj = 0; -- 2.43.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel