timens: add timens_commit() helper
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 6 Jul 2020 15:49:10 +0000 (17:49 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 8 Jul 2020 09:14:21 +0000 (11:14 +0200)
Wrap the calls to timens_set_vvar_page() and vdso_join_timens() in
timens_on_fork() and timens_install() in a new timens_commit() helper.
We'll use this helper in a follow-up patch in nsproxy too.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Reviewed-by: Andrei Vagin <avagin@gmail.com>
Cc: Will Deacon <will@kernel.org>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Dmitry Safonov <dima@arista.com>
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20200706154912.3248030-3-christian.brauner@ubuntu.com
kernel/time/namespace.c

index e5af6fe..aa7b90a 100644 (file)
@@ -280,6 +280,12 @@ static void timens_put(struct ns_common *ns)
        put_time_ns(to_time_ns(ns));
 }
 
+static void timens_commit(struct task_struct *tsk, struct time_namespace *ns)
+{
+       timens_set_vvar_page(tsk, ns);
+       vdso_join_timens(tsk, ns);
+}
+
 static int timens_install(struct nsset *nsset, struct ns_common *new)
 {
        struct nsproxy *nsproxy = nsset->nsproxy;
@@ -292,9 +298,8 @@ static int timens_install(struct nsset *nsset, struct ns_common *new)
            !ns_capable(nsset->cred->user_ns, CAP_SYS_ADMIN))
                return -EPERM;
 
-       timens_set_vvar_page(current, ns);
 
-       vdso_join_timens(current, ns);
+       timens_commit(current, ns);
 
        get_time_ns(ns);
        put_time_ns(nsproxy->time_ns);
@@ -315,14 +320,12 @@ int timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk)
        if (nsproxy->time_ns == nsproxy->time_ns_for_children)
                return 0;
 
-       timens_set_vvar_page(tsk, ns);
-
-       vdso_join_timens(tsk, ns);
-
        get_time_ns(ns);
        put_time_ns(nsproxy->time_ns);
        nsproxy->time_ns = ns;
 
+       timens_commit(tsk, ns);
+
        return 0;
 }