Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1871318ybg; Thu, 30 Jul 2020 05:03:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGyx+BQ5JPt/2oGBOYCmZrOC5sNGU4XoFPvF18Ob5+OIkLTnvf1g/uZy1wMIAXVS47Cr8s X-Received: by 2002:a17:906:ce32:: with SMTP id sd18mr2335820ejb.228.1596110636650; Thu, 30 Jul 2020 05:03:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596110636; cv=none; d=google.com; s=arc-20160816; b=qHKjv3bHFbFLc/6c8GkRWv9UFf/DBUhoU2WJLQZJyLXI092/0GkZME8BjeGtAjO5Es KsIfDML+yjyi0J6yz3mkoixZJ0bf35PUpgu0g9/8+NR6TQr70PkmJgN4BDrPFHVjLdPO +BYiT4KaXHI4WT3bhbvG7PaXM5/i59HwETlMS4BRxGh8gO/sKuFpFUkJLdLIzxe5KPHM S7hzjVsTsdlpW9b8D/V8krYV3ACH5LCOsWAAWixpbghCXRMeONvZNR1Ru+S0XZwz6xqa pSyhgNplCf87u7QyHoyjZ8jzNdFZbYm8fQj9x0Gh7ek16fZM6NyE2jlJUmzKg9g9IHGF W18w== 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=kllhQ7+GH8pR+YvJz4pb0jbu1z4w8pMywo/gH/JmTm8=; b=EVYNpaKYj2DDpgvoS9r/+liZaLqxt1F/PvmWWpxJivSkP/vInnIMdkd2kBHpZrButP S1nlpL7B7XPTPSL6fKXxgDNERjzBzQXS0b/d5wKOQ/Rd1k490NeBGu6k1nOHr4LTF2VV VKI2V71Bq3t3YWe4s0I/cENihDTSqx/YqsqUK673YsrKFgFRuzzIJejjX/5JWN14Tt5E RItY7XJCKwwa9VRj2SaeCBKh4fGVrZ1iuaJQod5m8/EGbRun3waHvPKvqyQu4u/R/Ltr HGG6L/HHt0GEXGlG5N4fze2cZpOaOkb20MU5wkXYQN50hc4sNbZDeEQTHXZUnuFoVZ43 J1ew== 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 i1si3236053edn.445.2020.07.30.05.03.34; Thu, 30 Jul 2020 05:03:56 -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 S1728641AbgG3MAz (ORCPT + 99 others); Thu, 30 Jul 2020 08:00:55 -0400 Received: from relay.sw.ru ([185.231.240.75]:57040 "EHLO relay3.sw.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728592AbgG3MAy (ORCPT ); Thu, 30 Jul 2020 08:00:54 -0400 Received: from [192.168.15.64] (helo=localhost.localdomain) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1k17Ej-0002zO-S1; Thu, 30 Jul 2020 15:00:37 +0300 Subject: [PATCH 17/23] pid: Add pid 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:00:51 +0300 Message-ID: <159611045173.535980.13125182914304511849.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. Note, that we already wait RCU grace period before pid namespace's memory is freed. Signed-off-by: Kirill Tkhai --- kernel/pid_namespace.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c index da8490390f51..06398a7c4c59 100644 --- a/kernel/pid_namespace.c +++ b/kernel/pid_namespace.c @@ -109,8 +109,13 @@ static struct pid_namespace *create_pid_namespace(struct user_namespace *user_ns ns->ucounts = ucounts; ns->pid_allocated = PIDNS_ADDING; + if (ns_idr_register(&ns->ns) < 0) + goto out_free_inum; + return ns; +out_free_inum: + ns_free_inum(&ns->ns); out_free_idr: idr_destroy(&ns->idr); kmem_cache_free(pid_ns_cachep, ns); @@ -132,6 +137,7 @@ static void delayed_free_pidns(struct rcu_head *p) static void destroy_pid_namespace(struct pid_namespace *ns) { + ns_idr_unregister(&ns->ns); ns_free_inum(&ns->ns); idr_destroy(&ns->idr); @@ -466,6 +472,7 @@ static __init int pid_namespaces_init(void) #ifdef CONFIG_CHECKPOINT_RESTORE register_sysctl_paths(kern_path, pid_ns_ctl_table); #endif + WARN_ON(ns_idr_register(&init_pid_ns.ns) < 0); return 0; }