[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <159611048400.535980.3963260192974391169.stgit@localhost.localdomain>
Date: Thu, 30 Jul 2020 15:01:24 +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 23/23] time: Add time namespaces into ns_idr
Now they are exposed in /proc/namespace/ directory.
Signed-off-by: Kirill Tkhai <ktkhai@...tuozzo.com>
---
include/linux/time_namespace.h | 1 +
kernel/time/namespace.c | 11 ++++++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/include/linux/time_namespace.h b/include/linux/time_namespace.h
index a51ffc089219..18eb8a9f7d68 100644
--- a/include/linux/time_namespace.h
+++ b/include/linux/time_namespace.h
@@ -24,6 +24,7 @@ struct time_namespace {
struct page *vvar_page;
/* If set prevents changing offsets after any task joined namespace. */
bool frozen_offsets;
+ struct rcu_head rcu;
} __randomize_layout;
extern struct time_namespace init_time_ns;
diff --git a/kernel/time/namespace.c b/kernel/time/namespace.c
index c4c829eb3511..164a057ccbfc 100644
--- a/kernel/time/namespace.c
+++ b/kernel/time/namespace.c
@@ -107,8 +107,15 @@ static struct time_namespace *clone_time_ns(struct user_namespace *user_ns,
ns->user_ns = get_user_ns(user_ns);
ns->offsets = old_ns->offsets;
ns->frozen_offsets = false;
+
+ err = ns_idr_register(&ns->ns);
+ if (err)
+ goto fail_put_userns;
return ns;
+fail_put_userns:
+ put_user_ns(user_ns);
+ ns_free_inum(&ns->ns);
fail_free_page:
__free_page(ns->vvar_page);
fail_free:
@@ -228,11 +235,12 @@ static void timens_set_vvar_page(struct task_struct *task,
void free_time_ns(struct time_namespace *ns)
{
+ ns_idr_unregister(&ns->ns);
dec_time_namespaces(ns->ucounts);
put_user_ns(ns->user_ns);
ns_free_inum(&ns->ns);
__free_page(ns->vvar_page);
- kfree(ns);
+ kfree_rcu(ns, rcu);
}
static struct time_namespace *to_time_ns(struct ns_common *ns)
@@ -470,6 +478,7 @@ struct time_namespace init_time_ns = {
static int __init time_ns_init(void)
{
+ WARN_ON(ns_idr_register(&init_time_ns.ns) < 0);
return 0;
}
subsys_initcall(time_ns_init);
Powered by blists - more mailing lists