Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Author: Andrei Vagin <avagin@openvz.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Author: Dmitry Safonov <dima@arista.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/time_namespace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/user_namespace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/sched/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/sched/task.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/clocksource.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/proc_ns.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/cred.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <vdso/datapage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) ktime_t do_timens_ktime_to_host(clockid_t clockid, ktime_t tim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 				struct timens_offsets *ns_offsets)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	ktime_t offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	switch (clockid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	case CLOCK_MONOTONIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 		offset = timespec64_to_ktime(ns_offsets->monotonic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	case CLOCK_BOOTTIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	case CLOCK_BOOTTIME_ALARM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 		offset = timespec64_to_ktime(ns_offsets->boottime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 		return tim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	 * Check that @tim value is in [offset, KTIME_MAX + offset]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	 * and subtract offset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	if (tim < offset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		 * User can specify @tim *absolute* value - if it's lesser than
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		 * the time namespace's offset - it's already expired.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		tim = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		tim = ktime_sub(tim, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		if (unlikely(tim > KTIME_MAX))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 			tim = KTIME_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	return tim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) static struct ucounts *inc_time_namespaces(struct user_namespace *ns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	return inc_ucount(ns, current_euid(), UCOUNT_TIME_NAMESPACES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) static void dec_time_namespaces(struct ucounts *ucounts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	dec_ucount(ucounts, UCOUNT_TIME_NAMESPACES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * clone_time_ns - Clone a time namespace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * @user_ns:	User namespace which owns a new namespace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * @old_ns:	Namespace to clone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  * Clone @old_ns and set the clone refcount to 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  * Return: The new namespace or ERR_PTR.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) static struct time_namespace *clone_time_ns(struct user_namespace *user_ns,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 					  struct time_namespace *old_ns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	struct time_namespace *ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	struct ucounts *ucounts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	err = -ENOSPC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	ucounts = inc_time_namespaces(user_ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	if (!ucounts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	ns = kmalloc(sizeof(*ns), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	if (!ns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		goto fail_dec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	kref_init(&ns->kref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	ns->vvar_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	if (!ns->vvar_page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		goto fail_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	err = ns_alloc_inum(&ns->ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		goto fail_free_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	ns->ucounts = ucounts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	ns->ns.ops = &timens_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	ns->user_ns = get_user_ns(user_ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	ns->offsets = old_ns->offsets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	ns->frozen_offsets = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	return ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) fail_free_page:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	__free_page(ns->vvar_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) fail_free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	kfree(ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) fail_dec:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	dec_time_namespaces(ucounts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	return ERR_PTR(err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  * copy_time_ns - Create timens_for_children from @old_ns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  * @flags:	Cloning flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  * @user_ns:	User namespace which owns a new namespace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  * @old_ns:	Namespace to clone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  * If CLONE_NEWTIME specified in @flags, creates a new timens_for_children;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  * adds a refcounter to @old_ns otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)  * Return: timens_for_children namespace or ERR_PTR.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) struct time_namespace *copy_time_ns(unsigned long flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	struct user_namespace *user_ns, struct time_namespace *old_ns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	if (!(flags & CLONE_NEWTIME))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		return get_time_ns(old_ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	return clone_time_ns(user_ns, old_ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) static struct timens_offset offset_from_ts(struct timespec64 off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	struct timens_offset ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	ret.sec = off.tv_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	ret.nsec = off.tv_nsec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)  * A time namespace VVAR page has the same layout as the VVAR page which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  * contains the system wide VDSO data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)  * For a normal task the VVAR pages are installed in the normal ordering:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  *     VVAR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  *     PVCLOCK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  *     HVCLOCK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  *     TIMENS   <- Not really required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  * Now for a timens task the pages are installed in the following order:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)  *     TIMENS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)  *     PVCLOCK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)  *     HVCLOCK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)  *     VVAR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)  * The check for vdso_data->clock_mode is in the unlikely path of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)  * the seq begin magic. So for the non-timens case most of the time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)  * 'seq' is even, so the branch is not taken.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)  * If 'seq' is odd, i.e. a concurrent update is in progress, the extra check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)  * for vdso_data->clock_mode is a non-issue. The task is spin waiting for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)  * update to finish and for 'seq' to become even anyway.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  * Timens page has vdso_data->clock_mode set to VDSO_CLOCKMODE_TIMENS which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  * enforces the time namespace handling path.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) static void timens_setup_vdso_data(struct vdso_data *vdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 				   struct time_namespace *ns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	struct timens_offset *offset = vdata->offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	struct timens_offset monotonic = offset_from_ts(ns->offsets.monotonic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	struct timens_offset boottime = offset_from_ts(ns->offsets.boottime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	vdata->seq			= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	vdata->clock_mode		= VDSO_CLOCKMODE_TIMENS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	offset[CLOCK_MONOTONIC]		= monotonic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	offset[CLOCK_MONOTONIC_RAW]	= monotonic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	offset[CLOCK_MONOTONIC_COARSE]	= monotonic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	offset[CLOCK_BOOTTIME]		= boottime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	offset[CLOCK_BOOTTIME_ALARM]	= boottime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)  * Protects possibly multiple offsets writers racing each other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)  * and tasks entering the namespace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) static DEFINE_MUTEX(offset_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) static void timens_set_vvar_page(struct task_struct *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 				struct time_namespace *ns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	struct vdso_data *vdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	if (ns == &init_time_ns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	/* Fast-path, taken by every task in namespace except the first. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	if (likely(ns->frozen_offsets))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	mutex_lock(&offset_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	/* Nothing to-do: vvar_page has been already initialized. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	if (ns->frozen_offsets)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	ns->frozen_offsets = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	vdata = arch_get_vdso_data(page_address(ns->vvar_page));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	for (i = 0; i < CS_BASES; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		timens_setup_vdso_data(&vdata[i], ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	mutex_unlock(&offset_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) void free_time_ns(struct kref *kref)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	struct time_namespace *ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	ns = container_of(kref, struct time_namespace, kref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	dec_time_namespaces(ns->ucounts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	put_user_ns(ns->user_ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	ns_free_inum(&ns->ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	__free_page(ns->vvar_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	kfree(ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) static struct time_namespace *to_time_ns(struct ns_common *ns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	return container_of(ns, struct time_namespace, ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) static struct ns_common *timens_get(struct task_struct *task)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	struct time_namespace *ns = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	struct nsproxy *nsproxy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	task_lock(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	nsproxy = task->nsproxy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	if (nsproxy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		ns = nsproxy->time_ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		get_time_ns(ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	task_unlock(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	return ns ? &ns->ns : NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) static struct ns_common *timens_for_children_get(struct task_struct *task)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	struct time_namespace *ns = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	struct nsproxy *nsproxy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	task_lock(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	nsproxy = task->nsproxy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	if (nsproxy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 		ns = nsproxy->time_ns_for_children;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		get_time_ns(ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	task_unlock(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	return ns ? &ns->ns : NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) static void timens_put(struct ns_common *ns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	put_time_ns(to_time_ns(ns));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) void timens_commit(struct task_struct *tsk, struct time_namespace *ns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	timens_set_vvar_page(tsk, ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	vdso_join_timens(tsk, ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) static int timens_install(struct nsset *nsset, struct ns_common *new)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	struct nsproxy *nsproxy = nsset->nsproxy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	struct time_namespace *ns = to_time_ns(new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	if (!current_is_single_threaded())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		return -EUSERS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	    !ns_capable(nsset->cred->user_ns, CAP_SYS_ADMIN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 		return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	get_time_ns(ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	put_time_ns(nsproxy->time_ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	nsproxy->time_ns = ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	get_time_ns(ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	put_time_ns(nsproxy->time_ns_for_children);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	nsproxy->time_ns_for_children = ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) int timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	struct ns_common *nsc = &nsproxy->time_ns_for_children->ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	struct time_namespace *ns = to_time_ns(nsc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	/* create_new_namespaces() already incremented the ref counter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	if (nsproxy->time_ns == nsproxy->time_ns_for_children)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	get_time_ns(ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	put_time_ns(nsproxy->time_ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	nsproxy->time_ns = ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	timens_commit(tsk, ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) static struct user_namespace *timens_owner(struct ns_common *ns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	return to_time_ns(ns)->user_ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) static void show_offset(struct seq_file *m, int clockid, struct timespec64 *ts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	char *clock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	switch (clockid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	case CLOCK_BOOTTIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 		clock = "boottime";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	case CLOCK_MONOTONIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 		clock = "monotonic";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 		clock = "unknown";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	seq_printf(m, "%-10s %10lld %9ld\n", clock, ts->tv_sec, ts->tv_nsec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) void proc_timens_show_offsets(struct task_struct *p, struct seq_file *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	struct ns_common *ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	struct time_namespace *time_ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	ns = timens_for_children_get(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	if (!ns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	time_ns = to_time_ns(ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	show_offset(m, CLOCK_MONOTONIC, &time_ns->offsets.monotonic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	show_offset(m, CLOCK_BOOTTIME, &time_ns->offsets.boottime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	put_time_ns(time_ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) int proc_timens_set_offset(struct file *file, struct task_struct *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 			   struct proc_timens_offset *offsets, int noffsets)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	struct ns_common *ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	struct time_namespace *time_ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	struct timespec64 tp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	int i, err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	ns = timens_for_children_get(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	if (!ns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		return -ESRCH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	time_ns = to_time_ns(ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	if (!file_ns_capable(file, time_ns->user_ns, CAP_SYS_TIME)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		put_time_ns(time_ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 		return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	for (i = 0; i < noffsets; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 		struct proc_timens_offset *off = &offsets[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 		switch (off->clockid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 		case CLOCK_MONOTONIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 			ktime_get_ts64(&tp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 		case CLOCK_BOOTTIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 			ktime_get_boottime_ts64(&tp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 			err = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 		err = -ERANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 		if (off->val.tv_sec > KTIME_SEC_MAX ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 		    off->val.tv_sec < -KTIME_SEC_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 		tp = timespec64_add(tp, off->val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 		 * KTIME_SEC_MAX is divided by 2 to be sure that KTIME_MAX is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 		 * still unreachable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 		if (tp.tv_sec < 0 || tp.tv_sec > KTIME_SEC_MAX / 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	mutex_lock(&offset_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	if (time_ns->frozen_offsets) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 		err = -EACCES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 		goto out_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	/* Don't report errors after this line */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	for (i = 0; i < noffsets; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 		struct proc_timens_offset *off = &offsets[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 		struct timespec64 *offset = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 		switch (off->clockid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 		case CLOCK_MONOTONIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 			offset = &time_ns->offsets.monotonic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 		case CLOCK_BOOTTIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 			offset = &time_ns->offsets.boottime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 		*offset = off->val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) out_unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	mutex_unlock(&offset_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	put_time_ns(time_ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) const struct proc_ns_operations timens_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	.name		= "time",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	.type		= CLONE_NEWTIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	.get		= timens_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	.put		= timens_put,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	.install	= timens_install,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	.owner		= timens_owner,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) const struct proc_ns_operations timens_for_children_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	.name		= "time_for_children",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	.real_ns_name	= "time",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	.type		= CLONE_NEWTIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	.get		= timens_for_children_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	.put		= timens_put,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	.install	= timens_install,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	.owner		= timens_owner,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) struct time_namespace init_time_ns = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	.kref		= KREF_INIT(3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	.user_ns	= &init_user_ns,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	.ns.inum	= PROC_TIME_INIT_INO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	.ns.ops		= &timens_operations,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	.frozen_offsets	= true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) static int __init time_ns_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) subsys_initcall(time_ns_init);