On Fri 12-09-25 13:52:46, Christian Brauner wrote:
> Support the generic ns lookup infrastructure to support file handles for
> namespaces.
> 
> Reviewed-by: Thomas Gleixner <t...@linutronix.de>
> Signed-off-by: Christian Brauner <brau...@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <j...@suse.cz>

                                                                Honza

> ---
>  include/linux/time_namespace.h |  5 +++++
>  init/main.c                    |  2 ++
>  kernel/time/namespace.c        | 11 ++++++++++-
>  3 files changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/time_namespace.h b/include/linux/time_namespace.h
> index bb2c52f4fc94..7f6af7a9771e 100644
> --- a/include/linux/time_namespace.h
> +++ b/include/linux/time_namespace.h
> @@ -33,6 +33,7 @@ struct time_namespace {
>  extern struct time_namespace init_time_ns;
>  
>  #ifdef CONFIG_TIME_NS
> +void __init time_ns_init(void);
>  extern int vdso_join_timens(struct task_struct *task,
>                           struct time_namespace *ns);
>  extern void timens_commit(struct task_struct *tsk, struct time_namespace 
> *ns);
> @@ -108,6 +109,10 @@ static inline ktime_t timens_ktime_to_host(clockid_t 
> clockid, ktime_t tim)
>  }
>  
>  #else
> +static inline void __init time_ns_init(void)
> +{
> +}
> +
>  static inline int vdso_join_timens(struct task_struct *task,
>                                  struct time_namespace *ns)
>  {
> diff --git a/init/main.c b/init/main.c
> index 0ee0ee7b7c2c..e7d2c57c65a7 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -103,6 +103,7 @@
>  #include <linux/randomize_kstack.h>
>  #include <linux/pidfs.h>
>  #include <linux/ptdump.h>
> +#include <linux/time_namespace.h>
>  #include <net/net_namespace.h>
>  
>  #include <asm/io.h>
> @@ -1072,6 +1073,7 @@ void start_kernel(void)
>       fork_init();
>       proc_caches_init();
>       uts_ns_init();
> +     time_ns_init();
>       key_init();
>       security_init();
>       dbg_late_init();
> diff --git a/kernel/time/namespace.c b/kernel/time/namespace.c
> index 0be93d8f2896..408f60d0a3b6 100644
> --- a/kernel/time/namespace.c
> +++ b/kernel/time/namespace.c
> @@ -12,6 +12,7 @@
>  #include <linux/seq_file.h>
>  #include <linux/proc_ns.h>
>  #include <linux/export.h>
> +#include <linux/nstree.h>
>  #include <linux/time.h>
>  #include <linux/slab.h>
>  #include <linux/cred.h>
> @@ -104,6 +105,7 @@ 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;
> +     ns_tree_add(ns);
>       return ns;
>  
>  fail_free_page:
> @@ -250,11 +252,13 @@ static void timens_set_vvar_page(struct task_struct 
> *task,
>  
>  void free_time_ns(struct time_namespace *ns)
>  {
> +     ns_tree_remove(ns);
>       dec_time_namespaces(ns->ucounts);
>       put_user_ns(ns->user_ns);
>       ns_free_inum(&ns->ns);
>       __free_page(ns->vvar_page);
> -     kfree(ns);
> +     /* Concurrent nstree traversal depends on a grace period. */
> +     kfree_rcu(ns, ns.ns_rcu);
>  }
>  
>  static struct time_namespace *to_time_ns(struct ns_common *ns)
> @@ -487,3 +491,8 @@ struct time_namespace init_time_ns = {
>       .ns.ops         = &timens_operations,
>       .frozen_offsets = true,
>  };
> +
> +void __init time_ns_init(void)
> +{
> +     ns_tree_add(&init_time_ns);
> +}
> 
> -- 
> 2.47.3
> 
-- 
Jan Kara <j...@suse.com>
SUSE Labs, CR

Reply via email to