From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (unknown [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 3981B80024 for ; Wed, 26 Aug 2026 15:40:04 +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 67QFco3G010162; Wed, 26 Aug 2026 18:38:51 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 67QFco3G010162 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="UL7Xx/XZ" 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 67QFcnhi010154 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 26 Aug 2026 18:38:49 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 67QFcnhi010154 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-6a3f8cbd9feso1281272a12.2 for ; Wed, 26 Aug 2026 08:38:49 -0700 (PDT) X-Gm-Message-State: AFuF++lrTF6fJAWCsuY9mZFQXoTsmj+6O46yGpTfuN3OdmDl50sskQM3 4u5bP0CQ+cF6cOWJTIF6eSbXxWX3QBJfhGq0XSVAnX9mrQ8v5ba7WsUnoKL/sTtXR8N7HQqL6A0 VMixFbduKJQtycnxSAQeBklWThZj6HbxegTzZU7ZjTthgzQmx0gkkmg== X-Gm-Gg: AR+sD109qlBEiM2qSOyhLULbBBHEoVKx0LAiHPU+JaDlfyq9BuEaH7c0RfqJ7JfeAwu pcnn2FZe3CTAbhgiDlc7BGmvDtUGShQztUgGjDZZmdnFQDWkslHphT8G161CTVxj0A70PCY9i1b JWtZYD+UayiNdzd0edzd/TQEB2KTZrSZtezdpV/NMCp0KJitH+tGlG3gnweKbUqBk751V731NpG MSQnyzczHAOyJPOhk6SP7yOK1OEpTKJkLwSubMH8Kb1Kpi/YrZ7QCAGP8jRLONZN1q44yEC0MWL GIr/T6WMJXcR/k5WTn1yigGHPIHLIm566NLUelNDgTaU+kz4LBXJcNqPomCzolOYNz05mQjvu0v kD+5iHz6GMoVzQeXR8Q== X-Received: by 2002:a05:6402:1586:b0:6a5:d8f0:dc12 with SMTP id 4fb4d7f45d1cf-6a5df64dd40mr10891973a12.14.1787758729036; Wed, 26 Aug 2026 08:38:49 -0700 (PDT) X-Received: by 2002:a05:6402:1586:b0:6a5:d8f0:dc12 with SMTP id 4fb4d7f45d1cf-6a5df64dd40mr10891880a12.14.1787758728528; Wed, 26 Aug 2026 08:38:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1787758728; cv=none; d=google.com; s=arc-20260327; b=Ji+WNUrFuMNOYC6Ma5QSbVpT0h4+67Zp6PJMGeJUt4NrgVdb/vaaEs/pGsQ+og0zEe hq1IHVeiFCwsh5bF3XoKwD9jLpS4Dg1xaXOV8SwHlWM5U0HG8VrkXBmseBmqBC4xT1d8 8CeTf3Pg9einC5wz0n8/u49TVLou2yWkWMQSkLTPCnboP0SDAUay/kaEWFR4JKJ4ZVXJ nE6Vife4Ncu0H1R30x7iHW+8O8o+W2Q3saX5/XNuc6g+iKv9XvSPgB5xjyEqjiflanro bToISQc9gegI/KevpB7znBUs3klTDxaFnz0513WDUtKTW5/7mjiQGlvtwY64T9JoOjZZ pLPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=subject:in-reply-to:cc:to:from:message-id:date:dkim-signature; bh=2xznQrSgFdWlu+qn6+G0qq2UdhmfQl8ZWiCqh01oMag=; fh=6WaLqqjLrnoBYT6o6L3rXzHBtCCDnrtj0IcE19DsjNk=; b=QfdJqv6kiv65lEEo71yXYNLMwIyPY07w7+ggNn9STUGG6rWCjXp9HdmobhlK53EA0y QrQ4fuxeEInfb5YIimtQrRWtfEqRCnD0VdlBNqZWWMjQML/NGbYBfmcnSTGs6YtranJJ +CJnjtHyglPXgMUIvB1Gr+TcRw6APFMKITO8AZnxMarI1FXw7SccmVFIFAppk/3o7F4+ qHX4a+0xYoG7029/AhFVlNckNsCU30AMjUMo0f17+kI4vAS9AvUAsZtT3a3xaUJXJmGa ktbzHghpOpqBC8Gt8sSZnpSZa3COlnSP4QqrG0Q+zj6joyAcKvkqqozh5gGc0Sq3iUIv l+dg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b="UL7Xx/XZ"; 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-6a5de87a79csi4750176a12.33.2026.08.26.08.38.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2026 08:38:48 -0700 (PDT) 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="UL7Xx/XZ"; 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=Subject:From:Message-Id:Date:Content-Type: MIME-Version; bh=2xznQrSgFdWlu+qn6+G0qq2UdhmfQl8ZWiCqh01oMag=; b=UL7Xx/XZjQvP rPWPocE4v0q6cDFTpTj8GVp6ovrywfTucke8TcRHUiaEA+rRoKko0Oz8Bq5KiEJpXUe/3ABlMLzEn y8GZ97xbDS3kSOroLtadNq9K7CSEM5MiQqKkaD3BHAc9d5td+vXira/La8xNvFRS8VJQ/g5e8Dbxj tPG8E34UDBTo6mDy28HR8VeP7DTEA1UlT/vvqs7whLMTOwzjGR5cYomi1y7EBzrztOr0CRSmuRhs6 1rU4xutwbKqEFi2YfR0Y4Gd6YY1UDhShrPfXAiSXuR2LE0hkjJ/K9RcZXOe1bM10t4fZ2SujZuSBY 0nw5+v6O48mtkfhm35Cdmg==; Received: from ch-demo-asa.virtuozzo.com ([130.117.225.8] helo=f0.sw.ru) by relay.virtuozzo.com with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wzFfx-004iV7-1Z; Wed, 26 Aug 2026 17:38:47 +0200 Received: from f0.sw.ru (localhost [127.0.0.1]) by f0.sw.ru (8.18.1/8.18.1/Debian-2) with ESMTP id 67QFcloE907571; Wed, 26 Aug 2026 17:38:47 +0200 Received: (from kostja@localhost) by f0.sw.ru (8.18.1/8.18.1/Submit) id 67QFclYJ907570; Wed, 26 Aug 2026 17:38:47 +0200 Date: Wed, 26 Aug 2026 17:38:47 +0200 Message-Id: <202608261538.67QFclYJ907570@f0.sw.ru> X-Authentication-Warning: f0.sw.ru: kostja set sender to khorenko@virtuozzo.com using -f From: Konstantin Khorenko To: Mirian Shilakadze In-Reply-to: <07f25e8bb318c82bc628051fe3882ccfc37befc2.1786950779.git.mirian.shilakadze@virtuozzo.com> X-OZ-Fwd: true Cc: OpenVZ devel Subject: Re: [Devel] [PATCH RHEL10 COMMIT] ve/fs: take the owner of copied mounts from the namespace, not the task 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: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org The commit is pushed to "branch-rh10-6.12.0-211.39.1.16.x.vz10-ovz" and will appear at git@bitbucket.org:openvz/vzkernel.git after rh10-6.12.0-211.39.1.16.10.vz10 ------> commit a614531f0672e6ab3ad4f13c91fe813dc8927009 Author: Mirian Shilakadze Date: Mon Aug 17 11:16:41 2026 +0400 ve/fs: take the owner of copied mounts from the namespace, not the task A new mount takes its ve_owner from get_exec_env(), the VE of the task doing the work, rather than the VE of the mount namespace it is working in. The two differ for a ve0 task that has entered a container's mount namespace and stayed ve0, which is what nsenter -m gives you. Two places build mounts that way and neither passes through commit_tree(), so the transfer added by the previous patch cannot correct them. copy_mnt_ns() takes the owner from the unsharing task unless an explicit VE was threaded in, which only happens for CLONE_NEWVE, so a plain unshare(CLONE_NEWNS) hands back a ve0 owned copy of every mount in the namespace. open_detached_copy() passes NULL to __do_loopback(), so open_tree(OPEN_TREE_CLONE) mints ve0 owned clones in an anonymous namespace the mount never leaves before being executed from. Either one undoes the trusted exec check with one extra command: nsenter -t $INITPID -m -- unshare -m -- /ctown/planted This is older than the mount transfer it defeats. Both paths also launder a tmpfs the container created entirely on its own, which ve_check_trusted_file() was already supposed to refuse, so the check has been avoidable this way since it was added. Take the owner from the namespace being worked in rather than from the caller, the same rule commit_tree() follows for a mount that moves. An explicit VE for a container being created still wins, and nothing changes for a task working inside its own VE's namespace, which is every normal mount, bind and unshare. Note that ve_mount_allowed() tests the limit against get_exec_env() while ve_mount_nr_inc() charges the owner, so in the mismatched case a ve0 task passes the check against ve0 and the copies are charged to the container. That split is older than this patch, which only widens where it applies. Fixes: d65efacf542b ("trusted/ve/fs/exec: Don't allow a privileged user to execute untrusted files") Fixes: fc7157b84c32 ("trusted/ve/mmap: Protect from unsecure library load from CT image") https://virtuozzo.atlassian.net/browse/VSTOR-141429 Feature: ve: ve generic structures Signed-off-by: Mirian Shilakadze Reviewed-by: Vasileios Almpanis Reviewed-by: Konstantin Khorenko --- fs/namespace.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index f8319a2b33df8..4adc1db84b4c0 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2830,6 +2830,7 @@ static int do_change_type(struct path *path, int ms_flags) static struct mount *__do_loopback(struct path *old_path, int recurse) { + struct ve_struct *owner = current->nsproxy->mnt_ns->ve_owner; struct mount *mnt = ERR_PTR(-EINVAL), *old = real_mount(old_path->mnt); if (IS_MNT_UNBINDABLE(old)) @@ -2846,11 +2847,17 @@ static struct mount *__do_loopback(struct path *old_path, int recurse) if (!recurse && __has_locked_children(old, old_path->dentry)) return mnt; + /* + * The copy belongs to the namespace it is taken from, not to whoever + * is asking. The two differ for a ve0 task working inside a + * container's mount namespace, and open_detached_copy() never reaches + * commit_tree() to have the owner corrected later. + */ if (recurse) mnt = copy_tree(old, old_path->dentry, CL_COPY_MNT_NS_FILE, - NULL); + owner); else - mnt = clone_mnt(old, old_path->dentry, 0, NULL); + mnt = clone_mnt(old, old_path->dentry, 0, owner); if (!IS_ERR(mnt)) mnt->mnt.mnt_flags &= ~MNT_LOCKED; @@ -4372,7 +4379,16 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns, old = ns->root; - new_ns = alloc_mnt_ns(user_ns, false, new_ve); + /* + * A copied namespace holds copies of @ns's mounts, so it belongs to + * whoever owns @ns rather than to whoever is unsharing. The two differ + * for a ve0 task working inside a container's mount namespace, and + * copy_mnt_ns() populates the namespace directly, without going + * through commit_tree() where the owner would otherwise be corrected. + * An explicit @new_ve still wins: a container being created owns the + * namespace made for it. + */ + new_ns = alloc_mnt_ns(user_ns, false, new_ve ?: ns->ve_owner); if (IS_ERR(new_ns)) return new_ns; _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel