Skip to content

Commit 5cfea9a

Browse files
author
Christian Brauner
committed
timens: add timens_commit() helper
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 <[email protected]> Reviewed-by: Andrei Vagin <[email protected]> Cc: Will Deacon <[email protected]> Cc: Vincenzo Frascino <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Dmitry Safonov <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent 4281580 commit 5cfea9a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

kernel/time/namespace.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,12 @@ static void timens_put(struct ns_common *ns)
280280
put_time_ns(to_time_ns(ns));
281281
}
282282

283+
static void timens_commit(struct task_struct *tsk, struct time_namespace *ns)
284+
{
285+
timens_set_vvar_page(tsk, ns);
286+
vdso_join_timens(tsk, ns);
287+
}
288+
283289
static int timens_install(struct nsset *nsset, struct ns_common *new)
284290
{
285291
struct nsproxy *nsproxy = nsset->nsproxy;
@@ -292,9 +298,8 @@ static int timens_install(struct nsset *nsset, struct ns_common *new)
292298
!ns_capable(nsset->cred->user_ns, CAP_SYS_ADMIN))
293299
return -EPERM;
294300

295-
timens_set_vvar_page(current, ns);
296301

297-
vdso_join_timens(current, ns);
302+
timens_commit(current, ns);
298303

299304
get_time_ns(ns);
300305
put_time_ns(nsproxy->time_ns);
@@ -315,14 +320,12 @@ int timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk)
315320
if (nsproxy->time_ns == nsproxy->time_ns_for_children)
316321
return 0;
317322

318-
timens_set_vvar_page(tsk, ns);
319-
320-
vdso_join_timens(tsk, ns);
321-
322323
get_time_ns(ns);
323324
put_time_ns(nsproxy->time_ns);
324325
nsproxy->time_ns = ns;
325326

327+
timens_commit(tsk, ns);
328+
326329
return 0;
327330
}
328331

0 commit comments

Comments
 (0)