Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1871631ybg; Thu, 30 Jul 2020 05:04:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhuZ8JVKmwoOsRrkBpSNMzisU/1CdvVN4dUhFsTglOUQcM2/HFzNTyQ+FiykiANVIoY03r X-Received: by 2002:a17:906:3ac4:: with SMTP id z4mr2117732ejd.65.1596110660533; Thu, 30 Jul 2020 05:04:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596110660; cv=none; d=google.com; s=arc-20160816; b=H3WJ2zd83maRDkjDAysUoqDkCfoitVSP65gQ9UZSKMwOloBTNFe9T9Q42ImlSOXTYC UP5cQmRen/ZvaWZMiAQRoSWAFFjX2hTJ+cSPVOg21RFhlSkjEj2VV/uv1n2VF23dQzcU 1xpggvQh5UXAX0mDS03O4jOVHHPOUWCkXjERJ6iMjcDr2OQqYO5kquwwLRo5g/6/ny0E 2JmTiAS7OnZgWVnK/4Y0SweSoMP2HRFWtg3nW5kYcfsBEh8jJ05RL9gR1tGOVkfnh6QG NaRs9ZtlLZ0K/Miz3Z0rsjqGdLXUhWEq3dPrf4U0qWs/GMf8O3D80+ewZZ4SC8NSkVxZ j90w== 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=r7e5DzgI38AziC8oZ4sEvCn1F9/EsmSdqd/5Pji2+vY=; b=Jeyx+1+UqoKZbsy4N0qIv7JSiwZfYJAeK7tIvgTnign1o1rd4Wn5eeqqg7kMnsv52Q P8RmcH2+4RfoP3mlh2Ool4coxlRGI/CCXjujLfHrxjEkSLvefXEqZemUz/mwcIUvEOg8 Xk5XF2tgYxGhSGM0hscA6rhr+r72y6e5KuZ5hSfRgsTHiciRY/TnSRaWBdIoztcNQi/M e4rwQ1TbAPL9gE8JLXrEO/UTpZa9MqinqbJjQu4Lutzj9rhpO0awHfpniikncyihM/qP wq+GqjnIxN6iOHZhD3rv6ImDlFdQpWSodON8jn8cvUS/OXKsofDmyenE8jUO5U4G+Aus RFdg== 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 o9si3121217edw.550.2020.07.30.05.03.58; Thu, 30 Jul 2020 05:04:20 -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 S1728820AbgG3MBR (ORCPT + 99 others); Thu, 30 Jul 2020 08:01:17 -0400 Received: from relay.sw.ru ([185.231.240.75]:57156 "EHLO relay3.sw.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728675AbgG3MBK (ORCPT ); Thu, 30 Jul 2020 08:01:10 -0400 Received: from [192.168.15.64] (helo=localhost.localdomain) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1k17F0-0002zz-44; Thu, 30 Jul 2020 15:00:54 +0300 Subject: [PATCH 20/23] ipc: Add ipc 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:08 +0300 Message-ID: <159611046802.535980.15486117399701470621.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 --- ipc/namespace.c | 13 ++++++++++++- ipc/shm.c | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ipc/namespace.c b/ipc/namespace.c index 7bd0766ddc3b..ce6f87dd6d08 100644 --- a/ipc/namespace.c +++ b/ipc/namespace.c @@ -63,8 +63,17 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns, msg_init_ns(ns); shm_init_ns(ns); + err = ns_idr_register(&ns->ns); + if (err) + goto fail_exit; + return ns; +fail_exit: + mq_put_mnt(ns); + sem_exit_ns(ns); + msg_exit_ns(ns); + shm_exit_ns(ns); fail_put: put_user_ns(ns->user_ns); ns_free_inum(&ns->ns); @@ -117,6 +126,8 @@ void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids, static void free_ipc_ns(struct ipc_namespace *ns) { + ns_idr_unregister(&ns->ns); + /* mq_put_mnt() waits for a grace period as kern_unmount() * uses synchronize_rcu(). */ @@ -128,7 +139,7 @@ static void free_ipc_ns(struct ipc_namespace *ns) dec_ipc_namespaces(ns->ucounts); put_user_ns(ns->user_ns); ns_free_inum(&ns->ns); - kfree(ns); + kfree(ns); /* RCU grace period wait is done in mq_put_mnt */ } static LLIST_HEAD(free_ipc_list); diff --git a/ipc/shm.c b/ipc/shm.c index 6cf24a5994ec..9e83556d9dcb 100644 --- a/ipc/shm.c +++ b/ipc/shm.c @@ -137,6 +137,7 @@ void shm_exit_ns(struct ipc_namespace *ns) static int __init ipc_ns_init(void) { shm_init_ns(&init_ipc_ns); + WARN_ON(ns_idr_register(&init_ipc_ns.ns) < 0); return 0; }