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-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * The "user cache".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * (C) Copyright 1991-2000 Linus Torvalds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * We have a per-user structure to keep track of how many
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * processes, files etc the user has claimed, in order to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * able to have per-user limits for system resources. 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/bitops.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/key.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/sched/user.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/user_namespace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/proc_ns.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * userns count is 1 for root user, 1 for init_uts_ns,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * and 1 for... ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) struct user_namespace init_user_ns = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	.uid_map = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 		.nr_extents = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 			.extent[0] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 				.first = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 				.lower_first = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 				.count = 4294967295U,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	.gid_map = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 		.nr_extents = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 			.extent[0] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 				.first = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 				.lower_first = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 				.count = 4294967295U,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	.projid_map = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		.nr_extents = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 			.extent[0] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 				.first = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 				.lower_first = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 				.count = 4294967295U,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 			},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	.count = ATOMIC_INIT(3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	.owner = GLOBAL_ROOT_UID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	.group = GLOBAL_ROOT_GID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	.ns.inum = PROC_USER_INIT_INO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) #ifdef CONFIG_USER_NS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	.ns.ops = &userns_operations,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	.flags = USERNS_INIT_FLAGS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) #ifdef CONFIG_KEYS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	.keyring_name_list = LIST_HEAD_INIT(init_user_ns.keyring_name_list),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	.keyring_sem = __RWSEM_INITIALIZER(init_user_ns.keyring_sem),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) EXPORT_SYMBOL_GPL(init_user_ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  * UID task count cache, to get fast user lookup in "alloc_uid"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  * when changing user ID's (ie setuid() and friends).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) #define UIDHASH_BITS	(CONFIG_BASE_SMALL ? 3 : 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) #define UIDHASH_SZ	(1 << UIDHASH_BITS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) #define UIDHASH_MASK		(UIDHASH_SZ - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) #define __uidhashfn(uid)	(((uid >> UIDHASH_BITS) + uid) & UIDHASH_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) #define uidhashentry(uid)	(uidhash_table + __uidhashfn((__kuid_val(uid))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) static struct kmem_cache *uid_cachep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) static struct hlist_head uidhash_table[UIDHASH_SZ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  * The uidhash_lock is mostly taken from process context, but it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  * occasionally also taken from softirq/tasklet context, when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  * task-structs get RCU-freed. Hence all locking must be softirq-safe.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  * But free_uid() is also called with local interrupts disabled, and running
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  * local_bh_enable() with local interrupts disabled is an error - we'll run
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  * softirq callbacks, and they can unconditionally enable interrupts, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)  * the caller of free_uid() didn't expect that..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) static DEFINE_SPINLOCK(uidhash_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) /* root_user.__count is 1, for init task cred */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) struct user_struct root_user = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	.__count	= REFCOUNT_INIT(1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	.processes	= ATOMIC_INIT(1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	.sigpending	= ATOMIC_INIT(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	.locked_shm     = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	.uid		= GLOBAL_ROOT_UID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	.ratelimit	= RATELIMIT_STATE_INIT(root_user.ratelimit, 0, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  * These routines must be called with the uidhash spinlock held!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) static void uid_hash_insert(struct user_struct *up, struct hlist_head *hashent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	hlist_add_head(&up->uidhash_node, hashent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) static void uid_hash_remove(struct user_struct *up)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	hlist_del_init(&up->uidhash_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static struct user_struct *uid_hash_find(kuid_t uid, struct hlist_head *hashent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	struct user_struct *user;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	hlist_for_each_entry(user, hashent, uidhash_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		if (uid_eq(user->uid, uid)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 			refcount_inc(&user->__count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 			return user;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) /* IRQs are disabled and uidhash_lock is held upon function entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)  * IRQ state (as stored in flags) is restored and uidhash_lock released
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)  * upon function exit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) static void free_user(struct user_struct *up, unsigned long flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	__releases(&uidhash_lock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	uid_hash_remove(up);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	spin_unlock_irqrestore(&uidhash_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	kmem_cache_free(uid_cachep, up);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)  * Locate the user_struct for the passed UID.  If found, take a ref on it.  The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)  * caller must undo that ref with free_uid().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  * If the user_struct could not be found, return NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) struct user_struct *find_user(kuid_t uid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	struct user_struct *ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	spin_lock_irqsave(&uidhash_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	ret = uid_hash_find(uid, uidhashentry(uid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	spin_unlock_irqrestore(&uidhash_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) EXPORT_SYMBOL_GPL(find_user);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) void free_uid(struct user_struct *up)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	if (!up)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	if (refcount_dec_and_lock_irqsave(&up->__count, &uidhash_lock, &flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		free_user(up, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) EXPORT_SYMBOL_GPL(free_uid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) struct user_struct *alloc_uid(kuid_t uid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	struct hlist_head *hashent = uidhashentry(uid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	struct user_struct *up, *new;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	spin_lock_irq(&uidhash_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	up = uid_hash_find(uid, hashent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	spin_unlock_irq(&uidhash_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	if (!up) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		new = kmem_cache_zalloc(uid_cachep, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		if (!new)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 			return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		new->uid = uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		refcount_set(&new->__count, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		ratelimit_state_init(&new->ratelimit, HZ, 100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		ratelimit_set_flags(&new->ratelimit, RATELIMIT_MSG_ON_RELEASE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		 * Before adding this, check whether we raced
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		 * on adding the same user already..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		spin_lock_irq(&uidhash_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		up = uid_hash_find(uid, hashent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		if (up) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 			kmem_cache_free(uid_cachep, new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 			uid_hash_insert(new, hashent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 			up = new;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		spin_unlock_irq(&uidhash_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	return up;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) static int __init uid_cache_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	int n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	uid_cachep = kmem_cache_create("uid_cache", sizeof(struct user_struct),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 			0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	for(n = 0; n < UIDHASH_SZ; ++n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		INIT_HLIST_HEAD(uidhash_table + n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	/* Insert the root user immediately (init already runs as root) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	spin_lock_irq(&uidhash_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	uid_hash_insert(&root_user, uidhashentry(GLOBAL_ROOT_UID));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	spin_unlock_irq(&uidhash_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) subsys_initcall(uid_cache_init);