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 B7F0C802A5 for ; Mon, 28 Sep 2026 16:42:52 +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 68SGfUTG011491; Mon, 28 Sep 2026 19:41:32 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 68SGfUTG011491 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="dkUJy87w" 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 68SGfTf6011487 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Mon, 28 Sep 2026 19:41:29 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 68SGfTf6011487 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-48aec01b6b6so520978f8f.1 for ; Mon, 28 Sep 2026 09:41:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBxU9iBXIJIOVPQxQOHLU34OvDTHRVqG0fqHXPzTn2/OM86OUozpL3BI+xNa74pQQnlm9iNt0A==@openvz.org X-Gm-Message-State: AFuF++mTUOFAzBnrQXN+D/JEPZLk5+qr4Oom0o1jQeG1yvWTyepVx4Yp PdWFD2+twJ1LhoHnwZUsGEKOo9SRLYqyL+BWcz2ljO2k9zFBpxE4gN3qRf2HfdqaOfDAr3hnqx5 Ov+BbTngQoOz5qa8rdbaGcwquEpd/aGhCewGp/NbgAd5ULDCz+JqXfw== X-Gm-Gg: AYBFou1XKjnB0pX9GvQNposVjzcqhyvIqSDzyj1U7yGPbM0+TOQqFR0wvmzNFxAi14G apKYdLEEsDdtM00IRKrWA7hi2pkPDIDv/N46fsLHyWL1gcX2BYmFM5AxMSFiOeMfj6J0FyH69fH 2G6NKQydfqHd/5UOrIzy9HKaOO4nWuoP+57mawc9S3CGvueCSOT5E3pUEbCiBe6ZarLtVFre2SL ogokq5P+3vJlqeHl91iRatsxdJubsVokpIwAibsg4pw+0EFjlawa/XbprFlHZIUnPGv8QA5CtYI sXOySWqop0IeZ4MqH+6JT93ws73gI6WqtT7h01hBUXJa1f4PESq7LNA0xSvAgmv3jAglTHtrmYg OLwNc7ozCRvuv4sn1pQ== X-Received: by 2002:a05:600c:8b74:b0:49c:fc6e:a3d7 with SMTP id 5b1f17b1804b1-49fe66e87damr217474725e9.22.1790613689301; Mon, 28 Sep 2026 09:41:29 -0700 (PDT) X-Received: by 2002:a05:600c:8b74:b0:49c:fc6e:a3d7 with SMTP id 5b1f17b1804b1-49fe66e87damr217474505e9.22.1790613688825; Mon, 28 Sep 2026 09:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1790613688; cv=none; d=google.com; s=arc-20260327; b=r9ULxf5aRt8sE0EmVgib73pxzq4m6v3UTx8qLyZl4HH+UCssD59Ew7gxVqYQ1g5ueS Hnx+JNVdmPzCf+4Ig6EGpQSy00xkPr1XZGisN4bME5zLVgXRv1KqR8YlFIHmp0dOkjYf iVcUCXkhx5d+7BSeTHuAUudfAl7Vy/RHDdiwM18dSZUz/RH1vrxU4NPoiXIwX0p4AjvG fOshw9YgtPAONsCHfaqFNIpyZm8c9yM9ZSIvLfi6txDnvze9mVPlxwFAQ91dzwoXO3tG Yyg0dSipnTDQ19B++Ud6KyrGWbojHHVNo6SieHgLm7DEIAYsqQbCbZO0wf7+k4mQ70H/ Useg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:dkim-signature; bh=gyM3KUorDt8q4n9PGxx4/A7w240oY9xDqN+Sk1X4NfM=; fh=346reOmpJGhqEImASAaKGxE5+s/50Y3SE/fyBLJtWtQ=; b=OIMYKff8EqVhHDGwANuy4h4bwfPpJf9A/4UXhNlN6n7BdWJiK37MN2hXhp9RRGFeM1 zZKLqPNVZjJkl70V0/Or8t16tChCwbE24RIS6I/plp5WO3wncxNtdXnmkRtJGyNA7ZfW sSpjANaXLt2xpo9SSjxjXNFtDp8nUE3iMRf7qYjIo806TigcnLqibvYpOZWJ2DiAl/hF h4UrhcNfqO88rn+2rxY+inMy0T9ppy28MOyuVssDrHYho7nnUrcHdMf2brAjJ6AF7spt yYdHu6cLIqaFoHy+upawIDXp06uczSRFkc5u9qJi+M3fFbxM6+oOucqX5/Rb9US1vrnE gr/w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=dkUJy87w; 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 ffacd0b85a97d-4887a84e267si20667144f8f.248.2026.09.28.09.41.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2026 09:41:28 -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=dkUJy87w; 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=gyM3KUorDt8q4n9PGxx4/A7w240oY9xDqN+Sk1X4NfM=; b=dkUJy87wyNJ1BFKvimu az2k+mKn1qWdT6PRsZPJgUQVJkwHnvclPNlM/a86PWyovCC4qz0F5Hu3eKCeIFfdmPJKRV1R3nKro 5RCvNAqyS3phRr+SxCTk657o19UU1vu4wBwfpD7aVGp9S2tG7TqT1nJlxxMgHc7iM4qgQVlJN3lkD xvsYEF+pDSStO5wB1TLBTB24CdF+LqRBSLVlOhZSxDVY/woZFPyeCH4eJQe7sfgcmQMbjavt0wzOO NlK71XB571+MAovuehdxDEIcUbRXfsW/ULZ6TVhJd9p/uwpqfEvJl8UEGQUFZPubXWQtceDWwfRyh jPFKJWPHNpIGolg==; 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 1xBEMt-006XZe-1d; Mon, 28 Sep 2026 18:41:19 +0200 From: Konstantin Khorenko Date: Mon, 28 Sep 2026 18:41:25 +0200 MIME-Version: 1.0 Message-Id: <20260928-prep-kh-vstor-142552-kernfs-pin-ve-v1-1-7297e159e813@virtuozzo.com> X-B4-Tracking: v=1; b=H4sIALSYumoC/yWNQQ6CMBBFr0Jm7STtRLR4FcPCwiAjSWk62BgId 6fq8r3kv7+BchJWuFUbJM6iMocC9lRBNz7Ck1H6wkCGLqYhhzFxxGnErMuc0J6prgknTmFQjBI wM/be8ZW9a8hYKKEyGeTzO7lDXq2B9m/17V/cLd8+7PsBDeAbkYwAAAA= X-Change-ID: 20260928-prep-kh-vstor-142552-kernfs-pin-ve-db8e7eb89201 To: Mirian Shilakadze X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4564; i=khorenko@virtuozzo.com; h=from:subject:message-id; bh=EcwmJxPXmpx5QrHVbh3CuDtMyBnMwowIL+Za5Om4s48=; b=owEBbQKS/ZANAwAKAVGWCkf5YVwqAcsmYgBqupi3nd4byer2wWEBcQQY5SgVi8nYqESyvNCSF DB7GXhKECqJAjMEAAEKAB0WIQRWD23IPcXT0GO9CCxRlgpH+WFcKgUCarqYtwAKCRBRlgpH+WFc KmM2EAC8YdrBt0ZybuyfaeLlI6+eMmaSHSqAFDwKD/Bdr3zi4HW4zSrT9xGJ90oW6GbJPgobssY WFwN4hriu72NkPdBVTSQ5xS5m3iLKW+IHwKOu0379EfNSJv4l/kwGGTMdH9dznSZHX3mgz4j6GR LnEyUAG8GHjZWcALP8HVuCKBn7X8NmcFWbfpFATQ8tIohFE6bcONrGgAKzxCnDMRKE6vNnEXwoZ 7Y8U5RxNw7FZ3GPZqWtZ+VWeJhYjRWCICWqIOdJloUT92Lvrx6HkCaZeAviKPiQyh6wlWI2Vehk ApY6cOunHP9S+Yilpk9IcgXOTqjurMJTqlsELVeDNyHXrPd+ZhXkMD8yAjcOdVrthxwH4pVUmdU s8GTamHNcnRIG0lh8i9sv7lEMlVzqqs4Rk7HlxGTJVK+O1tOFSrYvpwUtvQEvsn7RwA7hhyJjhQ IrdYTWrhopDl1eVQMxXlAgZvEq9SogObPcVyaaqb9CVLHHK5ptJNSy6q9wBq/rzKWk27A/1WIOY wlEVUHbtGSSFttuVR3lsCRLViaYpCmfzd/tGJ5la5HyR6MAy34ELldLx1DdcCuB6+vg2wePXdhi qiuUVwPH4ce/6rVD1p2aIZWh4IKgFRsiRB54l+49vmnQGvR+yzdx3q7EkzH+ozm2hGJ3wR66dSh PCMKIKd+JahyMwQ== X-Developer-Key: i=khorenko@virtuozzo.com; a=openpgp; fpr=560F6DC83DC5D3D063BD082C51960A47F9615C2A X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH vz10] fs/kernfs, ve: pin the VE that mounted a kernfs instance 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 kernfs_get_tree() stores a bare get_exec_env() pointer in kernfs_super_info, and since commit 8d1abf587552 ("fs/kernfs, ve: hide entries from a VE without invalidating the dentry") kernfs_dop_revalidate() compares it against the caller's VE to decide between dropping the dentry and answering -ENOENT. Nothing backs that pointer with a reference: if the mount is pinned from outside - the host bind-mounted a Container's sysfs, or holds an fd inside it - the superblock outlives the Container, info->ve dangles, and a later Container whose ve_struct is allocated at the same address is mistaken for the creator of the instance. Its lookups then take the d_invalidate() path on the dead instance and detach the mounts placed on top of it. Take a css reference on the VE for the lifetime of the superblock, so the comparison always names the VE that really created the instance. The assignment in kernfs_set_ve_perms() is dropped instead of converted: it runs right after kernfs_get_tree() in the same mount context, so it always rewrites the field with the same value. Fixes: 8d1abf587552 ("fs/kernfs, ve: hide entries from a VE without invalidating the dentry") https://virtuozzo.atlassian.net/browse/VSTOR-142552 Feature: kernfs: per-CT entries visibility and permissions configuration Signed-off-by: Konstantin Khorenko --- kernfs_get_tree() stores a bare get_exec_env() pointer in kernfs_super_info, and since commit 8d1abf587552 ("fs/kernfs, ve: hide entries from a VE without invalidating the dentry") kernfs_dop_revalidate() compares it against the caller's VE to decide between dropping the dentry and answering -ENOENT. Nothing backs that pointer with a reference: if the mount is pinned from outside - the host bind-mounted a Container's sysfs, or holds an fd inside it - the superblock outlives the Container, info->ve dangles, and a later Container whose ve_struct is allocated at the same address is mistaken for the creator of the instance. Its lookups then take the d_invalidate() path on the dead instance and detach the mounts placed on top of it. Take a css reference on the VE for the lifetime of the superblock, so the comparison always names the VE that really created the instance. The assignment in kernfs_set_ve_perms() is dropped instead of converted: it runs right after kernfs_get_tree() in the same mount context, so it always rewrites the field with the same value. Fixes: 8d1abf587552 ("fs/kernfs, ve: hide entries from a VE without invalidating the dentry") https://virtuozzo.atlassian.net/browse/VSTOR-142552 --- fs/kernfs/mount.c | 13 ++++++++++--- fs/kernfs/ve.c | 1 - 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c index 14a08ba6ae57d..d4bf659b5f8fe 100644 --- a/fs/kernfs/mount.c +++ b/fs/kernfs/mount.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "kernfs-internal.h" #include "kernfs-ve.h" @@ -362,7 +363,7 @@ int kernfs_get_tree(struct fs_context *fc) info->root = kfc->root; info->ns = kfc->ns_tag; INIT_LIST_HEAD(&info->node); - info->ve = get_exec_env(); + info->ve = get_ve(get_exec_env()); fc->s_fs_info = info; sb = sget_fc(fc, kernfs_test_super, kernfs_set_super); @@ -397,9 +398,14 @@ int kernfs_get_tree(struct fs_context *fc) void kernfs_free_fs_context(struct fs_context *fc) { + struct kernfs_super_info *info = fc->s_fs_info; + /* Note that we don't deal with kfc->ns_tag here. */ - kfree(fc->s_fs_info); - fc->s_fs_info = NULL; + if (info) { + put_ve(info->ve); + kfree(info); + fc->s_fs_info = NULL; + } } /** @@ -424,6 +430,7 @@ void kernfs_kill_sb(struct super_block *sb) * so we can't find it, before freeing kernfs_super_info. */ kill_anon_super(sb); + put_ve(info->ve); kfree(info); } diff --git a/fs/kernfs/ve.c b/fs/kernfs/ve.c index 630ea34d1ccab..1097fd30598e3 100644 --- a/fs/kernfs/ve.c +++ b/fs/kernfs/ve.c @@ -28,7 +28,6 @@ void kernfs_set_ve_perms(struct dentry *root, off_t key_off) struct kernfs_super_info *info = kernfs_info(root->d_sb); info->ve_perms_off = key_off; - info->ve = get_exec_env(); } int kernfs_init_ve_perms(struct kernfs_root *root, --- base-commit: 0679f0d70523972eec3a0643565521d93e26eb9c change-id: 20260928-prep-kh-vstor-142552-kernfs-pin-ve-db8e7eb89201 Best regards, -- Konstantin Khorenko _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel