Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1869986ybg; Thu, 30 Jul 2020 05:02:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpoHaAEDnS3YJmTM3f3PxKg1Go/+66L2xANXc92hsjCZ4kUL99fKY29i5435Qijk2YxxjH X-Received: by 2002:a17:907:7204:: with SMTP id dr4mr2200413ejc.258.1596110545042; Thu, 30 Jul 2020 05:02:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596110545; cv=none; d=google.com; s=arc-20160816; b=UBlwM6Ff/d3kiK2HrAeDD4fkKvMlCZjq0glyLcXP+4rz5lixv16ZjlZfhndGpHAv9S Z9nSWHl5uCDRO+rJ2C7EmrxI4jDP0fSrThCMqhwpGMbvkoU1k4wG/YfJ85N07y6XJxiJ lZzgmhAc65BPGAxnhcLL8jo7NxFSnVcoxw3IUVexENeSJVHC2T0hcmi2EL5DM3x18kO7 TaB4+aJVLcs3hpo19MaQcyd3gzqPjhTILDddftnFRy+CqQMDVJ5UXRPIeObuTXHC1/AG rF3+Rjo8mcHJfVjmqvkHkg9c9mOPIGlozyBK9g0VD2ChNCCpTAya5UcWbkScgcLmBFpX G3iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:to:from:subject; bh=TxsGBoBcwMEE6wntT8R6Qa3w6DX6Gz9ZMP42OcR/ayE=; b=uT8IaWExMJWQ1aiutZzQn59cxsQLRbpxmMng5s6aBcwX/W2AKl3VyBGUDJfSiW85JP /tgumPsuSFr0RtiNwkO6eCM4OnZCecAN/FuauXkKrlp0HH0Edb/0EEABBme5aKsH7NSR bUQLv7TvhGs/P8jC6df3RVoklf08YkUPK9pKsw1w+vutw3k1aexHY/egMezxHiSGhj4Q O8B+E+GUzUIKNBv6/fGOOKHAUeZ5iGJQXyrzSpS0+ibE6C0M3Hp5X1cLQwyXxMKa/KGv 0DCXEEx4o6GlF5jhxwxFuJkZK6Odmk2jCMvUcvQ+rwKmM3g4Bs5qtr9uYmZO3f1Yoh2q iBjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a13si2147512edv.545.2020.07.30.05.02.02; Thu, 30 Jul 2020 05:02:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728897AbgG3MBS (ORCPT + 99 others); Thu, 30 Jul 2020 08:01:18 -0400 Received: from relay.sw.ru ([185.231.240.75]:57218 "EHLO relay3.sw.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728737AbgG3MBR (ORCPT ); Thu, 30 Jul 2020 08:01:17 -0400 Received: from [192.168.15.64] (helo=localhost.localdomain) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1k17F5-00030I-Fo; Thu, 30 Jul 2020 15:00:59 +0300 Subject: [PATCH 21/23] mnt: Add mount namespaces into ns_idr From: Kirill Tkhai To: viro@zeniv.linux.org.uk, adobriyan@gmail.com, davem@davemloft.net, ebiederm@xmission.com, akpm@linux-foundation.org, christian.brauner@ubuntu.com, areber@redhat.com, serge@hallyn.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, ktkhai@virtuozzo.com Date: Thu, 30 Jul 2020 15:01:13 +0300 Message-ID: <159611047332.535980.13828558388565780541.stgit@localhost.localdomain> In-Reply-To: <159611007271.535980.15362304262237658692.stgit@localhost.localdomain> References: <159611007271.535980.15362304262237658692.stgit@localhost.localdomain> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now they are exposed in /proc/namespace/ directory. Signed-off-by: Kirill Tkhai --- fs/mount.h | 1 + fs/namespace.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/mount.h b/fs/mount.h index f296862032ec..cde7f7bed8ec 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -23,6 +23,7 @@ struct mnt_namespace { u64 event; unsigned int mounts; /* # of mounts in the namespace */ unsigned int pending_mounts; + struct rcu_head rcu; } __randomize_layout; struct mnt_pcp { diff --git a/fs/namespace.c b/fs/namespace.c index 8c39810e6ec3..756e43fd21f3 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -3258,7 +3258,7 @@ static void free_mnt_ns(struct mnt_namespace *ns) ns_free_inum(&ns->ns); dec_mnt_namespaces(ns->ucounts); put_user_ns(ns->user_ns); - kfree(ns); + kfree_rcu(ns, rcu); } /* @@ -3382,6 +3382,12 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns, if (pwdmnt) mntput(pwdmnt); + if (ns_idr_register(&new_ns->ns) < 0) { + drop_collected_mounts(&new_ns->root->mnt); + free_mnt_ns(new_ns); + new_ns = ERR_PTR(-ENOMEM); + } + return new_ns; } @@ -3824,6 +3830,7 @@ static void __init init_mount_tree(void) list_add(&m->mnt_list, &ns->list); init_task.nsproxy->mnt_ns = ns; get_mnt_ns(ns); + WARN_ON(ns_idr_register(&ns->ns) < 0); root.mnt = mnt; root.dentry = mnt->mnt_root; @@ -3872,6 +3879,7 @@ void put_mnt_ns(struct mnt_namespace *ns) { if (!refcount_dec_and_test(&ns->ns.count)) return; + ns_idr_unregister(&ns->ns); drop_collected_mounts(&ns->root->mnt); free_mnt_ns(ns); }