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 E59A1802A7 for ; Tue, 29 Sep 2026 16:50:36 +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 68TGn78f032767; Tue, 29 Sep 2026 19:49:08 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 68TGn78f032767 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="Xg86PXaO" Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 68TGn7RW032763 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 29 Sep 2026 19:49:07 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 68TGn7RW032763 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-4887b0303b0so2512991f8f.3 for ; Tue, 29 Sep 2026 09:49:07 -0700 (PDT) X-Gm-Message-State: AFq9FYL4bCdcxYQ9TAOYgovTdH0qyd6/gRyX/A27Ii3udJYp1K53PCys oTyxWxhVfo9yfLr8XVEZhiRpuYIsF1ozr0Py4E4IsxFuIaVp9YgZowCQBxsYm1CXNodg72lK3NL jAk3iSl0mGURD5+3Z6ZbLgypOkpj4y2eXWtvLpTma93QfOgMjM3hEsA== X-Gm-Gg: AYBFou0jaN5N7x6pXqR56svxiowcbc0cVX7jsH8poMA72bp/aNKIsJphB8iVfR34cN9 qKvoxpCzYBvdTVPpMuyJFYuDJgAX+mgD99DgseRYm6DByEit8rgET8D4e4a4SbX/eSeB30tNm4A GnN03Lo9ka5lmsVAfWyDW7aBMb4mOweVuPuh9frj75xQ49TUzvWG5EFtlILYJSSbis0deQBGu2V eY92X/p38l434PZjlafAv13+lgjq/bu2qWNHb6cwIDS29+BWSxiNaB91SudzxCllMBetH3hzkpD onc4cQsCqXn2NKrD8UdWxTF8e3ws/IwiqGZABT2iEFH7fXsdbT4dFUzpeDw5etXJ12c8N6JyrkR WEbTMIH0BVC1Q1lj8yw== X-Received: by 2002:a05:6000:1863:b0:487:342:d142 with SMTP id ffacd0b85a97d-4887175ae72mr34529178f8f.44.1790700546696; Tue, 29 Sep 2026 09:49:06 -0700 (PDT) X-Received: by 2002:a05:6000:1863:b0:487:342:d142 with SMTP id ffacd0b85a97d-4887175ae72mr34529127f8f.44.1790700546129; Tue, 29 Sep 2026 09:49:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1790700546; cv=none; d=google.com; s=arc-20260327; b=ins7dYZ9lIcBD7NkB4z1mgvpWdL0pyNEQSwDZKy7TzWpZggbwSVRNIyzczh/Jm3prp wXHh9DM9v8gn/waQomS/ZJFhOLB5Dy4dmRbB7kgMpYercpmaGIRqAqV+ITtjFXX/vkjI nzi31W7EvClyX6xYUEP9Nglqh7qr8jaNuscDAg7Jy7fdZaYBnJLBHW9EwXJinF4kAPxI o+oeGlM6GB2RrS/CJDIe/KP726C2ePn+w9uCInWgYj2YujVKUDzhikbwKsNRPaDLnjy5 5dWxJaWpoEZRdpC64gFLw3Ebo6ZvLm+k4OaLiT/E03ZiCIB1wwby+k+T7LkvyFzm6gqU yeJw== 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=wVqwg+ztv1H2+9c3p6OT18hM5qUh7gNwpcml71VQm9E=; fh=f7d4VQ+MxXdh5EkArlUG3frZAj/HeYjOJUiaOoFtWrU=; b=Z2Pzptrohqdy8uKcA/bauX1XunzAqNzJbnOIdY+aOJqomnNEM7Eheu7uZ03FXqNay+ XF3O0i/sTSCpKpggExQA1uF0kS7hV/W3GdR6riW1+6M2ty/v/DJwPTsOauDEMPBRPOs7 Ybx9q6LHzXGEWhB3U2xiOz1V9e8rn72hb4vjzUbO5Nfb5ApFfC8ao76C+e7Ngi5K3zVI R7818oGdbKEfOHA5IfqtxrOGp2i1s0Yg3pQtxCrI+4sireOG/c3gAFlqn7X9ZM0GIwwr 0tYnvBPR1dGE6VpS1PyZvIgL0mjkdxPM+aHsrxPQ7/WvSb0t3j7py1mMQCNOKS6NO5kS xc6A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=Xg86PXaO; 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-48af50f7c51si4064728f8f.452.2026.09.29.09.49.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2026 09:49:06 -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=Xg86PXaO; 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=wVqwg+ztv1H2+9c3p6OT18hM5qUh7gNwpcml71VQm9E=; b=Xg86PXaOEq/8UaWNXw8 59UM9PpcXwqVuRZgj0SzBYRKFYUiJv1bEjlEOqTrfGycu+Imr64srGiN/N260jQRXgRD91uY+rYfr wmE8T9Xc69f/oNw1i7Y8rY7hDaUA7wu4BUrIWbu407ImQfVZS2TtljAgXUfu3LAJrjxjiG+Uyi17h FWT22f+dgR3hvlQ+jTgTzDB76PDlBpLkNU9GusOnFK8NkuO6mSqkiBaz/nryO743O9oEXw7vy+Jjd EeNwAIs/PjKqU1PzmSAN9vAlOdBTe8TcHrF+H1bAY1ZbJsHV8pQxuRV6NSEPbQipeAfbALtahtXy+ T6b0JxNhhaUpOFQ==; 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 1xBaxn-00GcAP-0z; Tue, 29 Sep 2026 18:48:55 +0200 From: Konstantin Khorenko Date: Tue, 29 Sep 2026 18:49:03 +0200 MIME-Version: 1.0 Message-Id: <20260929-prep-kh-vstor-142552-kernfs-pin-ve-v2-1-0795e3aee679@virtuozzo.com> X-B4-Tracking: v=1; b=H4sIAP7ru2oC/5WOQQ6CMBREr0L+2m/6q0jrynsYFgJfqcSWtNAoh Ltb8AQuZzLzZmYI7A0HOGczeI4mGGeTkLsM6vZmH4ymSRqkkCehpcLec49dizEMziMdZZ5L7Nj be8DeWIyMTaW44EppKQgSKFXu5r2NXCFOJKD8uWGsnlwPK3/NtWZlfrYvkbb0P7ORkLCQumDKN Ss6XKLxw+imye1r94JyWZYvwMm4ufAAAAA= X-Change-ID: 20260928-prep-kh-vstor-142552-kernfs-pin-ve-db8e7eb89201 To: devel@openvz.org, Konstantin Khorenko X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3966; i=khorenko@virtuozzo.com; h=from:subject:message-id; bh=raq7EgH3JG8oex4fZ8aBCGNts55MbJx9JM84sFZBKUU=; b=owEBbQKS/ZANAwAKAVGWCkf5YVwqAcsmYgBqu+wBwK5xvgciZlQCwhtOemXwreecp1DLwOdIe oBHY/gTxWeJAjMEAAEKAB0WIQRWD23IPcXT0GO9CCxRlgpH+WFcKgUCarvsAQAKCRBRlgpH+WFc KjV8D/9wtPAs7iRL8NiEt0JXxbp4aFQv0FlqHkNPFoKNKhf3cxrzC28fmiGEH31FlRqyUIWR81J ufI1423/awokiGsoiEBlLgTSyEPyrS8n9kZnYHxYnCGnNqKxoZro3mCwelGIm7RjXMS7Rqzzz5s txKnGV2PQJzGlAeNuQ2UAlwo88IsE3MSs1r9T1cvZuATUnYMFZjY6P3h6ojB3NHAP6fMMox0SmX EKW+A1uRW6uqgSgMqkR32MbaYzF3n55NZpl6XScmeG0u0o8yKozdUJT2ngC+UYLkLOp3Bt89XWQ XZMiCa3dyDD+gf/HV0cc9eh0WeyVzfwUiSdSG3p0xePLJUp2XbWo6A3rL4fWsByyerLHzXnD315 V2390/tA2OjUQrRVR/nALuJWwcePd54jrn3nDyo7J4qs6AUzyAN0RcP4Ac54djfW/ZvRF8wx+MV z1rLIBMEbnIV/9/kr5r/IhVO9Pkz91cQ9MLQoMJikgI5akeqQkUbraq24XYVDNGjVLi3xmbY8V+ N69Tutm0IeluRER89q2V8mDkURMJS+455EmoUs5XBZBKpK88Mp7T4fDZLMqqWxP5x4oln4nMDc1 8XsOSkJNk/TchZViVKFViny8W+vJPC/B0LSZSBGNl4sXNBtvKBWf3daIos9f4KBljqlWoStlNEk odLtB7WWHuePXhQ== X-Developer-Key: i=khorenko@virtuozzo.com; a=openpgp; fpr=560F6DC83DC5D3D063BD082C51960A47F9615C2A X-OZ-Fwd: true Subject: [Devel] [PATCH vz10 v2] fs/kernfs, ve: pin the VE that created 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. Review notes: * Pasha: the stale match is hard to hit in practice, since a new VE gets its own netns and with it its own sysfs superblock and never looks at the old instance; * Mirian: the comparison in kernfs_dop_revalidate() (8d1abf587552) is the only reader of info->ve, dropping it would also close this. 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 Reviewed-by: Pavel Tikhomirov Reviewed-by: Mirian Shilakadze --- Changes in v2: - commit message updated - reviewed-by lines added - Link to v1: http://lore.virtuozzo.com/20260928-prep-kh-vstor-142552-kernfs-pin-ve-v1-1-7297e159e813@virtuozzo.com --- 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