Lines Matching +full:up +full:-
1 // SPDX-License-Identifier: GPL-2.0-only
5 * (C) Copyright 1991-2000 Linus Torvalds
7 * We have a per-user structure to keep track of how many
9 * able to have per-user limits for system resources.
94 #define UIDHASH_MASK (UIDHASH_SZ - 1)
104 * task-structs get RCU-freed. Hence all locking must be softirq-safe.
106 * local_bh_enable() with local interrupts disabled is an error - we'll run
122 static void uid_hash_insert(struct user_struct *up, struct hlist_head *hashent) in uid_hash_insert() argument
124 hlist_add_head(&up->uidhash_node, hashent); in uid_hash_insert()
127 static void uid_hash_remove(struct user_struct *up) in uid_hash_remove() argument
129 hlist_del_init(&up->uidhash_node); in uid_hash_remove()
137 if (uid_eq(user->uid, uid)) { in uid_hash_find()
138 refcount_inc(&user->__count); in uid_hash_find()
146 static int user_epoll_alloc(struct user_struct *up) in user_epoll_alloc() argument
149 return percpu_counter_init(&up->epoll_watches, 0, GFP_KERNEL); in user_epoll_alloc()
155 static void user_epoll_free(struct user_struct *up) in user_epoll_free() argument
158 percpu_counter_destroy(&up->epoll_watches); in user_epoll_free()
166 static void free_user(struct user_struct *up, unsigned long flags) in free_user() argument
169 uid_hash_remove(up); in free_user()
171 user_epoll_free(up); in free_user()
172 kmem_cache_free(uid_cachep, up); in free_user()
192 void free_uid(struct user_struct *up) in free_uid() argument
196 if (!up) in free_uid()
199 if (refcount_dec_and_lock_irqsave(&up->__count, &uidhash_lock, &flags)) in free_uid()
200 free_user(up, flags); in free_uid()
207 struct user_struct *up, *new; in alloc_uid() local
210 up = uid_hash_find(uid, hashent); in alloc_uid()
213 if (!up) { in alloc_uid()
218 new->uid = uid; in alloc_uid()
219 refcount_set(&new->__count, 1); in alloc_uid()
224 ratelimit_state_init(&new->ratelimit, HZ, 100); in alloc_uid()
225 ratelimit_set_flags(&new->ratelimit, RATELIMIT_MSG_ON_RELEASE); in alloc_uid()
232 up = uid_hash_find(uid, hashent); in alloc_uid()
233 if (up) { in alloc_uid()
238 up = new; in alloc_uid()
243 return up; in alloc_uid()