Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1869568ybg; Thu, 30 Jul 2020 05:01:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1VRJJqAx1GqW2W9k/+BTP0/m4rg8S9G64QuhLrys+Hd/3JjuJRitLBaffsI43FoN26zSD X-Received: by 2002:a17:906:46c6:: with SMTP id k6mr482371ejs.230.1596110515221; Thu, 30 Jul 2020 05:01:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596110515; cv=none; d=google.com; s=arc-20160816; b=iLGg4UK3yahgKYDbQ/199NH0ttoP4vvN2Y6SXYsNAiJ/h/t6QmosPeMCJFDRgQrkG0 y7i8IIaTHv7v0Hk8w9j8maquR1UkweZZWhxqlmXBhjPNJJ+YuFOC6cyqXmYW6GEpipYG N4KaGjzs8C46iAr1qpj44AnaPx0bvm67+Uj1H33Fq7BRM2I4BFFJcq/2DMBDEFZBB6my G0Vducn9WT6x/bxYtCYw7SLyDiYYMuqGE0xzPcN07jSvG281++PoOZHsXw7IMGUzQpqb dAPfsNLl8Zit+P92f3sqWMdr6Ii1eOy9Cy/uc2IDcgpHIXIZqjJvvu/1j3fiecHJGWSR OreQ== 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=WjtDUzsZlKDsdC2I5cMvozWyUEE7KFgB85gw0Xt/bBI=; b=hZkoS6vr5Sdkqfrsogsy9YVbjPjPzpG9rzkw+kToD42cWCvZI5RNsBlfNnOgHkfgr8 oK+57s2HTc1/q0F4haXa5Xi5X5CayTViDSEaHKn/zIOJ9Mj2AAKeaXwT34toI6raK6RW AeDr0M00PRTZ6j1pNnww5/vgAf25D4IDJfjNzs0bycODqZXjpmVlpPwWpnhLOOSol/ZR LwyMh0cSEqRML7fc/ufoO4qf9qLSLZptk/rTJ+//qudvcQnDGKgKSUgUucvU/e3mOR86 wKCCQBtJKG+QmnTyI7b+dyjM4IxJglXTaq165yAiBVZl2bG8+V7eMnusvKwNFCPzc7ym 658g== 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 q14si2977574edw.527.2020.07.30.05.01.32; Thu, 30 Jul 2020 05:01:55 -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 S1728315AbgG3MAg (ORCPT + 99 others); Thu, 30 Jul 2020 08:00:36 -0400 Received: from relay.sw.ru ([185.231.240.75]:56868 "EHLO relay3.sw.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728112AbgG3MAd (ORCPT ); Thu, 30 Jul 2020 08:00:33 -0400 Received: from [192.168.15.64] (helo=localhost.localdomain) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1k17EO-0002yI-Is; Thu, 30 Jul 2020 15:00:16 +0300 Subject: [PATCH 13/23] user: Add user 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:30 +0300 Message-ID: <159611043002.535980.3019217992777905831.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 --- kernel/user_namespace.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c index 367a942bb484..bbfd7f0f9e7c 100644 --- a/kernel/user_namespace.c +++ b/kernel/user_namespace.c @@ -137,7 +137,13 @@ int create_user_ns(struct cred *new) goto fail_keyring; set_cred_user_ns(new, ns); + + if (ns_idr_register(&ns->ns)) + goto fail_sysctl; + return 0; +fail_sysctl: + retire_userns_sysctls(ns); fail_keyring: #ifdef CONFIG_PERSISTENT_KEYRINGS key_put(ns->persistent_keyring_register); @@ -186,6 +192,7 @@ static void free_user_ns(struct work_struct *work) do { struct ucounts *ucounts = ns->ucounts; parent = ns->parent; + ns_idr_unregister(&ns->ns); if (ns->gid_map.nr_extents > UID_GID_MAP_MAX_BASE_EXTENTS) { kfree(ns->gid_map.forward); kfree(ns->gid_map.reverse); @@ -1327,6 +1334,7 @@ const struct proc_ns_operations userns_operations = { static __init int user_namespaces_init(void) { user_ns_cachep = KMEM_CACHE(user_namespace, SLAB_PANIC); - return 0; + + return ns_idr_register(&init_user_ns.ns); } subsys_initcall(user_namespaces_init);