lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <159611045706.535980.12888496197045005870.stgit@localhost.localdomain>
Date:   Thu, 30 Jul 2020 15:00:57 +0300
From:   Kirill Tkhai <ktkhai@...tuozzo.com>
To:     viro@...iv.linux.org.uk, adobriyan@...il.com, davem@...emloft.net,
        ebiederm@...ssion.com, akpm@...ux-foundation.org,
        christian.brauner@...ntu.com, areber@...hat.com, serge@...lyn.com,
        linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        ktkhai@...tuozzo.com
Subject: [PATCH 18/23] uts: Free uts namespace one RCU grace period after
 final counter put

This is needed to link uts_ns into ns_idr in next patch.

Signed-off-by: Kirill Tkhai <ktkhai@...tuozzo.com>
---
 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)


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ