Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1869811ybg; Thu, 30 Jul 2020 05:02:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZz6F+cRQ5F3XbJmNvMadD8WM17212RNr6oT/23RJW3DeSNS7axMD/bWYxkXWMtmJC3tKC X-Received: by 2002:a05:6402:6cc:: with SMTP id n12mr2417054edy.258.1596110532948; Thu, 30 Jul 2020 05:02:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596110532; cv=none; d=google.com; s=arc-20160816; b=xWJoUXit0X4ydyAxk6NkNLI161mTjAL5ftheEwbM/iNz0L+qa2qRZPM8x3vYivCfM+ mI5cK2eaxmG3HFMQBlIWQAcSqpJwKjjO30GilrCv4eHZPtLQg0Bxx4aS+gNJH1zTJFkI yV51aw4jJ6oCc9knwPIctPsd+vf4uEYROA3LBEoAnR2QzF3K4aHL94WcYp+XIa2uDIi8 v1v2z801ygUaRNSqZgFVAHC7czFEKdkg2xh8WT2/MatiwTjgYFdxJ+osfvkCYssawLAp wCbieJR6bhr8yTEn3DTC0cZzsPlvSE2uRbUjWLeg30U2NvGc78DCV1xYhnyM87AMgDbo veig== 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=hheYMEkw8OE1NUevB7QifBpC7fK2UPl0FTr5NobNBEc=; b=dUxb5tWmMGDsq7X81BjnZKKuJSwJs/nfKDrUGu+VhIfJkcNoXejbmhlOiRhIvtxQDz N0U5J/8g6VQlHOUABjN1P559eLxtPhkGkSaaz7e6kHg+uvUc8QXMxJeE4qwPLqvwPH0C iXITHxu6Zo4PUztiHTMZiBTFZ8xXORG3/agKM+uZYnpruvPV9/LXkSVpK4QF60p2o73d yLAmriGc+ozPTEoTV8tGEmOyd75kqih16riIQZeu9CKJPi9BvdWTnPCwswPYpbPl5Jp0 VET3vzdsTUGeFCs/Vc7D9fLuFHAlAlgGNnGc2oZlImlyBnLJRXOPLGcRZABumpGqYkfW 0FtA== 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 sd17si3122103ejb.423.2020.07.30.05.01.50; Thu, 30 Jul 2020 05:02:12 -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 S1728178AbgG3MBI (ORCPT + 99 others); Thu, 30 Jul 2020 08:01:08 -0400 Received: from relay.sw.ru ([185.231.240.75]:57080 "EHLO relay3.sw.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728592AbgG3MBA (ORCPT ); Thu, 30 Jul 2020 08:01:00 -0400 Received: from [192.168.15.64] (helo=localhost.localdomain) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1k17Ep-0002zc-Ew; Thu, 30 Jul 2020 15:00:43 +0300 Subject: [PATCH 18/23] uts: Free uts namespace one RCU grace period after final counter put 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:57 +0300 Message-ID: <159611045706.535980.12888496197045005870.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 This is needed to link uts_ns into ns_idr in next patch. Signed-off-by: Kirill Tkhai --- include/linux/utsname.h | 1 + kernel/utsname.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/linux/utsname.h b/include/linux/utsname.h index 2b1737c9b244..b783d0fe6ca4 100644 --- a/include/linux/utsname.h +++ b/include/linux/utsname.h @@ -25,6 +25,7 @@ struct uts_namespace { struct user_namespace *user_ns; struct ucounts *ucounts; struct ns_common ns; + struct rcu_head rcu; } __randomize_layout; extern struct uts_namespace init_uts_ns; diff --git a/kernel/utsname.c b/kernel/utsname.c index b1ac3ca870f2..aebf4df5f592 100644 --- a/kernel/utsname.c +++ b/kernel/utsname.c @@ -103,12 +103,20 @@ struct uts_namespace *copy_utsname(unsigned long flags, return new_ns; } +static void free_uts_ns_rcu(struct rcu_head *head) +{ + struct uts_namespace *ns; + + ns = container_of(head, struct uts_namespace, rcu); + kmem_cache_free(uts_ns_cache, ns); +} + void free_uts_ns(struct uts_namespace *ns) { dec_uts_namespaces(ns->ucounts); put_user_ns(ns->user_ns); ns_free_inum(&ns->ns); - kmem_cache_free(uts_ns_cache, ns); + call_rcu(&ns->rcu, free_uts_ns_rcu); } static inline struct uts_namespace *to_uts_ns(struct ns_common *ns)