hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/kernel/user.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * The "user cache".
34 *
....@@ -17,7 +18,6 @@
1718 #include <linux/interrupt.h>
1819 #include <linux/export.h>
1920 #include <linux/user_namespace.h>
20
-#include <linux/proc_fs.h>
2121 #include <linux/proc_ns.h>
2222
2323 /*
....@@ -63,9 +63,9 @@
6363 .ns.ops = &userns_operations,
6464 #endif
6565 .flags = USERNS_INIT_FLAGS,
66
-#ifdef CONFIG_PERSISTENT_KEYRINGS
67
- .persistent_keyring_register_sem =
68
- __RWSEM_INITIALIZER(init_user_ns.persistent_keyring_register_sem),
66
+#ifdef CONFIG_KEYS
67
+ .keyring_name_list = LIST_HEAD_INIT(init_user_ns.keyring_name_list),
68
+ .keyring_sem = __RWSEM_INITIALIZER(init_user_ns.keyring_sem),
6969 #endif
7070 };
7171 EXPORT_SYMBOL_GPL(init_user_ns);
....@@ -82,7 +82,7 @@
8282 #define uidhashentry(uid) (uidhash_table + __uidhashfn((__kuid_val(uid))))
8383
8484 static struct kmem_cache *uid_cachep;
85
-struct hlist_head uidhash_table[UIDHASH_SZ];
85
+static struct hlist_head uidhash_table[UIDHASH_SZ];
8686
8787 /*
8888 * The uidhash_lock is mostly taken from process context, but it is
....@@ -141,8 +141,6 @@
141141 {
142142 uid_hash_remove(up);
143143 spin_unlock_irqrestore(&uidhash_lock, flags);
144
- key_put(up->uid_keyring);
145
- key_put(up->session_keyring);
146144 kmem_cache_free(uid_cachep, up);
147145 }
148146
....@@ -162,6 +160,7 @@
162160 spin_unlock_irqrestore(&uidhash_lock, flags);
163161 return ret;
164162 }
163
+EXPORT_SYMBOL_GPL(find_user);
165164
166165 void free_uid(struct user_struct *up)
167166 {
....@@ -173,6 +172,7 @@
173172 if (refcount_dec_and_lock_irqsave(&up->__count, &uidhash_lock, &flags))
174173 free_user(up, flags);
175174 }
175
+EXPORT_SYMBOL_GPL(free_uid);
176176
177177 struct user_struct *alloc_uid(kuid_t uid)
178178 {
....@@ -186,7 +186,7 @@
186186 if (!up) {
187187 new = kmem_cache_zalloc(uid_cachep, GFP_KERNEL);
188188 if (!new)
189
- goto out_unlock;
189
+ return NULL;
190190
191191 new->uid = uid;
192192 refcount_set(&new->__count, 1);
....@@ -200,8 +200,6 @@
200200 spin_lock_irq(&uidhash_lock);
201201 up = uid_hash_find(uid, hashent);
202202 if (up) {
203
- key_put(new->uid_keyring);
204
- key_put(new->session_keyring);
205203 kmem_cache_free(uid_cachep, new);
206204 } else {
207205 uid_hash_insert(new, hashent);
....@@ -209,12 +207,8 @@
209207 }
210208 spin_unlock_irq(&uidhash_lock);
211209 }
212
- proc_register_uid(uid);
213210
214211 return up;
215
-
216
-out_unlock:
217
- return NULL;
218212 }
219213
220214 static int __init uid_cache_init(void)
....@@ -231,7 +225,6 @@
231225 spin_lock_irq(&uidhash_lock);
232226 uid_hash_insert(&root_user, uidhashentry(GLOBAL_ROOT_UID));
233227 spin_unlock_irq(&uidhash_lock);
234
- proc_register_uid(GLOBAL_ROOT_UID);
235228
236229 return 0;
237230 }