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