• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_SCHED_USER_H
3 #define _LINUX_SCHED_USER_H
4 
5 #include <linux/uidgid.h>
6 #include <linux/atomic.h>
7 #include <linux/percpu_counter.h>
8 #include <linux/refcount.h>
9 #include <linux/ratelimit.h>
10 #include <linux/android_kabi.h>
11 
12 /*
13  * Some day this will be a full-fledged user tracking system..
14  */
15 struct user_struct {
16 	refcount_t __count;	/* reference count */
17 #ifdef CONFIG_EPOLL
18 	struct percpu_counter epoll_watches; /* The number of file descriptors currently watched */
19 #endif
20 	unsigned long unix_inflight;	/* How many files in flight in unix sockets */
21 	atomic_long_t pipe_bufs;  /* how many pages are allocated in pipe buffers */
22 
23 	/* Hash table maintenance information */
24 	struct hlist_node uidhash_node;
25 	kuid_t uid;
26 
27 #if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL) || \
28     defined(CONFIG_NET) || defined(CONFIG_IO_URING)
29 	atomic_long_t locked_vm;
30 #endif
31 #ifdef CONFIG_WATCH_QUEUE
32 	atomic_t nr_watches;	/* The number of watches this user currently has */
33 #endif
34 
35 	/* Miscellaneous per-user rate limit */
36 	struct ratelimit_state ratelimit;
37 
38 	ANDROID_KABI_RESERVE(1);
39 	ANDROID_KABI_RESERVE(2);
40 };
41 
42 struct ext_user_struct {
43 	struct user_struct user;
44 	ANDROID_OEM_DATA_ARRAY(1, 2);
45 };
46 
47 extern int uids_sysfs_init(void);
48 
49 extern struct user_struct *find_user(kuid_t);
50 
51 extern struct ext_user_struct ext_root_user;
52 extern struct user_struct *root_user;
53 #define INIT_USER (&ext_root_user.user)
54 
55 /* per-UID process charging. */
56 extern struct user_struct * alloc_uid(kuid_t);
get_uid(struct user_struct * u)57 static inline struct user_struct *get_uid(struct user_struct *u)
58 {
59 	refcount_inc(&u->__count);
60 	return u;
61 }
62 extern void free_uid(struct user_struct *);
63 
64 #endif /* _LINUX_SCHED_USER_H */
65